31namespace triqs::utility {
56 report_stream(std::ostream *out_,
int verbosity_ = 1) : out(out_), verbosity(verbosity_) {}
64 report_stream(std::ostream &out_,
int verbosity_ = 1) : out(&out_), verbosity(verbosity_) {}
82 if (verbosity > 0) (*out) << x;
93 if (verbosity > 0) manip(*out);
106 class indented_streambuf :
public std::streambuf {
107 std::streambuf *dest;
109 bool at_line_start =
true;
112 indented_streambuf(std::streambuf *dest,
int indent) : dest(dest), head(indent,
' ') {}
115 int_type overflow(int_type c)
override {
116 if (c == EOF)
return !EOF;
117 if (at_line_start && c !=
'\n') dest->sputn(head.c_str(),
long(head.size()));
118 at_line_start = (c ==
'\n');
119 return dest->sputc(c);
121 int sync()
override {
return dest->pubsync(); }
123 indented_streambuf buffer;
132 indented_ostream(std::ostream &os,
int indent) : std::ostream(&buffer), buffer(os.rdbuf(), indent) {}
report_stream(std::ostream *out_, int verbosity_=1)
Construct a report stream from a pointer to an ostream and a verbosity level.
indented_ostream(std::ostream &os, int indent)
Construct an indented stream on top of an existing ostream with a given indentation width.
report_stream(std::ostream *out_, int verbosity_=1)
Construct a report stream from a pointer to an ostream and a verbosity level.
report_stream(std::ostream &out_, int verbosity_=1)
Construct a report stream from a reference to an ostream and a verbosity level.
report_stream & operator<<(std::ostream &(*manip)(std::ostream &))
Streaming operator that accepts manipulators like std::endl.
report_stream & operator<<(T const &x)
Streaming operator to write the given argument if the current verbosity is greater than zero.
report_stream operator()(int n) const
Return a child report stream whose verbosity has been reduced by .