lib/nbt: Yesterday’s progress of implementing more of the functions in the header
parent
4c4366f7e6
commit
2d2b67373c
|
@ -873,7 +873,8 @@ namespace NBT {
|
||||||
}
|
}
|
||||||
Helper::writeInt32(rawData, this->tags.size());
|
Helper::writeInt32(rawData, this->tags.size());
|
||||||
|
|
||||||
for (int32_t i=0; i<this->tags.size(); i++) {
|
// unsigned integer bc of compiler warning (shouldn't matter)
|
||||||
|
for (uint32_t i=0; i<this->tags.size(); i++) {
|
||||||
ErrorOrVoid result = this->tags.at(i)->serializeWithoutHeader(rawData);
|
ErrorOrVoid result = this->tags.at(i)->serializeWithoutHeader(rawData);
|
||||||
if (result.isError) {
|
if (result.isError) {
|
||||||
return result;
|
return result;
|
||||||
|
@ -884,28 +885,47 @@ namespace NBT {
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<Generic*> List::getElementPointer(uint64_t position) {
|
ErrorOr<Generic*> List::getElementPointer(uint64_t position) {
|
||||||
#pragma message("TODO: Implement.")
|
if (this->tags.size() <= position) {
|
||||||
return ErrorOr<Generic*>(true, ErrorCodes::UNIMPLEMENTED);
|
return ErrorOr<Generic*>(true, ErrorCodes::OUT_OF_RANGE);
|
||||||
|
}
|
||||||
|
return ErrorOr<Generic*>(this->tags.at(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOrVoid List::setElementPointerAt(uint64_t position, Generic*) {
|
ErrorOrVoid List::setElementPointerAt(uint64_t position, Generic* pointer) {
|
||||||
#pragma message("TODO: Implement.")
|
if (this->tags.size() <= position) {
|
||||||
return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED);
|
return ErrorOrVoid(true, ErrorCodes::OUT_OF_RANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOrVoid List::appendPointer(Generic*) {
|
if (pointer->getTagType() != this->containedType) {
|
||||||
#pragma message("TODO: Implement.")
|
return ErrorOrVoid(true, ErrorCodes::INVALID_TYPE);
|
||||||
return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED);
|
}
|
||||||
|
|
||||||
|
delete this->tags[position];
|
||||||
|
this->tags[position] = pointer;
|
||||||
|
return ErrorOrVoid();
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOrVoid List::appendPointer(Generic* pointer) {
|
||||||
|
if (pointer->getTagType() != this->containedType) {
|
||||||
|
return ErrorOrVoid(true, ErrorCodes::INVALID_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->tags.push_back(pointer);
|
||||||
|
|
||||||
|
return ErrorOrVoid();
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOrVoid List::deleteElement(uint64_t position) {
|
ErrorOrVoid List::deleteElement(uint64_t position) {
|
||||||
#pragma message("TODO: Implement.")
|
#pragma message("TODO: Implement.")
|
||||||
|
|
||||||
|
// Step 1) delete pointer
|
||||||
|
// Step 2) remove element from vector
|
||||||
|
|
||||||
return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED);
|
return ErrorOrVoid(true, ErrorCodes::UNIMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t List::length() {
|
uint64_t List::length() {
|
||||||
#pragma message("TODO: Implement.")
|
return this->tags.size();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,8 +235,8 @@ namespace NBT {
|
||||||
ErrorOrVoid serializeWithoutHeader(std::vector<uint8_t>* rawData) override;
|
ErrorOrVoid serializeWithoutHeader(std::vector<uint8_t>* rawData) override;
|
||||||
|
|
||||||
ErrorOr<Generic*> getElementPointer(uint64_t position);
|
ErrorOr<Generic*> getElementPointer(uint64_t position);
|
||||||
ErrorOrVoid setElementPointerAt(uint64_t position, Generic*);
|
ErrorOrVoid setElementPointerAt(uint64_t position, Generic* pointer);
|
||||||
ErrorOrVoid appendPointer(Generic*);
|
ErrorOrVoid appendPointer(Generic* pointer);
|
||||||
ErrorOrVoid deleteElement(uint64_t position);
|
ErrorOrVoid deleteElement(uint64_t position);
|
||||||
uint64_t length();
|
uint64_t length();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue