MCPcopy Create free account
hub / github.com/daniele77/cli / OutStream

Class OutStream

include/cli/cli.h:76–109  ·  view source on GitHub ↗

this class provides a global output stream

Source from the content-addressed store, hash-verified

74
75 // this class provides a global output stream
76 class OutStream : public std::basic_ostream<char>, public std::streambuf
77 {
78 public:
79 OutStream() : std::basic_ostream<char>(this)
80 {
81 }
82
83 // std::streambuf overrides
84 std::streamsize xsputn(const char* s, std::streamsize n) override
85 {
86 for (auto os: ostreams)
87 os->rdbuf()->sputn(s, n);
88 return n;
89 }
90 int overflow(int c) override
91 {
92 for (auto os: ostreams)
93 *os << static_cast<char>(c);
94 return c;
95 }
96
97 void Register(std::ostream& o)
98 {
99 ostreams.push_back(&o);
100 }
101 void UnRegister(std::ostream& o)
102 {
103 ostreams.erase(std::remove(ostreams.begin(), ostreams.end(), &o), ostreams.end());
104 }
105
106 private:
107
108 std::vector<std::ostream*> ostreams;
109 };
110
111 // forward declarations
112 class Menu;

Callers 1

CliTelnetSessionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected