MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / StringStreamToString

Function StringStreamToString

cpp/test/src/gtest.cc:1979–1995  ·  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

1977// Converts the buffer in a stringstream to an std::string, converting NUL
1978// bytes to "\\0" along the way.
1979std::string StringStreamToString(::std::stringstream* ss) {
1980 const ::std::string& str = ss->str();
1981 const char* const start = str.c_str();
1982 const char* const end = start + str.length();
1983
1984 std::string result;
1985 result.reserve(2 * (end - start));
1986 for (const char* ch = start; ch != end; ++ch) {
1987 if (*ch == '\0') {
1988 result += "\\0"; // Replaces NUL with "\\0";
1989 } else {
1990 result += *ch;
1991 }
1992 }
1993
1994 return result;
1995}
1996
1997// Appends the user-supplied message to the Google-Test-generated message.
1998std::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 3

c_strMethod · 0.45
lengthMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected