MCPcopy Create free account
hub / github.com/OneMoreGres/ScreenTranslator / StringStreamToString

Function StringStreamToString

external/gtest/gtest-all.cc:3474–3490  ·  view source on GitHub ↗

Converts the buffer in a stringstream to an std::string, converting NUL bytes to "\\0" along the way.

Source from the content-addressed store, hash-verified

3472// Converts the buffer in a stringstream to an std::string, converting NUL
3473// bytes to "\\0" along the way.
3474std::string StringStreamToString(::std::stringstream* ss) {
3475 const ::std::string& str = ss->str();
3476 const char* const start = str.c_str();
3477 const char* const end = start + str.length();
3478
3479 std::string result;
3480 result.reserve(static_cast<size_t>(2 * (end - start)));
3481 for (const char* ch = start; ch != end; ++ch) {
3482 if (*ch == '\0') {
3483 result += "\\0"; // Replaces NUL with "\\0";
3484 } else {
3485 result += *ch;
3486 }
3487 }
3488
3489 return result;
3490}
3491
3492// Appends the user-supplied message to the Google-Test-generated message.
3493std::string AppendUserMessage(const std::string& gtest_msg,

Callers 6

CmpHelperFloatingPointEQFunction · 0.85
GetStringMethod · 0.85
FloatingPointLEFunction · 0.85
WideStringToUtf8Function · 0.85
OnTestIterationEndMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected