Helper class to easily achieve indent levels. More...
#include <senf/Utils/Format.hh>
Public Member Functions | |
IndentHelper () | |
Construct new IndentHelper instance. More... | |
~IndentHelper () | |
Destruct IndentHelper instance. More... | |
void | increase () |
Increase the indent level. More... | |
unsigned int | level () const |
return the current indent level More... | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &os, IndentHelper const &indent) |
Output indent to given ostream. More... | |
Helper class to easily achieve indent levels.
This class helps to achieve indent levels across function calls. Every instance increases the static indent level. On destruction the level is decreased to the level before the instance. The following example illustrates the use of this class:
Output:
f2 begin f1 f2 end
Here f1()
and f2()
don't need to know to current indent level, they just increase the level by instantiating IndentHelper.
senf::format::IndentHelper::IndentHelper | ( | ) |
Construct new IndentHelper instance.
The static indent level is increased by one.
senf::format::IndentHelper::~IndentHelper | ( | ) |
Destruct IndentHelper instance.
The static indent level will be decreased to the level before the instance.
void senf::format::IndentHelper::increase | ( | ) |
Increase the indent level.
The indent level of the instance is increases by one.
unsigned int senf::format::IndentHelper::level | ( | ) | const |
return the current indent level
|
related |
Output indent to given ostream.