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

@ -32,32 +32,13 @@ MapFileDumper::PhysicsCylinder::PhysicsCylinder(const Vec3 middlePoint, const fl
}
MapFileDumper::MapFileDumper(std::ostream& stream)
: m_stream(stream),
: AbstractTextDumper(stream),
m_flags{},
m_indent(0u),
m_entity_index(0u),
m_brush_index(0u)
{
}
void MapFileDumper::Indent() const
{
for (auto i = 0u; i < m_indent; i++)
m_stream << " ";
}
void MapFileDumper::IncIndent()
{
++m_indent;
}
void MapFileDumper::DecIndent()
{
assert(m_indent > 0);
if (m_indent > 0)
m_indent--;
}
void MapFileDumper::Init() const
{
m_stream << "iwmap 4\n";

View File

@ -2,7 +2,9 @@
#include <ostream>
class MapFileDumper
#include "Dumping/AbstractTextDumper.h"
class MapFileDumper : AbstractTextDumper
{
public:
union Vec3
@ -13,6 +15,7 @@ public:
float m_y;
float m_z;
};
float v[3];
Vec3(float x, float y, float z);
@ -39,21 +42,15 @@ public:
};
private:
std::ostream& m_stream;
struct
{
bool m_in_entity : 1;
bool m_in_brush : 1;
} m_flags;
size_t m_indent;
size_t m_entity_index;
size_t m_brush_index;
void Indent() const;
void IncIndent();
void DecIndent();
public:
explicit MapFileDumper(std::ostream& stream);