Stream buffer that wraps lines on white-space characters at the specified line length, and with support for indentation.
More...
#include <ookii/line_wrapping_stream.h>
|
using | base_type = std::basic_streambuf< CharType, Traits > |
| The concrete type that this class derives from.
|
|
using | char_type = typename base_type::char_type |
| Character type used by the base type.
|
|
using | int_type = typename base_type::int_type |
| Integer type used by the base type.
|
|
using | traits_type = typename base_type::traits_type |
| Traits type used by the base type.
|
|
|
virtual void | imbue (const std::locale &loc) override |
| Change the locale of the stream buffer. More...
|
|
virtual int_type | overflow (int_type ch=traits_type::eof()) override |
| Ensure there is space to write at least one character to the buffer. More...
|
|
virtual int | sync () override |
| Flushes the buffer to the underlying stream buffer. More...
|
|
template<typename CharType, typename Traits = std::char_traits<CharType>>
class ookii::basic_line_wrapping_streambuf< CharType, Traits >
Stream buffer that wraps lines on white-space characters at the specified line length, and with support for indentation.
This stream buffer writes its output to another stream buffer, which could belong to any stream (like a file stream, or string stream).
- Warning
- This class assumes that the target stream buffer is at the start of a line when writing starts, and that no other users are writing to the same stream buffer. Otherwise, output will not be correctly wrapped or indented.
Several typedefs for common character types are provided:
- Template Parameters
-
CharType | The type of characters used by the target stream buffer. |
Traits | The character traits used by the target stream buffer. |
◆ basic_line_wrapping_streambuf() [1/2]
template<typename CharType , typename Traits = std::char_traits<CharType>>
◆ basic_line_wrapping_streambuf() [2/2]
template<typename CharType , typename Traits = std::char_traits<CharType>>
Initializes a new instance of the basic_line_wrapping_streambuf class with the specified underlying stream buffer and maximum line length.
- Parameters
-
streambuf | The 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. |
◆ imbue()
template<typename CharType , typename Traits = std::char_traits<CharType>>
|
inlineoverrideprotectedvirtual |
Change the locale of the stream buffer.
- Parameters
-
◆ indent()
template<typename CharType , typename Traits = std::char_traits<CharType>>
Sets the number of spaces that each line is indented with.
- Parameters
-
indent | The new indentation size. |
◆ init()
template<typename CharType , typename Traits = std::char_traits<CharType>>
Initializes this basic_line_wrapping_streambuf instance with the specified underlying stream buffer and maximum line length.
- Parameters
-
streambuf | The 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. |
◆ overflow()
template<typename CharType , typename Traits = std::char_traits<CharType>>
|
inlineoverrideprotectedvirtual |
Ensure there is space to write at least one character to the buffer.
Called when there is no more space in the buffer, or when sync() is called.
- Attention
- This function flushes the buffer to the underlying stream buffer, wrapping lines and adding indent as necessary. The passed character, if not eof, will be added to the buffer afterwards.
- Parameters
-
ch | The character to put in the buffer. |
- Returns
- A value not equal to
Traits::eof()
on success, and Traits::eof()
on failure.
◆ reset_indent()
template<typename CharType , typename Traits = std::char_traits<CharType>>
Disables indentation for the next line.
- Warning
- If the last character written to the buffer was not a new line, one is inserted.
- Returns
false
if a new line character was needed but could not be written; otherwise, true
.
◆ swap()
template<typename CharType , typename Traits = std::char_traits<CharType>>
◆ sync()
template<typename CharType , typename Traits = std::char_traits<CharType>>
|
inlineoverrideprotectedvirtual |
Flushes the buffer to the underlying stream buffer.
- Returns
- The result of calling
pubsync()
on the underlying stream buffer.
The documentation for this class was generated from the following file: