Collects text output into a String, splitting on newlines. More...
#include <streamstring.h>
Public Types | |
| using | OnNewLineFunc = std::function< bool(String &)> |
| Callback type invoked for each completed line. | |
Public Member Functions | |
| StreamString () | |
| Constructs a StreamString with no callback. | |
| StreamString (OnNewLineFunc func) | |
| Constructs a StreamString with a newline callback. | |
| StreamString (const StreamString &)=delete | |
| Deleted copy constructor. | |
| StreamString & | operator= (const StreamString &)=delete |
| Deleted copy assignment operator. | |
| StreamString (StreamString &&)=delete | |
| Deleted move constructor. | |
| StreamString & | operator= (StreamString &&)=delete |
| Deleted move assignment operator. | |
| TextStream & | stream () |
| Returns the TextStream associated with this buffer. | |
| void | setOnNewLine (OnNewLineFunc func) |
| Sets or replaces the newline callback. | |
| const String & | line () const |
| Returns the current (possibly incomplete) line buffer. | |
| void | clear () |
| Clears the accumulated line buffer. | |
Collects text output into a String, splitting on newlines.
StreamString accumulates characters written to it. When a newline or flush is encountered, it invokes the onNewLine callback with the accumulated line. The callback returns true to clear the line buffer, or false to keep accumulating.
Example usage (routing stream output to the logger):
|
inline |
Constructs a StreamString with a newline callback.
| func | Callback invoked when a complete line is available. |
Returns the current (possibly incomplete) line buffer.
|
inline |
Sets or replaces the newline callback.
| func | New callback to invoke on each complete line. |
|
inline |
Returns the TextStream associated with this buffer.