mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-06 09:54:53 +01:00
NBT: make Tag constructors public, remove friend declarations
This commit is contained in:
parent
4288935d70
commit
59fe1ba025
13 changed files with 13 additions and 43 deletions
|
@ -36,17 +36,14 @@ namespace NBT {
|
||||||
|
|
||||||
class ByteArrayTag : public Tag {
|
class ByteArrayTag : public Tag {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
const uint8_t *value;
|
const uint8_t *value;
|
||||||
|
|
||||||
|
public:
|
||||||
ByteArrayTag(Buffer *buffer) {
|
ByteArrayTag(Buffer *buffer) {
|
||||||
len = buffer->get32();
|
len = buffer->get32();
|
||||||
value = buffer->get(len);
|
value = buffer->get(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::ByteArray;
|
return Type::ByteArray;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,13 @@ namespace NBT {
|
||||||
|
|
||||||
class ByteTag : public Tag {
|
class ByteTag : public Tag {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
|
|
||||||
|
public:
|
||||||
ByteTag(Buffer *buffer) {
|
ByteTag(Buffer *buffer) {
|
||||||
value = buffer->get8();
|
value = buffer->get8();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::Byte;
|
return Type::Byte;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,7 @@ namespace MinedMap {
|
||||||
namespace NBT {
|
namespace NBT {
|
||||||
|
|
||||||
class CompoundTag : public Tag, public std::unordered_map<std::string, std::shared_ptr<const Tag>> {
|
class CompoundTag : public Tag, public std::unordered_map<std::string, std::shared_ptr<const Tag>> {
|
||||||
private:
|
public:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
CompoundTag(Buffer *buffer) {
|
CompoundTag(Buffer *buffer) {
|
||||||
while (true) {
|
while (true) {
|
||||||
std::pair<std::string, std::shared_ptr<const Tag>> v = Tag::readNamedTag(buffer);
|
std::pair<std::string, std::shared_ptr<const Tag>> v = Tag::readNamedTag(buffer);
|
||||||
|
@ -49,7 +47,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::Compound;
|
return Type::Compound;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,13 @@ namespace NBT {
|
||||||
|
|
||||||
class DoubleTag : public Tag {
|
class DoubleTag : public Tag {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
const uint8_t *ptr;
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
DoubleTag(Buffer *buffer) {
|
DoubleTag(Buffer *buffer) {
|
||||||
ptr = buffer->get(8);
|
ptr = buffer->get(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::Double;
|
return Type::Double;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,9 @@ namespace MinedMap {
|
||||||
namespace NBT {
|
namespace NBT {
|
||||||
|
|
||||||
class EndTag : public Tag {
|
class EndTag : public Tag {
|
||||||
private:
|
public:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
EndTag() {}
|
EndTag() {}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::End;
|
return Type::End;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,16 +33,13 @@ namespace MinedMap {
|
||||||
namespace NBT {
|
namespace NBT {
|
||||||
|
|
||||||
class FloatTag : public Tag {
|
class FloatTag : public Tag {
|
||||||
private:
|
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
const uint8_t *ptr;
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
FloatTag(Buffer *buffer) {
|
FloatTag(Buffer *buffer) {
|
||||||
ptr = buffer->get(4);
|
ptr = buffer->get(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::Float;
|
return Type::Float;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,17 +36,15 @@ namespace NBT {
|
||||||
|
|
||||||
class IntArrayTag : public Tag {
|
class IntArrayTag : public Tag {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
const uint8_t *ptr;
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
IntArrayTag(Buffer *buffer) {
|
IntArrayTag(Buffer *buffer) {
|
||||||
len = buffer->get32();
|
len = buffer->get32();
|
||||||
ptr = buffer->get(4*len);
|
ptr = buffer->get(4*len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::IntArray;
|
return Type::IntArray;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,13 @@ namespace NBT {
|
||||||
|
|
||||||
class IntTag : public Tag {
|
class IntTag : public Tag {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
const uint8_t *ptr;
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
IntTag(Buffer *buffer) {
|
IntTag(Buffer *buffer) {
|
||||||
ptr = buffer->get(4);
|
ptr = buffer->get(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::Int;
|
return Type::Int;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,9 @@ public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ListTag : public ListTagBase, public std::vector<std::shared_ptr<const T>> {
|
class ListTag : public ListTagBase, public std::vector<std::shared_ptr<const T>> {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
Type type;
|
Type type;
|
||||||
|
|
||||||
|
public:
|
||||||
ListTag(Type type0, Buffer *buffer) : type(type0) {
|
ListTag(Type type0, Buffer *buffer) : type(type0) {
|
||||||
uint32_t len = buffer->get32();
|
uint32_t len = buffer->get32();
|
||||||
|
|
||||||
|
@ -61,7 +60,6 @@ private:
|
||||||
(*this)[i] = std::static_pointer_cast<const T>(Tag::readTag(type, buffer));
|
(*this)[i] = std::static_pointer_cast<const T>(Tag::readTag(type, buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getSubtype() const {
|
virtual Type getSubtype() const {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,17 +36,15 @@ namespace NBT {
|
||||||
|
|
||||||
class LongArrayTag : public Tag {
|
class LongArrayTag : public Tag {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
const uint8_t *ptr;
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
LongArrayTag(Buffer *buffer) {
|
LongArrayTag(Buffer *buffer) {
|
||||||
len = buffer->get32();
|
len = buffer->get32();
|
||||||
ptr = buffer->get(8*len);
|
ptr = buffer->get(8*len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::LongArray;
|
return Type::LongArray;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,13 @@ namespace NBT {
|
||||||
|
|
||||||
class LongTag : public Tag {
|
class LongTag : public Tag {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
const uint8_t *ptr;
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
LongTag(Buffer *buffer) {
|
LongTag(Buffer *buffer) {
|
||||||
ptr = buffer->get(8);
|
ptr = buffer->get(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::Long;
|
return Type::Long;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,13 @@ namespace NBT {
|
||||||
|
|
||||||
class ShortTag : public Tag {
|
class ShortTag : public Tag {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
const uint8_t *ptr;
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
ShortTag(Buffer *buffer) {
|
ShortTag(Buffer *buffer) {
|
||||||
ptr = buffer->get(2);
|
ptr = buffer->get(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::Short;
|
return Type::Short;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,17 +34,15 @@ namespace NBT {
|
||||||
|
|
||||||
class StringTag : public Tag {
|
class StringTag : public Tag {
|
||||||
private:
|
private:
|
||||||
friend class Tag;
|
|
||||||
|
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
const uint8_t *ptr;
|
const uint8_t *ptr;
|
||||||
|
|
||||||
|
public:
|
||||||
StringTag(Buffer *buffer) {
|
StringTag(Buffer *buffer) {
|
||||||
len = buffer->get16();
|
len = buffer->get16();
|
||||||
ptr = buffer->get(len);
|
ptr = buffer->get(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
virtual Type getType() const {
|
virtual Type getType() const {
|
||||||
return Type::String;
|
return Type::String;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue