MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/xstudio / write_format

Method write_format

extern/include/cpp-httplib/httplib.h:1576–1597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1574
1575template <typename... Args>
1576inline ssize_t Stream::write_format(const char *fmt, const Args &...args) {
1577 const auto bufsiz = 2048;
1578 std::array<char, bufsiz> buf{};
1579
1580 auto sn = snprintf(buf.data(), buf.size() - 1, fmt, args...);
1581 if (sn <= 0) { return sn; }
1582
1583 auto n = static_cast<size_t>(sn);
1584
1585 if (n >= buf.size() - 1) {
1586 std::vector<char> glowable_buf(buf.size());
1587
1588 while (n >= glowable_buf.size() - 1) {
1589 glowable_buf.resize(glowable_buf.size() * 2);
1590 n = static_cast<size_t>(
1591 snprintf(&glowable_buf[0], glowable_buf.size() - 1, fmt, args...));
1592 }
1593 return write(&glowable_buf[0], n);
1594 } else {
1595 return write(buf.data(), n);
1596 }
1597}
1598
1599inline void default_socket_options(socket_t sock) {
1600 int yes = 1;

Callers 4

write_headersFunction · 0.80
write_response_coreMethod · 0.80
process_requestMethod · 0.80
write_requestMethod · 0.80

Calls 3

dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected