Dune Core Modules (2.6.0)

Dune::Indent Class Reference

Utility class for handling nested indentation in output. More...

#include <dune/common/indent.hh>

Public Member Functions

 Indent (const std::string &basic_indent_=" ", unsigned level_=0)
 setup without parent More...
 
 Indent (unsigned level_)
 setup without parent and basic_indentation of two spaces
 
 Indent (const Indent *parent_, const std::string &basic_indent_=" ", unsigned level_=1)
 setup with parent More...
 
 Indent (const Indent *parent_, unsigned level_)
 setup with parent
 
Indent operator+ (const std::string &newindent) const
 create new indentation object with this one as parent
 
Indent operator+ (unsigned morelevel) const
 create a copy of this indentation object with raised level
 
Indentoperator++ ()
 raise indentation level
 
Indentoperator-- ()
 lower indentation level
 

Detailed Description

Utility class for handling nested indentation in output.

An indentation object hast a string basic_indent and an indentation level. When it is put into a std::ostream using << it will print its basic_indent as many times as its indentation level. By default the basic_indent will be two spaces and the indentation level will be 0.

An Indent object may also have a reference to a parent Indent object. If it has, that object it put into the stream with the << operator before the indentation of this object is put into the stream. This effectively chains Indent objects together.

You can use the ++ operator to raise and the – operator to lower the indentation by one level.

You can use the + operator with a numeric second argument morelevel to create a copy of the Indent object with the indentation level increased morelevel times. This is mainly useful to pass indent+1 to a function, where indent is an indentation object.

You can use the + operator with a string second argument newindent to create a new Indent object with this object as parent, a basic_indent of newindent, and an indentation level of one. This is mainly useful to pass indent+"> " to a function, where "> " is a possibly different indentation string then the one used by indent indentation object.

Note
The idea is for functions receive indentation objects as call by value parameters. This way, the indentation object of the caller will not be modified by the function and the function can simply return at anytime without having to clean up.

The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)