MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / PrintCharAndCodeTo

Function PrintCharAndCodeTo

source/test/gtest/gtest-printers.cc:251–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249// also properly escaped using the standard C++ escape sequence.
250template <typename Char>
251void PrintCharAndCodeTo(Char c, ostream* os) {
252 // First, print c as a literal in the most readable form we can find.
253 *os << GetCharWidthPrefix(c) << "'";
254 const CharFormat format = PrintAsCharLiteralTo(c, os);
255 *os << "'";
256
257 // To aid user debugging, we also print c's code in decimal, unless
258 // it's 0 (in which case c was printed as '\\0', making the code
259 // obvious).
260 if (c == 0) return;
261 *os << " (" << static_cast<int>(c);
262
263 // For more convenience, we print c's code again in hexadecimal,
264 // unless c was already printed in the form '\x##' or the code is in
265 // [1, 9].
266 if (format == kHexEscape || (1 <= c && c <= 9)) {
267 // Do nothing.
268 } else {
269 *os << ", 0x" << String::FormatHexInt(static_cast<int>(c));
270 }
271 *os << ")";
272}
273
274void PrintTo(unsigned char c, ::std::ostream* os) { PrintCharAndCodeTo(c, os); }
275void PrintTo(signed char c, ::std::ostream* os) { PrintCharAndCodeTo(c, os); }

Callers 1

PrintToFunction · 0.70

Calls 2

GetCharWidthPrefixFunction · 0.70
PrintAsCharLiteralToFunction · 0.70

Tested by

no test coverage detected