Vcsn  2.3
Be Rational
indent.cc
Go to the documentation of this file.
1 
6 #include <cassert>
7 #include <iomanip>
8 #include <ostream>
9 
10 #include <vcsn/misc/indent.hh>
11 #include <vcsn/misc/xalloc.hh>
12 
13 namespace vcsn
14 {
15 
16  namespace detail
17  {
19  }
20 
21  std::ostream& incindent(std::ostream& o)
22  {
23  detail::indentation(o) += 2;
24  return o;
25  }
26 
27  std::ostream& decindent(std::ostream& o)
28  {
29  assert(detail::indentation(o));
30  detail::indentation(o) -= 2;
31  return o;
32  }
33 
34  std::ostream& resetindent(std::ostream& o)
35  {
36  detail::indentation(o) = 0;
37  return o;
38  }
39 
40  std::ostream& indent(std::ostream& o)
41  {
42  // Be sure to be able to restore the stream flags.
43  char fill = o.fill(' ');
44  return o << std::setw(detail::indentation(o))
45  << ""
46  << std::setfill(fill);
47  }
48 
49  std::ostream& iendl(std::ostream& o)
50  {
51  return o << '\n' << indent;
52  }
53 
54  std::ostream& incendl(std::ostream& o)
55  {
56  return o << incindent << iendl;
57  }
58 
59  std::ostream& decendl(std::ostream& o)
60  {
61  return o << decindent << iendl;
62  }
63 }
std::ostream & incindent(std::ostream &o)
Increment the indentation.
Definition: indent.cc:21
std::ostream & incendl(std::ostream &o)
Increment the indentation, print an end of line, and set the indentation.
Definition: indent.cc:54
std::ostream & indent(std::ostream &o)
Set the indentation.
Definition: indent.cc:40
std::ostream & iendl(std::ostream &o)
Print an end of line, then set the indentation.
Definition: indent.cc:49
xalloc< long int > indentation
Definition: indent.cc:18
std::ostream & decendl(std::ostream &o)
Decrement the indentation, print an end of line, and set the indentation.
Definition: indent.cc:59
std::ostream & decindent(std::ostream &o)
Decrement the indentation.
Definition: indent.cc:27
Definition: a-star.hh:8
Indentation relative functions.
Declaration of vcsn::xalloc.
Allocate slots in std::ostreams.
Definition: xalloc.hh:38
std::ostream & resetindent(std::ostream &o)
Reset the indentation.
Definition: indent.cc:34