Defined in header <cparse/Indentation.hh>
class Indentation final;
Indentation is the simplest class in cparse: a uint_fast16_t for the current indent, another for the step size, left() / right() to adjust the indent by a whole number of steps, and an operator<< that streams the current indent as that many space characters.
That is the whole thing. If you already have a plain integer and a stream, you have most of what Indentation offers; the reason it exists is to give code emitters (subclasses of Generator) a common vocabulary so callers write getIndentor().right() and stream << getIndentor() instead of maintaining their own counter and formatting logic.
The class is final.
Member functions
Construction / destruction / assignment
Indent adjustment
| |
| right | increase indent by N × step size (default N = 1) |
| left | decrease indent by N × step size (default N = 1) |
Step-size accessors
Indent accessors
Reset
| |
| reset | set step size and clear indent to zero |
Static constants
| |
| DEFAULT_STEPSIZE | 2U — default step size when the constructor is called without an argument |
Non-member functions
| |
| operator<< | inserts getIndentation() space characters into an ostream |
Notes
Move construction and move assignment are deleted; copy construction and copy assignment are noexcept.
There is no notion of "current column", no wrapping, no tabs, no alignment. Indentation is precisely a leading-whitespace counter. Targets that expect tabs post-process the output or write tabs directly to the stream instead of using this class.
See also