MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / PrintBytesInObjectToImpl

Function PrintBytesInObjectToImpl

cpp/test/src/gtest-printers.cc:82–103  ·  view source on GitHub ↗

Prints the bytes in the given value to the given ostream.

Source from the content-addressed store, hash-verified

80
81// Prints the bytes in the given value to the given ostream.
82void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,
83 ostream* os) {
84 // Tells the user how big the object is.
85 *os << count << "-byte object <";
86
87 const size_t kThreshold = 132;
88 const size_t kChunkSize = 64;
89 // If the object size is bigger than kThreshold, we'll have to omit
90 // some details by printing only the first and the last kChunkSize
91 // bytes.
92 // TODO(wan): let the user control the threshold using a flag.
93 if (count < kThreshold) {
94 PrintByteSegmentInObjectTo(obj_bytes, 0, count, os);
95 } else {
96 PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os);
97 *os << " ... ";
98 // Rounds up to 2-byte boundary.
99 const size_t resume_pos = (count - kChunkSize + 1)/2*2;
100 PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os);
101 }
102 *os << ">";
103}
104
105} // namespace
106

Callers 1

PrintBytesInObjectToFunction · 0.85

Calls 1

Tested by

no test coverage detected