LibAC-cpp/src/nbt/Accountant.cpp
2024-07-30 22:59:35 -07:00

41 lines
No EOL
970 B
C++

#include "Accountant.h"
#include "Tag.h"
#include "CompoundTag.h"
#include <iostream>
using namespace nbt;
using namespace libac;
namespace nbt
{
int NBTAccountant::_prettyIndex = 0;
void NBTAccountant::printRead(const Tag &tag)
{
tag.prettyPrint(_prettyIndex, false);
}
void NBTAccountant::visitTag()
{
_prettyIndex++;
}
void NBTAccountant::leaveTag(const Tag &tag)
{
// Assuming Tag has virtual methods to check its type or a `getType` method
if (dynamic_cast<const CompoundTag *>(&tag) || dynamic_cast<const ListTag *>(&tag))
{
if (const CompoundTag *ct = dynamic_cast<const CompoundTag *>(&tag))
{
ct->endPrettyPrint(_prettyIndex);
}
else if (const ListTag *lt = dynamic_cast<const ListTag *>(&tag))
{
lt->endPrettyPrint(_prettyIndex);
}
}
_prettyIndex--;
}
}