11 #ifndef LARDATAALG_DUMPERS_DUMPERBASE_H 12 #define LARDATAALG_DUMPERS_DUMPERBASE_H 43 void set(std::string
const& newIndent, std::string
const& newFirstIndent)
46 firstIndent = newFirstIndent;
48 void set(std::string&& newIndent, std::string&& newFirstIndent)
50 indent = std::move(newIndent);
51 firstIndent = std::move(newFirstIndent);
53 void set(std::string
const& newIndent) {
set(newIndent, newIndent); }
70 : fIndentSettings{{
indent, firstIndent}}
110 template <
typename Stream>
111 Stream&
indented(Stream&& out,
bool first =
false)
const 119 template <
typename Stream>
122 return indented(std::forward<Stream>(out),
true);
127 template <
typename Stream>
130 return indented(std::forward<Stream>(out));
166 template <
typename Stream>
176 : out(
std::forward<Stream>(out)), dumper(dumper)
186 template <
typename T>
189 out << std::forward<T>(v);
214 template <
typename Stream>
228 fIndentSettings.push_back(std::move(oldSettings));
235 if (fIndentSettings.size() > 1U) fIndentSettings.pop_back();
236 assert(!fIndentSettings.empty());
243 template <
typename Dumper>
246 dumper.setIndent(indent, firstIndent);
251 template <
typename Dumper>
261 #endif // LARDATAALG_DUMPERS_DUMPERBASE_H std::string const & indentString() const
Returns the default indentation string.
indenter_t & operator<<(T &&v)
Forwards data to the underlying stream.
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.
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.