NBT: make Tag constructors public, remove friend declarations

This commit is contained in:
Matthias Schiffer 2018-07-21 16:17:40 +02:00
parent 4288935d70
commit 59fe1ba025
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
13 changed files with 13 additions and 43 deletions

View file

@ -36,17 +36,14 @@ namespace NBT {
class ByteArrayTag : public Tag {
private:
friend class Tag;
uint32_t len;
const uint8_t *value;
public:
ByteArrayTag(Buffer *buffer) {
len = buffer->get32();
value = buffer->get(len);
}
public:
virtual Type getType() const {
return Type::ByteArray;
}

View file

@ -34,15 +34,13 @@ namespace NBT {
class ByteTag : public Tag {
private:
friend class Tag;
uint8_t value;
public:
ByteTag(Buffer *buffer) {
value = buffer->get8();
}
public:
virtual Type getType() const {
return Type::Byte;
}

View file

@ -36,9 +36,7 @@ namespace MinedMap {
namespace NBT {
class CompoundTag : public Tag, public std::unordered_map<std::string, std::shared_ptr<const Tag>> {
private:
friend class Tag;
public:
CompoundTag(Buffer *buffer) {
while (true) {
std::pair<std::string, std::shared_ptr<const Tag>> v = Tag::readNamedTag(buffer);
@ -49,7 +47,6 @@ private:
}
}
public:
virtual Type getType() const {
return Type::Compound;
}

View file

@ -34,15 +34,13 @@ namespace NBT {
class DoubleTag : public Tag {
private:
friend class Tag;
const uint8_t *ptr;
public:
DoubleTag(Buffer *buffer) {
ptr = buffer->get(8);
}
public:
virtual Type getType() const {
return Type::Double;
}

View file

@ -33,12 +33,9 @@ namespace MinedMap {
namespace NBT {
class EndTag : public Tag {
private:
friend class Tag;
public:
EndTag() {}
public:
virtual Type getType() const {
return Type::End;
}

View file

@ -33,16 +33,13 @@ namespace MinedMap {
namespace NBT {
class FloatTag : public Tag {
private:
friend class Tag;
const uint8_t *ptr;
public:
FloatTag(Buffer *buffer) {
ptr = buffer->get(4);
}
public:
virtual Type getType() const {
return Type::Float;
}

View file

@ -36,17 +36,15 @@ namespace NBT {
class IntArrayTag : public Tag {
private:
friend class Tag;
uint32_t len;
const uint8_t *ptr;
public:
IntArrayTag(Buffer *buffer) {
len = buffer->get32();
ptr = buffer->get(4*len);
}
public:
virtual Type getType() const {
return Type::IntArray;
}

View file

@ -34,15 +34,13 @@ namespace NBT {
class IntTag : public Tag {
private:
friend class Tag;
const uint8_t *ptr;
public:
IntTag(Buffer *buffer) {
ptr = buffer->get(4);
}
public:
virtual Type getType() const {
return Type::Int;
}

View file

@ -48,10 +48,9 @@ public:
template<typename T>
class ListTag : public ListTagBase, public std::vector<std::shared_ptr<const T>> {
private:
friend class Tag;
Type type;
public:
ListTag(Type type0, Buffer *buffer) : type(type0) {
uint32_t len = buffer->get32();
@ -61,7 +60,6 @@ private:
(*this)[i] = std::static_pointer_cast<const T>(Tag::readTag(type, buffer));
}
public:
virtual Type getSubtype() const {
return type;
}

View file

@ -36,17 +36,15 @@ namespace NBT {
class LongArrayTag : public Tag {
private:
friend class Tag;
uint32_t len;
const uint8_t *ptr;
public:
LongArrayTag(Buffer *buffer) {
len = buffer->get32();
ptr = buffer->get(8*len);
}
public:
virtual Type getType() const {
return Type::LongArray;
}

View file

@ -34,15 +34,13 @@ namespace NBT {
class LongTag : public Tag {
private:
friend class Tag;
const uint8_t *ptr;
public:
LongTag(Buffer *buffer) {
ptr = buffer->get(8);
}
public:
virtual Type getType() const {
return Type::Long;
}

View file

@ -34,15 +34,13 @@ namespace NBT {
class ShortTag : public Tag {
private:
friend class Tag;
const uint8_t *ptr;
public:
ShortTag(Buffer *buffer) {
ptr = buffer->get(2);
}
public:
virtual Type getType() const {
return Type::Short;
}

View file

@ -34,17 +34,15 @@ namespace NBT {
class StringTag : public Tag {
private:
friend class Tag;
uint16_t len;
const uint8_t *ptr;
public:
StringTag(Buffer *buffer) {
len = buffer->get16();
ptr = buffer->get(len);
}
public:
virtual Type getType() const {
return Type::String;
}