Add AbstractTextDumper to implement stream holding and indendation

This commit is contained in:
Jan
2022-01-15 17:44:56 +01:00
parent c9a0392fc1
commit b48d55671e
8 changed files with 60 additions and 38 deletions

View File

@ -0,0 +1,28 @@
#include "AbstractTextDumper.h"
#include <cassert>
AbstractTextDumper::AbstractTextDumper(std::ostream& stream)
: m_stream(stream),
m_indent(0u)
{
}
void AbstractTextDumper::Indent() const
{
for (auto i = 0u; i < m_indent; i++)
m_stream << " ";
}
void AbstractTextDumper::IncIndent()
{
++m_indent;
}
void AbstractTextDumper::DecIndent()
{
assert(m_indent > 0);
if (m_indent > 0)
m_indent--;
}