lib/nbt: Implement more member functions for tag types
parent
89baeebc65
commit
fc2caf3bc0
|
@ -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<uint8_t>* 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<Generic*> 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; i<this->tags.size(); i++) {
|
||||
delete this->tags.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
ErrorOrVoid toRawData(std::vector<uint8_t>* rawData) {
|
||||
#pragma message("TODO: Implement.")
|
||||
return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED);
|
||||
}
|
||||
|
||||
ErrorOr<Generic*> getElementPointer(uint64_t position) {
|
||||
#pragma message("TODO: Implement.")
|
||||
return ErrorOr<Generic*>(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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace NBT {
|
|||
class List: public Generic {
|
||||
private:
|
||||
std::vector<Generic*> tags;
|
||||
uint8_t type;
|
||||
uint8_t containedType;
|
||||
public:
|
||||
List();
|
||||
List(tiny_utf8::string name, uint8_t type);
|
||||
|
|
Loading…
Reference in New Issue