MCPcopy Create free account
hub / github.com/EmbeddedRPC/erpc / StringStreamToString

Function StringStreamToString

test/common/gtest/gtest.cpp:3454–3470  ·  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

3452// Converts the buffer in a stringstream to an std::string, converting NUL
3453// bytes to "\\0" along the way.
3454std::string StringStreamToString(::std::stringstream* ss) {
3455 const ::std::string& str = ss->str();
3456 const char* const start = str.c_str();
3457 const char* const end = start + str.length();
3458
3459 std::string result;
3460 result.reserve(2 * (end - start));
3461 for (const char* ch = start; ch != end; ++ch) {
3462 if (*ch == '\0') {
3463 result += "\\0"; // Replaces NUL with "\\0";
3464 } else {
3465 result += *ch;
3466 }
3467 }
3468
3469 return result;
3470}
3471
3472// Appends the user-supplied message to the Google-Test-generated message.
3473std::string AppendUserMessage(const std::string& gtest_msg,

Callers 5

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

Calls

no outgoing calls

Tested by

no test coverage detected