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

Function PrintIOBuf

src/butil/binary_printer.cpp:98–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97template <typename Appender>
98static void PrintIOBuf(Appender* appender, const IOBuf& b, size_t max_length) {
99 BinaryCharPrinter<Appender> printer(appender);
100 const size_t n = b.backing_block_num();
101 size_t nw = 0;
102 for (size_t i = 0; i < n; ++i) {
103 StringPiece blk = b.backing_block(i);
104 for (size_t j = 0; j < blk.size(); ++j) {
105 if (nw >= max_length) {
106 printer.Flush();
107 char buf[48];
108 int len = snprintf(buf, sizeof(buf), "...<skipping %" PRIu64 " bytes>",
109 (uint64_t)(b.size() - nw));
110 appender->Append(buf, len);
111 return;
112 }
113 ++nw;
114 printer.PushChar(blk[j]);
115 }
116 }
117}
118
119template <typename Appender>
120static void PrintString(Appender* appender, const StringPiece& s, size_t max_length) {

Callers 2

PrintMethod · 0.85
ToPrintableStringFunction · 0.85

Calls 7

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

Tested by

no test coverage detected