summaryrefslogtreecommitdiffstats
path: root/src/NBT/ListTag.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/NBT/ListTag.hpp')
-rw-r--r--src/NBT/ListTag.hpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/NBT/ListTag.hpp b/src/NBT/ListTag.hpp
index d86abdb..7276923 100644
--- a/src/NBT/ListTag.hpp
+++ b/src/NBT/ListTag.hpp
@@ -34,34 +34,29 @@
namespace MinedMap {
namespace NBT {
+class ListTag : public Tag, public std::vector<std::shared_ptr<const Tag>> {
+private:
+ const TagType *subtype;
-class ListTagBase : public Tag {
public:
- virtual Type getType() const {
- return Type::List;
- }
+ static const MakeType<ListTag> Type;
- virtual Type getSubtype() const = 0;
-};
+ ListTag(Buffer *buffer) {
+ subtype = &getTypeById(buffer->get8());
-template<typename T>
-class ListTag : public ListTagBase, public std::vector<std::shared_ptr<const T>> {
-private:
- Type type;
-
-public:
- ListTag(Type type0, Buffer *buffer) : type(type0) {
uint32_t len = buffer->get32();
- this->resize(len);
-
for (uint32_t i = 0; i < len; i++)
- (*this)[i] = std::static_pointer_cast<const T>(Tag::readTag(type, buffer));
+ push_back(subtype->read(buffer));
+ }
+
+ virtual const TagType & getType() const {
+ return Type;
}
- virtual Type getSubtype() const {
- return type;
+ virtual const TagType & getSubtype() const {
+ return *subtype;
}
virtual void print(std::ostream& os, const std::string &indent) const {