CPP-TOOLBOX
Loading...
Searching...
No Matches
text_utils::MultilineStringAccumulator Class Reference

#include <text_utils.hpp>

Public Member Functions

 MultilineStringAccumulator ()
 
void indent ()
 Increase indentation level.
 
void unindent ()
 Decrease indentation level (no-op if already at 0).
 
template<typename... Args>
void add (Args &&...args)
 Add a line with current indentation applied.
 
void add_multiline (const std::string &multiline_str)
 Add multiple lines with indentation applied.
 
void insert_line (size_t index, const std::string &line)
 Insert a line at the given index.
 
void insert_lines (size_t index, const MultilineStringAccumulator &other)
 Insert all lines from another accumulator.
 
void insert_multiline (size_t index, const std::string &multiline_str)
 Insert multiple lines from a string.
 
void remove_line (size_t index)
 Remove a line at the given index.
 
std::string str () const
 Get the accumulated text as a single string with newlines.
 
void clear ()
 Clear all stored lines.
 
size_t line_count () const
 Get the number of stored lines.
 

Constructor & Destructor Documentation

◆ MultilineStringAccumulator()

text_utils::MultilineStringAccumulator::MultilineStringAccumulator ( )
inline

Member Function Documentation

◆ add()

template<typename... Args>
void text_utils::MultilineStringAccumulator::add ( Args &&... args)
inline

Add a line with current indentation applied.

Template Parameters
ArgsAny streamable types.
Parameters
argsValues to append to the line.

◆ add_multiline()

void text_utils::MultilineStringAccumulator::add_multiline ( const std::string & multiline_str)
inline

Add multiple lines with indentation applied.

Parameters
multiline_strInput string with newlines.

◆ clear()

void text_utils::MultilineStringAccumulator::clear ( )
inline

Clear all stored lines.

◆ indent()

void text_utils::MultilineStringAccumulator::indent ( )
inline

Increase indentation level.

◆ insert_line()

void text_utils::MultilineStringAccumulator::insert_line ( size_t index,
const std::string & line )
inline

Insert a line at the given index.

Parameters
indexPosition in the list of lines.
lineText to insert.
Exceptions
std::out_of_rangeif index is invalid.

◆ insert_lines()

void text_utils::MultilineStringAccumulator::insert_lines ( size_t index,
const MultilineStringAccumulator & other )
inline

Insert all lines from another accumulator.

Parameters
indexPosition in the list of lines.
otherAnother accumulator containing lines.
Exceptions
std::out_of_rangeif index is invalid.

◆ insert_multiline()

void text_utils::MultilineStringAccumulator::insert_multiline ( size_t index,
const std::string & multiline_str )
inline

Insert multiple lines from a string.

Parameters
indexPosition in the list of lines.
multiline_strString containing newlines.
Exceptions
std::out_of_rangeif index is invalid.

◆ line_count()

size_t text_utils::MultilineStringAccumulator::line_count ( ) const
inline

Get the number of stored lines.

◆ remove_line()

void text_utils::MultilineStringAccumulator::remove_line ( size_t index)
inline

Remove a line at the given index.

Parameters
indexPosition in the list of lines.
Exceptions
std::out_of_rangeif index is invalid.

◆ str()

std::string text_utils::MultilineStringAccumulator::str ( ) const
inline

Get the accumulated text as a single string with newlines.

◆ unindent()

void text_utils::MultilineStringAccumulator::unindent ( )
inline

Decrease indentation level (no-op if already at 0).


The documentation for this class was generated from the following file: