MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / StringStreamToString

Function StringStreamToString

rtpose_wrapper/src/gtest/gtest-all.cpp:3038–3055  ·  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

3036// Converts the buffer in a stringstream to a String, converting NUL
3037// bytes to "\\0" along the way.
3038String StringStreamToString(::std::stringstream* ss) {
3039 const ::std::string& str = ss->str();
3040 const char* const start = str.c_str();
3041 const char* const end = start + str.length();
3042
3043 // We need to use a helper stringstream to do this transformation
3044 // because String doesn't support push_back().
3045 ::std::stringstream helper;
3046 for (const char* ch = start; ch != end; ++ch) {
3047 if (*ch == '\0') {
3048 helper << "\\0"; // Replaces NUL with "\\0";
3049 } else {
3050 helper.put(*ch);
3051 }
3052 }
3053
3054 return String(helper.str().c_str());
3055}
3056
3057// Appends the user-supplied message to the Google-Test-generated message.
3058String AppendUserMessage(const String& gtest_msg,

Callers 5

GetStringFunction · 0.85
CmpHelperFloatingPointEQFunction · 0.85
FloatingPointLEFunction · 0.85
WideStringToUtf8Function · 0.85
PrintXmlTestCaseMethod · 0.85

Calls 1

StringFunction · 0.70

Tested by

no test coverage detected