senf::format::IndentHelper Class Reference
[Formating]

Helper class to easily achieve indent levels. More...

#include <senf/Utils/Format.hh>

List of all members.


Detailed Description

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:

    void f1() {
        senf::format::IndentHelper indent;
        std::cout << indent << "f1\n";
    }
    void f2() {
        senf::format::IndentHelper indent;
        std::cout << indent << "f2 begin\n";
        f1();
        std::cout << indent << "f2 end\n";
    }
    f2()
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.

Definition at line 237 of file Format.hh.


Public Member Functions

  IndentHelper ()
  Construct new IndentHelper instance.
  ~IndentHelper ()
  Destruct IndentHelper instance.
void  increase ()
  Increase the indent level.
unsigned int  level () const
  return the current indent level

Related Functions

(Note that these are not member functions.)

std::ostream &  operator<< (std::ostream &os, IndentHelper const &indent)
  Output indent to given ostream.

Constructor & Destructor Documentation

senf::format::IndentHelper::
IndentHelper ()

Construct new IndentHelper instance.

The static indent level is increased by one.

Definition at line 159 of file Format.cci.

senf::format::IndentHelper::
~IndentHelper ()

Destruct IndentHelper instance.

The static indent level will be decreased to the level before the instance.

Definition at line 165 of file Format.cci.


Member Function Documentation

void senf::format::IndentHelper::
increase ()

Increase the indent level.

The indent level of the instance is increases by one.

Definition at line 170 of file Format.cci.

unsigned int senf::format::IndentHelper::
level ()

return the current indent level

Definition at line 176 of file Format.cci.


Friends And Related Function Documentation

std::ostream &
operator<< ( std::ostream &  os,
IndentHelper const &  indent )

Output indent to given ostream.


The documentation for this class was generated from the following files: