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

Function PrintCharsAsStringTo

source/test/gtest/src/gtest-printers.cc:337–361  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335// and may not be NUL-terminated.
336template <typename CharType>
337GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
338 GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_
339 GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ static CharFormat
340 PrintCharsAsStringTo(const CharType* begin, size_t len, ostream* os) {
341 const char* const quote_prefix = GetCharWidthPrefix(*begin);
342 *os << quote_prefix << "\"";
343 bool is_previous_hex = false;
344 CharFormat print_format = kAsIs;
345 for (size_t index = 0; index < len; ++index) {
346 const CharType cur = begin[index];
347 if (is_previous_hex && IsXDigit(cur)) {
348 // Previous character is of '\x..' form and this character can be
349 // interpreted as another hexadecimal digit in its number. Break string to
350 // disambiguate.
351 *os << "\" " << quote_prefix << "\"";
352 }
353 is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;
354 // Remember if any characters required hex escaping.
355 if (is_previous_hex) {
356 print_format = kHexEscape;
357 }
358 }
359 *os << "\"";
360 return print_format;
361}
362
363// Prints a (const) char/wchar_t array of 'len' elements, starting at address
364// 'begin'. CharType must be either char or wchar_t.

Callers 7

UniversalPrintCharArrayFunction · 0.70
PrintCStringToFunction · 0.70
PrintStringToFunction · 0.70
PrintU8StringToFunction · 0.70
PrintU16StringToFunction · 0.70
PrintU32StringToFunction · 0.70
PrintWideStringToFunction · 0.70

Calls 3

IsXDigitFunction · 0.85
GetCharWidthPrefixFunction · 0.70
PrintAsStringLiteralToFunction · 0.70

Tested by

no test coverage detected