MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / PrintCharsAsStringTo

Function PrintCharsAsStringTo

tests/gtest/gtest-all.cc:11370–11392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11368GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
11369GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
11370static CharFormat PrintCharsAsStringTo(
11371 const CharType* begin, size_t len, ostream* os) {
11372 const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\"";
11373 *os << kQuoteBegin;
11374 bool is_previous_hex = false;
11375 CharFormat print_format = kAsIs;
11376 for (size_t index = 0; index < len; ++index) {
11377 const CharType cur = begin[index];
11378 if (is_previous_hex && IsXDigit(cur)) {
11379 // Previous character is of '\x..' form and this character can be
11380 // interpreted as another hexadecimal digit in its number. Break string to
11381 // disambiguate.
11382 *os << "\" " << kQuoteBegin;
11383 }
11384 is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;
11385 // Remember if any characters required hex escaping.
11386 if (is_previous_hex) {
11387 print_format = kHexEscape;
11388 }
11389 }
11390 *os << "\"";
11391 return print_format;
11392}
11393
11394// Prints a (const) char/wchar_t array of 'len' elements, starting at address
11395// '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