MCPcopy Create free account
hub / github.com/apache/singa / PrintCharsAsStringTo

Function PrintCharsAsStringTo

test/gtest/gtest-all.cc:9268–9284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9266// and may not be NUL-terminated.
9267template <typename CharType>
9268static void PrintCharsAsStringTo(
9269 const CharType* begin, size_t len, ostream* os) {
9270 const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\"";
9271 *os << kQuoteBegin;
9272 bool is_previous_hex = false;
9273 for (size_t index = 0; index < len; ++index) {
9274 const CharType cur = begin[index];
9275 if (is_previous_hex && IsXDigit(cur)) {
9276 // Previous character is of '\x..' form and this character can be
9277 // interpreted as another hexadecimal digit in its number. Break string to
9278 // disambiguate.
9279 *os << "\" " << kQuoteBegin;
9280 }
9281 is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;
9282 }
9283 *os << "\"";
9284}
9285
9286// Prints a (const) char/wchar_t array of 'len' elements, starting at address
9287// 'begin'. CharType must be either char or wchar_t.

Callers 4

UniversalPrintCharArrayFunction · 0.85
PrintToFunction · 0.85
PrintStringToFunction · 0.85
PrintWideStringToFunction · 0.85

Calls 2

IsXDigitFunction · 0.85
PrintAsStringLiteralToFunction · 0.85

Tested by

no test coverage detected