nightly commit + working on NBT
parent
983d7de820
commit
c3aab51030
|
@ -7,6 +7,8 @@
|
|||
#ifndef BLT_TESTS_NBT_H
|
||||
#define BLT_TESTS_NBT_H
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "blt/std/format.h"
|
||||
#include "blt/std/filesystem.h"
|
||||
|
||||
|
@ -31,6 +33,29 @@ namespace blt::nbt {
|
|||
LONG_ARRAY = 12
|
||||
};
|
||||
|
||||
class tag {
|
||||
public:
|
||||
virtual void writePayload(std::fstream& out) = 0;
|
||||
virtual void readPayload(std::fstream& in) = 0;
|
||||
};
|
||||
|
||||
class named_tag : public tag {
|
||||
private:
|
||||
std::string name;
|
||||
public:
|
||||
explicit named_tag(std::string name): name(std::move(name)) {}
|
||||
named_tag() = default;
|
||||
void writeName(std::fstream& out);
|
||||
void readName(std::fstream& in);
|
||||
};
|
||||
|
||||
class tag_end : public tag {
|
||||
public:
|
||||
void writePayload(std::fstream& out) final;
|
||||
// nothing to read
|
||||
void readPayload(std::fstream& in) final {}
|
||||
};
|
||||
|
||||
class NBTDecoder {
|
||||
private:
|
||||
blt::fs::block_reader* m_reader;
|
||||
|
|
|
@ -27,4 +27,16 @@ namespace blt::nbt {
|
|||
delete[] str.characters;
|
||||
return strOut;
|
||||
}
|
||||
|
||||
void named_tag::writeName(std::fstream& out) {
|
||||
writeUTF8String(out, name);
|
||||
}
|
||||
|
||||
void named_tag::readName(std::fstream& in) {
|
||||
name = readUTF8String(in);
|
||||
}
|
||||
|
||||
void tag_end::writePayload(std::fstream& out) {
|
||||
out.put('\0');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue