55 if (verbosity_ > 0) *out_ << value;
65 if (verbosity_ > 0) manip(*out_);
90 class indented_streambuf :
public std::streambuf {
93 bool at_line_start =
true;
96 indented_streambuf(std::streambuf *dest,
int indent) : dest(dest), head(indent,
' ') {}
99 int_type overflow(int_type c)
override {
100 if (c == EOF)
return !EOF;
101 if (at_line_start && c !=
'\n') dest->sputn(head.c_str(),
long(head.size()));
102 at_line_start = (c ==
'\n');
103 return dest->sputc(c);
105 int sync()
override {
return dest->pubsync(); }
107 indented_streambuf buffer;
116 indented_ostream(std::ostream &os,
int indent) : std::ostream(&buffer), buffer(os.rdbuf(), indent) {}
A custom output stream that automatically indents each new line by a specified number of spaces.
indented_ostream(std::ostream &os, int indent)
Constructor.
FIXME : MERGE : replace triqs::report_steam, -> merge + alias.
ostream_with_verbosity & operator<<(T const &value)
Stream insertion operator for generic types.
ostream_with_verbosity & operator<<(std::ostream &(*manip)(std::ostream &))
Stream insertion for manipulators like std::endl.
ostream_with_verbosity(std::ostream &out, int verbosity=1)
Construct a stream_with_verbosity.
ostream_with_verbosity operator()(int n) const
Create a derived stream with adjusted verbosity.