Prints the bytes in the given value to the given ostream.
| 80 | |
| 81 | // Prints the bytes in the given value to the given ostream. |
| 82 | void 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 |
no test coverage detected