8 #ifndef LARDATA_RECOBASE_DUMPERS_NEWLINE_H 9 #define LARDATA_RECOBASE_DUMPERS_NEWLINE_H 1 25 : indent(ind), appendFirst(followLine)
29 { indent += more; appendFirst =
false;
return *
this; }
32 indent.erase(
std::max(indent.length() - less.length(), size_t(0)));
73 template <
typename Stream>
87 : out(stream), options(
std::move(indentOptions)), nLines(0)
108 unsigned int lines()
const {
return nLines; }
111 std::string
indent()
const {
return options.indent; }
116 Stream&
newLine() {
if (!append()) forceNewLine(); ++nLines;
return out; }
119 Stream& operator() () {
return newLine(); }
125 bool append()
const {
return (lines() == 0) && options.appendFirst; }
129 void setIndent(std::string newIndent) { options.indent = newIndent; }
132 void addIndent(std::string moreIndent) { options.indent += moreIndent; }
144 template <
typename Stream>
146 (Stream& stream, std::string
indent,
bool followLine =
false)
150 template <
typename Stream>
160 #endif // LARDATA_RECOBASE_DUMPERS_NEWLINE_H unsigned int nLines
number of lines in output
unsigned int lines() const
Returns the number of inserted lines.
Starts a new line in a output stream.
void addIndent(std::string moreIndent)
Adds to the end to the indentation string.
IndentOptions_t(std::string ind="", bool followLine=false)
std::string indent() const
Returns the current indentation string.
Reconstruction base classes.
std::string indent
indentation string
IndentOptions_t & appendIndentation(std::string more)
void setIndent(std::string newIndent)
Replaces the indentation string.
NewLine(Stream &stream, std::string indent="", bool followLine=false)
Constructor: associates with the stream.
IndentOptions_t & removeIndentation(std::string less)
Stream & out
reference to the output stream
bool appendFirst
skip indentation on the first line
NewLine(Stream &stream, IndentOptions_t indentOptions)
Constructor: associates with the stream.
Structure collecting indentation options.
void forceNewLine()
Starts a new line (no matter what)
Stream & newLine()
Starts a new line.
bool append() const
Returns whether newLine() will append text on the current line.
NewLine< Stream > makeNewLine(Stream &stream, std::string indent, bool followLine=false)
Convenience function to create a temporary NewLine.
IndentOptions_t options
all indentation options