Ookii.CommandLine for C++
2.0.0
|
Output stream that wraps lines on white-space characters at the specified line length, and with support for indentation. More...
#include <ookii/line_wrapping_stream.h>
Public Types | |
using | base_type = std::basic_ostream< CharType, Traits > |
The concrete type that this class derives from. | |
using | streambuf_type = std::basic_streambuf< CharType, Traits > |
The concrete base stream buffer type used by this stream. | |
Public Member Functions | |
basic_line_wrapping_ostream () | |
Initializes a new instance of the basic_line_wrapping_ostream class. More... | |
basic_line_wrapping_ostream (base_type &base_stream, size_t max_line_length, bool count_formatting=false) | |
Initializes a new instance of the basic_line_wrapping_ostream class with the specified underlying stream and maximum line length. More... | |
basic_line_wrapping_ostream (basic_line_wrapping_ostream &&other) noexcept | |
Move constructor. More... | |
void | flush (bool flush_last_line) |
Flushes the buffer to the underlying stream buffer, optionally including the the final, partial line. More... | |
void | init (base_type &base_stream, size_t max_line_length, bool count_formatting=false) |
Initializes a new instance of the basic_line_wrapping_ostream class with the specified underlying stream and maximum line length. More... | |
basic_line_wrapping_ostream & | operator= (basic_line_wrapping_ostream &&other) noexcept |
Move assignment operator. More... | |
void | swap (basic_line_wrapping_ostream &other) noexcept |
Swaps this basic_line_wrapping_ostream instance with another. More... | |
Static Public Member Functions | |
static basic_line_wrapping_ostream | for_cerr (short default_width=80) |
Creates a basic_line_wrapping_ostream that writes to the standard error stream, using the console width as the line width. More... | |
static basic_line_wrapping_ostream | for_cout (short default_width=80) |
Creates a basic_line_wrapping_ostream that writes to the standard output stream, using the console width as the line width. More... | |
Output stream that wraps lines on white-space characters at the specified line length, and with support for indentation.
This stream writes its output to the stream buffer of another stream, which could be any stream (like a file stream, or string stream).
flush_last_line
parameter set to true
to make sure all content is flushed (this may insert an additional new line character).Several typedefs for common character types are provided:
Type | Definition |
---|---|
ookii::line_wrapping_ostream | ookii::basic_line_wrapping_ostream<char> |
ookii::wline_wrapping_ostream | ookii::basic_line_wrapping_ostream<wchar_t> |
CharType | The type of characters used by the target stream. |
Traits | The character traits used by the target stream. |
|
inline |
Initializes a new instance of the basic_line_wrapping_ostream class.
You must call the init() method before the stream is usable.
|
inline |
Initializes a new instance of the basic_line_wrapping_ostream class with the specified underlying stream and maximum line length.
base_stream | The stream whose stream buffer to write output to. |
max_line_length | The maximum line length, or a value of 0 or larger than 65536 to specify no limit. Use the use_console_width constant to use the console width as the maximum. |
count_formatting | Include virtual terminal sequences when calculating the length of a line. |
|
inlinenoexcept |
Move constructor.
other | The basic_line_wrapping_ostream to move from. |
|
inline |
Flushes the buffer to the underlying stream buffer, optionally including the the final, partial line.
If the buffer contains a line that's shorter than the maximum and was not terminated by a line break, the normal basic_ostream::flush()
function will not flush that final line, because doing so would make it impossible to find the correct place to wrap the line later if that place was already flushed.
This function offers the ability to flush the buffer including the last line. If there is a non-empty, non-terminated line in the buffer, that line will be flushed, followed by a line break.
flush_last_line | true to flush the final non-terminated line; false to leave that line in the buffer. |
pubsync()
on the underlying stream buffer.
|
inlinestatic |
Creates a basic_line_wrapping_ostream that writes to the standard error stream, using the console width as the line width.
default_width | The maximum line length to use if the console width cannot be determined. |
|
inlinestatic |
Creates a basic_line_wrapping_ostream that writes to the standard output stream, using the console width as the line width.
default_width | The maximum line length to use if the console width cannot be determined. |
|
inline |
Initializes a new instance of the basic_line_wrapping_ostream class with the specified underlying stream and maximum line length.
base_stream | The stream whose stream buffer to write output to. |
max_line_length | The maximum line length, or a value of 0 or larger than 65536 to specify no limit. Use the use_console_width constant to use the console width as the maximum. |
count_formatting | Include virtual terminal sequences when calculating the length of a line. |
|
inlinenoexcept |
Move assignment operator.
other | The basic_line_wrapping_ostream to move from. |
|
inlinenoexcept |
Swaps this basic_line_wrapping_ostream instance with another.
other | The instance to swap with. |