diff --git a/src/lib/nbt.cpp b/src/lib/nbt.cpp index 5c09a60..5264ecf 100644 --- a/src/lib/nbt.cpp +++ b/src/lib/nbt.cpp @@ -867,6 +867,10 @@ namespace NBT { } } + uint8_t List::getContainedType() { + return this->containedType; + } + ErrorOrVoid List::serializeWithoutHeader(std::vector* rawData) { if (this->containedType == TagType::INVALID) { return ErrorOrVoid(true, ErrorCodes::INVALID_TYPE); diff --git a/src/lib/nbt.hpp b/src/lib/nbt.hpp index 91cda21..5e933dc 100644 --- a/src/lib/nbt.hpp +++ b/src/lib/nbt.hpp @@ -234,6 +234,7 @@ namespace NBT { ErrorOrVoid serializeWithoutHeader(std::vector* rawData) override; + uint8_t getContainedType(); ErrorOr getElementPointer(uint64_t position); ErrorOrVoid setElementPointerAt(uint64_t position, Generic* pointer); ErrorOrVoid appendPointer(Generic* pointer); diff --git a/src/test/nbt_tags.cpp b/src/test/nbt_tags.cpp index a184602..db2f005 100644 --- a/src/test/nbt_tags.cpp +++ b/src/test/nbt_tags.cpp @@ -784,6 +784,7 @@ int main(){ ASSERT(list_0.serialize(&vector).errorCode == ErrorCodes::INVALID_TYPE); vector.clear(); NBT::Tag::List list_1 = NBT::Tag::List("list_1", NBT::TagType::INT8); + ASSERT(list_1.getContainedType() == NBT::TagType::INT8); ASSERT(!list_1.appendPointer(pointer_1_0).isError); ASSERT(!list_1.appendPointer(pointer_1_1).isError); ASSERT(!list_1.appendPointer(pointer_1_2).isError); @@ -794,6 +795,7 @@ int main(){ //TODO: Check that constructing with a vector of mixed tags // results in a clearly defined failure mode (issue #60) NBT::Tag::List list_2 = NBT::Tag::List("list_2", listDataVector); + ASSERT(list_2.getContainedType() == NBT::TagType::INT8); ASSERT(list_1.length() == 4 && list_2.length() == 4); ASSERT(!list_2.deleteElement(1).isError); ASSERT(list_2.deleteElement(3).isError && list_2.deleteElement(3).errorCode == ErrorCodes::OUT_OF_RANGE);