diff --git a/src/lib/nbt.cpp b/src/lib/nbt.cpp index 9e66fee..22124f6 100644 --- a/src/lib/nbt.cpp +++ b/src/lib/nbt.cpp @@ -840,8 +840,99 @@ namespace NBT { } ErrorOrVoid Int8Array::removeElement(uint64_t position) { - //TODO: implement + #pragma message("TODO: implement") //this->data.erase(position); + return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED); + } + + String::String() { + this->type = TagType::STRING; + } + + String::String(tiny_utf8::string name, tiny_utf8::string value) { + this->type = TagType::STRING; + this->name = name; + this->value = value; + } + + ErrorOrVoid String::toRawData(std::vector* rawData) { + rawData->push_back(this->type); + + if (Helper::writeString(rawData, this->name).isError) { + return ErrorOrVoid(true, ErrorCodes::OVERRUN); + } + + return Helper::writeString(rawData, this->value); + } + + tiny_utf8::string String::getValue() { + return this->value; + } + + void String::setValue(tiny_utf8::string value) { + this->value = value; + } + + List::List() { + this->type = TagType::LIST; + this->containedType = TagType::INVALID; + } + + List::List(tiny_utf8::string name, uint8_t type) { + this->type = TagType::LIST; + this->name = name; + this->containedType = type; + } + + // WARNING: The pointers inside the vector are automatically cleaned + // up upon deletion of the List object. Do not retain a copy of them + // elsewhere and especially do not delete them externally. + List::List(tiny_utf8::string name, std::vector data) { + this->type = TagType::LIST; + this->name = name; + this->tags = data; + + if (data.size() == 0) { + this->containedType = TagType::END; + } else { + this->containedType = data.at(0)->getTagType(); + } + } + + List::~List() { + for (uint64_t i=0; itags.size(); i++) { + delete this->tags.at(i); + } + } + + ErrorOrVoid toRawData(std::vector* rawData) { + #pragma message("TODO: Implement.") + return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED); + } + + ErrorOr getElementPointer(uint64_t position) { + #pragma message("TODO: Implement.") + return ErrorOr(true, ErrorCodes::UNIMPLEMENTED); + } + + ErrorOrVoid setElementPointerAt(uint64_t position, Generic*) { + #pragma message("TODO: Implement.") + return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED); + } + + ErrorOrVoid appendPointer(Generic*) { + #pragma message("TODO: Implement.") + return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED); + } + + ErrorOrVoid deleteElement(uint64_t position) { + #pragma message("TODO: Implement.") + return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED); + } + + uint64_t length() { + #pragma message("TODO: Implement.") + return 0; } } diff --git a/src/lib/nbt.hpp b/src/lib/nbt.hpp index f9a3887..0635d44 100644 --- a/src/lib/nbt.hpp +++ b/src/lib/nbt.hpp @@ -220,7 +220,7 @@ namespace NBT { class List: public Generic { private: std::vector tags; - uint8_t type; + uint8_t containedType; public: List(); List(tiny_utf8::string name, uint8_t type);