MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / StringStreamToString

Function StringStreamToString

source/test/gtest/src/gtest.cc:2198–2214  ·  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

2196// Converts the buffer in a stringstream to an std::string, converting NUL
2197// bytes to "\\0" along the way.
2198std::string StringStreamToString(::std::stringstream* ss) {
2199 const ::std::string& str = ss->str();
2200 const char* const start = str.c_str();
2201 const char* const end = start + str.length();
2202
2203 std::string result;
2204 result.reserve(static_cast<size_t>(2 * (end - start)));
2205 for (const char* ch = start; ch != end; ++ch) {
2206 if (*ch == '\0') {
2207 result += "\\0"; // Replaces NUL with "\\0";
2208 } else {
2209 result += *ch;
2210 }
2211 }
2212
2213 return result;
2214}
2215
2216// Appends the user-supplied message to the Google-Test-generated message.
2217std::string AppendUserMessage(const std::string& gtest_msg,

Callers 6

gtest.hFile · 0.85
GetStringMethod · 0.85
FloatingPointLEFunction · 0.85
WideStringToUtf8Function · 0.85
OnTestIterationEndMethod · 0.85

Calls 4

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

Tested by

no test coverage detected