Helper class to keep track of indenting. More...
#include <DumperBase.h>
Public Types | |
using | indenter_t = Indenter< Stream > |
This type. More... | |
Public Member Functions | |
Indenter (Stream out, DumperBase const &dumper) | |
Records the underlying stream and the dumper associated. More... | |
std::string const & | indentString () const |
Returns the default indentation string. More... | |
std::string const & | firstIndentString () const |
Returns the indentation string for the first line. More... | |
template<typename T > | |
indenter_t & | operator<< (T &&v) |
Forwards data to the underlying stream. More... | |
indenter_t & | indent (bool first=false) |
Inserts an indentation and returns the indenter for further output. More... | |
indenter_t & | newline () |
Breaks the current line and returns the indenter for further output. More... | |
indenter_t & | start () |
Private Attributes | |
Stream | out |
DumperBase const & | dumper |
Helper class to keep track of indenting.
Stream | type of output stream the class is using |
This class is single use, tied to a dumper and to a stream instance. It does not attempt to keep track of whether the output line is the first or not, and it does not try to detect end-of-line characters in the passed strings to insert internal indentation.
Each object is tied to a dump::DumperBase
object and it reflects its indentation settings, i.e. if indentation settings of the dump::DumperBase
object are changed, the tied Indenter
object will reflect the new settings.
Example of usage:
Note how the manual indentation is more complicate than the "implicit" one.
Definition at line 162 of file DumperBase.h.
using dump::DumperBase::Indenter< Stream >::indenter_t = Indenter<Stream> |
This type.
Definition at line 167 of file DumperBase.h.
|
inline |
Records the underlying stream and the dumper associated.
Definition at line 170 of file DumperBase.h.
|
inline |
Returns the indentation string for the first line.
Definition at line 177 of file DumperBase.h.
|
inline |
Inserts an indentation and returns the indenter for further output.
Definition at line 186 of file DumperBase.h.
|
inline |
Returns the default indentation string.
Definition at line 174 of file DumperBase.h.
|
inline |
Breaks the current line and returns the indenter for further output.
Definition at line 190 of file DumperBase.h.
|
inline |
Forwards data to the underlying stream.
Definition at line 182 of file DumperBase.h.
|
inline |
Inserts a first-line indentation and returns the indenter for further output.
Definition at line 194 of file DumperBase.h.
|
private |
Definition at line 164 of file DumperBase.h.
|
private |
Definition at line 163 of file DumperBase.h.