summaryrefslogtreecommitdiffstats
path: root/src/NBT/ByteArrayTag.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/NBT/ByteArrayTag.hpp')
-rw-r--r--src/NBT/ByteArrayTag.hpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/NBT/ByteArrayTag.hpp b/src/NBT/ByteArrayTag.hpp
index ee0d7d1..2081759 100644
--- a/src/NBT/ByteArrayTag.hpp
+++ b/src/NBT/ByteArrayTag.hpp
@@ -38,22 +38,26 @@ class ByteArrayTag : public Tag {
private:
friend class Tag;
- std::vector<uint8_t> value;
+ uint32_t len;
+ const uint8_t *value;
ByteArrayTag(Buffer *buffer) {
- uint32_t len = uint32_t(buffer->get()) << 24;
- len |= uint32_t(buffer->get()) << 16;
- len |= uint32_t(buffer->get()) << 8;
- len |= uint32_t(buffer->get());
-
- value.resize(len);
- buffer->getData(value.data(), len);
+ len = buffer->get32();
+ value = buffer->get(len);
}
public:
virtual Type getType() const {
return Type::ByteArray;
}
+
+ uint32_t getLength() const {
+ return len;
+ }
+
+ const uint8_t & operator[](size_t i) const {
+ return value[i];
+ }
};
}