mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-12-02 22:18:09 +01:00
63 lines
2.1 KiB
C++
63 lines
2.1 KiB
C++
#pragma once
|
|
#include <cstddef>
|
|
#include <ostream>
|
|
#include "InputOutputStream.h"
|
|
using namespace std;
|
|
|
|
|
|
class Tag
|
|
{
|
|
public:
|
|
#ifdef __linux__
|
|
static const byte TAG_End = static_cast<std::byte>(0);
|
|
static const byte TAG_Byte = static_cast<std::byte>(1);
|
|
static const byte TAG_Short = static_cast<std::byte>(2);
|
|
static const byte TAG_Int = static_cast<std::byte>(3);
|
|
static const byte TAG_Long = static_cast<std::byte>(4);
|
|
static const byte TAG_Float = static_cast<std::byte>(5);
|
|
static const byte TAG_Double = static_cast<std::byte>(6);
|
|
static const byte TAG_Byte_Array = static_cast<std::byte>(7);
|
|
static const byte TAG_String = static_cast<std::byte>(8);
|
|
static const byte TAG_List = static_cast<std::byte>(9);
|
|
static const byte TAG_Compound = static_cast<std::byte>(10);
|
|
static const byte TAG_Int_Array = static_cast<std::byte>(11);
|
|
#else
|
|
static const byte TAG_End = 0;
|
|
static const byte TAG_Byte = 1;
|
|
static const byte TAG_Short = 2;
|
|
static const byte TAG_Int = 3;
|
|
static const byte TAG_Long = 4;
|
|
static const byte TAG_Float = 5;
|
|
static const byte TAG_Double = 6;
|
|
static const byte TAG_Byte_Array = 7;
|
|
static const byte TAG_String = 8;
|
|
static const byte TAG_List = 9;
|
|
static const byte TAG_Compound = 10;
|
|
static const byte TAG_Int_Array = 11;
|
|
#endif
|
|
static const int MAX_DEPTH = 512;
|
|
private:
|
|
wstring name;
|
|
|
|
protected:
|
|
Tag(const wstring &name);
|
|
|
|
public:
|
|
virtual void write(DataOutput *dos) = 0;
|
|
virtual void load(DataInput *dis, int tagDepth) = 0;
|
|
virtual wstring toString() = 0;
|
|
virtual byte getId() = 0;
|
|
void print(ostream out);
|
|
void print(char *prefix, wostream& out);
|
|
wstring getName();
|
|
Tag *setName(const wstring& name);
|
|
static Tag *readNamedTag(DataInput *dis);
|
|
static Tag *readNamedTag(DataInput *dis, int tagDepth);
|
|
static void writeNamedTag(Tag *tag, DataOutput *dos);
|
|
static Tag *newTag(byte type, const wstring &name);
|
|
static const wchar_t *getTagName(byte type);
|
|
virtual ~Tag() {}
|
|
virtual bool equals(Tag *obj); // 4J Brought forward from 1.2
|
|
virtual Tag *copy() = 0; // 4J Brought foward from 1.2
|
|
};
|