mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 17:44:52 +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 {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue