MCPcopy Create free account
hub / github.com/apache/thrift / MinimalStream

Class MinimalStream

test/cpp/src/PrivateOptionalTemplateStreamOpTest.cpp:57–76  ·  view source on GitHub ↗

Custom minimal stream - verifies that template_streamop works with non-std streams

Source from the content-addressed store, hash-verified

55
56// Custom minimal stream - verifies that template_streamop works with non-std streams
57class MinimalStream {
58private:
59 std::string buf_;
60public:
61 MinimalStream& operator<<(const std::string& s) { buf_ += s; return *this; }
62 MinimalStream& operator<<(const char* s) { buf_ += s; return *this; }
63 MinimalStream& operator<<(char c) { buf_ += c; return *this; }
64 MinimalStream& operator<<(int32_t i) { buf_ += std::to_string(i); return *this; }
65 MinimalStream& operator<<(int64_t i) { buf_ += std::to_string(i); return *this; }
66 MinimalStream& operator<<(uint32_t i) { buf_ += std::to_string(i); return *this; }
67 MinimalStream& operator<<(uint64_t i) { buf_ += std::to_string(i); return *this; }
68 MinimalStream& operator<<(double d) {
69 char tmp[64];
70 std::snprintf(tmp, sizeof(tmp), "%g", d);
71 buf_ += tmp;
72 return *this;
73 }
74 MinimalStream& operator<<(bool b) { buf_ += (b ? "true" : "false"); return *this; }
75 const std::string& str() const { return buf_; }
76};
77
78int main() {
79 std::cout << "Testing private_optional + template_streamop combined..." << std::endl;

Callers

nothing calls this directly

Calls 1

to_stringFunction · 0.50

Tested by

no test coverage detected