MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / StringStreamToString

Function StringStreamToString

tests/gtest/src/gtest.cc:2164–2180  ·  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

2162// Converts the buffer in a stringstream to an std::string, converting NUL
2163// bytes to "\\0" along the way.
2164std::string StringStreamToString(::std::stringstream* ss) {
2165 const ::std::string& str = ss->str();
2166 const char* const start = str.c_str();
2167 const char* const end = start + str.length();
2168
2169 std::string result;
2170 result.reserve(static_cast<size_t>(2 * (end - start)));
2171 for (const char* ch = start; ch != end; ++ch) {
2172 if (*ch == '\0') {
2173 result += "\\0"; // Replaces NUL with "\\0";
2174 } else {
2175 result += *ch;
2176 }
2177 }
2178
2179 return result;
2180}
2181
2182// Appends the user-supplied message to the Google-Test-generated message.
2183std::string AppendUserMessage(const std::string& gtest_msg,

Callers 6

GetStringMethod · 0.70
FloatingPointLEFunction · 0.70
WideStringToUtf8Function · 0.70
OnTestIterationEndMethod · 0.70
gtest.hFile · 0.50

Calls 4

strMethod · 0.45
c_strMethod · 0.45
lengthMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected