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

Function StringStreamToString

test/gtest/gtest-all.cc:3143–3159  ·  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

3141// Converts the buffer in a stringstream to an std::string, converting NUL
3142// bytes to "\\0" along the way.
3143std::string StringStreamToString(::std::stringstream* ss) {
3144 const ::std::string& str = ss->str();
3145 const char* const start = str.c_str();
3146 const char* const end = start + str.length();
3147
3148 std::string result;
3149 result.reserve(2 * (end - start));
3150 for (const char* ch = start; ch != end; ++ch) {
3151 if (*ch == '\0') {
3152 result += "\\0"; // Replaces NUL with "\\0";
3153 } else {
3154 result += *ch;
3155 }
3156 }
3157
3158 return result;
3159}
3160
3161// Appends the user-supplied message to the Google-Test-generated message.
3162std::string AppendUserMessage(const std::string& gtest_msg,

Callers 5

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