Add base for StructuredDataDefDumper

This commit is contained in:
Jan
2022-01-15 18:19:24 +01:00
parent b48d55671e
commit 5c2f7de87d
5 changed files with 109 additions and 1 deletions

View File

@ -0,0 +1,43 @@
#include "StructuredDataDefDumper.h"
#include <cassert>
StructuredDataDefDumper::StructuredDataDefDumper(std::ostream& stream)
: AbstractTextDumper(stream),
m_flags{}
{
}
void StructuredDataDefDumper::BeginVersion(const int version)
{
assert(!m_flags.m_in_version);
if (m_flags.m_in_version)
return;
if (m_flags.m_empty_line_before_version)
m_stream << "\n";
else
m_flags.m_empty_line_before_version = true;
Indent();
m_stream << "version " << version << "\n";
Indent();
m_stream << "{\n";
IncIndent();
m_flags.m_in_version = true;
}
void StructuredDataDefDumper::EndVersion()
{
assert(m_flags.m_in_version);
if (!m_flags.m_in_version)
return;
DecIndent();
Indent();
m_stream << "}\n";
m_flags.m_in_version = false;
}

View File

@ -0,0 +1,18 @@
#pragma once
#include "Dumping/AbstractTextDumper.h"
class StructuredDataDefDumper : AbstractTextDumper
{
struct
{
bool m_in_version : 1;
bool m_empty_line_before_version : 1;
} m_flags;
public:
explicit StructuredDataDefDumper(std::ostream& stream);
void BeginVersion(int version);
void EndVersion();
};