MCPcopy Create free account
hub / github.com/GarageGames/Torque2D / StringStreamToString

Function StringStreamToString

engine/source/testing/googleTest/src/gtest.cc:1735–1752  ·  view source on GitHub ↗

Converts the buffer in a stringstream to a String, converting NUL bytes to "\\0" along the way.

Source from the content-addressed store, hash-verified

1733// Converts the buffer in a stringstream to a String, converting NUL
1734// bytes to "\\0" along the way.
1735String StringStreamToString(::std::stringstream* ss) {
1736 const ::std::string& str = ss->str();
1737 const char* const start = str.c_str();
1738 const char* const end = start + str.length();
1739
1740 // We need to use a helper stringstream to do this transformation
1741 // because String doesn't support push_back().
1742 ::std::stringstream helper;
1743 for (const char* ch = start; ch != end; ++ch) {
1744 if (*ch == '\0') {
1745 helper << "\\0"; // Replaces NUL with "\\0";
1746 } else {
1747 helper.put(*ch);
1748 }
1749 }
1750
1751 return String(helper.str().c_str());
1752}
1753
1754// Appends the user-supplied message to the Google-Test-generated message.
1755String AppendUserMessage(const String& gtest_msg,

Callers 6

FloatingPointLEFunction · 0.70
WideStringToUtf8Function · 0.70
PrintXmlTestCaseMethod · 0.70
TESTFunction · 0.50
GetStringFunction · 0.50
CmpHelperFloatingPointEQFunction · 0.50

Calls 3

c_strMethod · 0.80
StringFunction · 0.50
lengthMethod · 0.45

Tested by

no test coverage detected