8 #ifndef LARDATA_RECOBASE_DUMPERS_NEWLINE_H 9 #define LARDATA_RECOBASE_DUMPERS_NEWLINE_H 1 24 : indent(ind), appendFirst(followLine)
35 indent.erase(std::max(indent.length() - less.length(), size_t(0)));
75 template <
typename Stream>
88 : out(stream), options(
std::move(indentOptions)), nLines(0)
109 unsigned int lines()
const {
return nLines; }
112 std::string
indent()
const {
return options.indent; }
119 if (!append()) forceNewLine();
131 bool append()
const {
return (lines() == 0) && options.appendFirst; }
134 void setIndent(std::string newIndent) { options.indent = newIndent; }
137 void addIndent(std::string moreIndent) { options.indent += moreIndent; }
147 template <
typename Stream>
154 template <
typename Stream>
163 #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)
Stream & operator()()
Calls and returns newLine(). Candy.
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