11 #ifndef LARDATAALG_DUMPERS_DUMPERBASE_H 12 #define LARDATAALG_DUMPERS_DUMPERBASE_H 46 { indent = newIndent; firstIndent = newFirstIndent; }
52 void set(
std::string const& newIndent) {
set(newIndent, newIndent); }
70 : fIndentSettings{ {
indent, firstIndent } }
111 template <
typename Stream>
112 Stream&
indented(Stream&& out,
bool first =
false)
const 117 template <
typename Stream>
119 {
return indented(std::forward<Stream>(out),
true); }
123 template <
typename Stream>
125 {
return indented(std::forward<Stream>(out)); }
161 template <
typename Stream>
171 : out(
std::forward<Stream>(out)), dumper(dumper) {}
181 template <
typename T>
183 { out << std::forward<T>(v);
return *
this; }
187 { dumper.
indented(out, first);
return *
this; }
201 template <
typename Stream>
209 {
return fIndentSettings.back(); }
215 fIndentSettings.push_back(
std::move(oldSettings));
222 if (fIndentSettings.size() > 1U) fIndentSettings.pop_back();
223 assert(!fIndentSettings.empty());
231 template <
typename Dumper>
234 { dumper.setIndent(indent, firstIndent);
return dumper; }
237 template <
typename Dumper>
240 {
return withIndentation(std::forward<Dumper>(dumper), indent, indent); }
248 #endif // LARDATAALG_DUMPERS_DUMPERBASE_H std::string const & indentString() const
Returns the default indentation string.
DumperBase(std::string const &indent, std::string const &firstIndent)
Constructor: sets indentation.
void setIndent(std::string const &indent, std::string const &firstIndent)
Sets indentation strings to the specified values.
Stream & newline(Stream &&out) const
Stream & firstIndented(Stream &&out) const
Helper class to keep track of indenting.
IndentSettings & restoreIndentSettings()
Restores and returns the last saved settings.
DumperBase(std::string const &indent)
Constructor: sets indentation.
void setIndent(std::string const &indent)
Sets both indentation strings to the same specified value.
indenter_t & indent(bool first=false)
Inserts an indentation and returns the indenter for further output.
Classes gathering simple statistics.
indenter_t & newline()
Breaks the current line and returns the indenter for further output.
std::string const & firstIndent() const
Returns the indentation string currently configured for the first line.
auto withIndentation(Dumper &&dumper, std::string const &indent, std::string const &firstIndent)
Changes the indentation settings of a dumper class and returns it back.
DumperBase const & dumper
IndentSettings & indentSettings()
std::string const & indent() const
Returns the indentation string currently configured for all lines.
std::string const & firstIndentString() const
Returns the indentation string for the first line.
decltype(auto) indenter(Stream &&out) const
Returns an Indenter object tied to this dumper and out stream.
std::string firstIndent
Indentation string for the first line.
std::ostream & operator<<(std::ostream &os, Analyzer::Table< T > const &t)
Stream & indented(Stream &&out, bool first=false) const
Writes the indentation into a stream, and returns it for further output.
Collection of utilities for dumping data on screen.
Indenter(Stream out, DumperBase const &dumper)
Records the underlying stream and the dumper associated.
IndentSettings & saveIndentSettings()
Stacks a copy of the current settings, and returns the "new" ones.
DumperBase()
Default constructor: no indentation.
std::string indent
Default indentation string.
IndentSettings const & indentSettings() const
Base class for data dumpers.
std::vector< IndentSettings > fIndentSettings
All indentation settings.