11 #ifndef LARDATAALG_DUMPERS_DUMPERBASE_H
12 #define LARDATAALG_DUMPERS_DUMPERBASE_H
45 void set(std::string
const& newIndent, std::string
const& newFirstIndent)
47 void set(std::string&& newIndent, std::string&& newFirstIndent)
49 indent = std::move(newIndent);
52 void set(std::string
const& newIndent) {
set(newIndent, newIndent); }
69 DumperBase(std::string
const& indent, std::string
const& firstIndent)
99 std::string
const& firstIndent()
const
103 void setIndent(std::string
const& indent, std::string
const& firstIndent)
107 void setIndent(std::string
const& indent) { setIndent(indent, indent); }
111 template <
typename Stream>
113 { out << (
first? firstIndent(): indent());
return out; }
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>
167 using indenter_t = Indenter<Stream>;
171 : out(
std::forward<
Stream>(out)), dumper(dumper) {}
174 std::string
const& indentString()
const {
return dumper.indent(); }
177 std::string
const& firstIndentString()
const
178 {
return dumper.firstIndent(); }
181 template <
typename T>
183 { out << std::forward<T>(v);
return *
this; }
186 indenter_t& indent(
bool first =
false)
187 { dumper.indented(out,
first);
return *
this; }
190 indenter_t& newline() { out <<
'\n';
return indent(); }
194 indenter_t& start() {
return indent(
true); }
201 template <
typename Stream>
203 {
return Indenter<Stream>(std::forward<Stream>(out), *
this); }
231 template <
typename Dumper>
233 (Dumper&& dumper, std::string
const& indent, std::string
const& firstIndent)
234 { dumper.setIndent(indent, firstIndent);
return dumper; }
237 template <
typename Dumper>
239 (Dumper&& dumper, std::string
const& indent)
240 {
return withIndentation(std::forward<Dumper>(dumper), indent, indent); }
248 #endif // LARDATAALG_DUMPERS_DUMPERBASE_H
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
void set(std::string const &newIndent)
IndentSettings & restoreIndentSettings()
Restores and returns the last saved settings.
void set(std::string const &newIndent, std::string const &newFirstIndent)
Classes gathering simple statistics.
auto withIndentation(Dumper &&dumper, std::string const &indent, std::string const &firstIndent)
Changes the indentation settings of a dumper class and returns it back.
void set(std::string &&newIndent, std::string &&newFirstIndent)
IndentSettings & indentSettings()
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.
IndentSettings & saveIndentSettings()
Stacks a copy of the current settings, and returns the "new" ones.
DumperBase()
Default constructor: no indentation.
std::ostream & operator<<(std::ostream &, Binner< T > const &)
std::string indent
Default indentation string.
IndentSettings const & indentSettings() const
Base class for data dumpers.
std::vector< IndentSettings > fIndentSettings
All indentation settings.