MCPcopy Create free account
hub / github.com/apache/brpc / PrintString

Function PrintString

src/butil/binary_printer.cpp:120–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118
119template <typename Appender>
120static void PrintString(Appender* appender, const StringPiece& s, size_t max_length) {
121 BinaryCharPrinter<Appender> printer(appender);
122 for (size_t i = 0; i < s.size(); ++i) {
123 if (i >= max_length) {
124 printer.Flush();
125 char buf[48];
126 int len = snprintf(buf, sizeof(buf), "...<skipping %" PRIu64 " bytes>",
127 (uint64_t)(s.size() - i));
128 appender->Append(buf, len);
129 return;
130 }
131 printer.PushChar(s[i]);
132 }
133}
134
135void ToPrintable::Print(std::ostream& os) const {
136 OStreamAppender appender(os);

Callers 2

PrintMethod · 0.85
ToPrintableStringFunction · 0.85

Calls 5

snprintfFunction · 0.85
PushCharMethod · 0.80
sizeMethod · 0.45
FlushMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected