aboutsummaryrefslogtreecommitdiff
path: root/ByteBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'ByteBuffer.h')
-rw-r--r--ByteBuffer.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/ByteBuffer.h b/ByteBuffer.h
index a572097..b3e06cf 100644
--- a/ByteBuffer.h
+++ b/ByteBuffer.h
@@ -20,12 +20,12 @@ public:
/**
* Wrapping constructor, the size will be equal to the capacity.
*/
- ByteBuffer(const uint8_t *bytes, size_t capacity);
+ ByteBuffer(const std::shared_ptr<uint8_t> bytes, size_t capacity);
/**
* Wrapping constructor.
*/
- ByteBuffer(const uint8_t *bytes, size_t capacity, size_t zero, size_t size);
+ ByteBuffer(const std::shared_ptr<uint8_t> bytes, size_t capacity, size_t zero, size_t size);
inline size_t getSize() const {
// DF << "end=" << (uint64_t)end << ", zero=" << (uint64_t)zero << ", size=" << (end - zero);
@@ -50,17 +50,17 @@ public:
ptr += length;
}
- ByteBuffer &add8(uint8_t value);
+ ByteBuffer &write8(uint8_t value);
- ByteBuffer &add16le(uint16_t value);
+ ByteBuffer &write16le(uint16_t value);
- uint8_t get8(size_t index);
+ uint8_t get8(size_t index) const;
- uint8_t get8();
+ uint8_t read8();
- uint16_t get16le();
+ uint16_t read16le();
- void copy(uint8_t *bytes, size_t length);
+ void copy(uint8_t *bytes, size_t length) const;
/**
* Creates a view from cursor to size.
@@ -73,7 +73,7 @@ public:
std::string toString() const;
private:
- ByteBuffer(const uint8_t *bytes, size_t capacity, const uint8_t *zero, const uint8_t *end);
+ ByteBuffer(const std::shared_ptr<uint8_t> bytes, size_t capacity, const uint8_t *zero, const uint8_t *end);
ByteBuffer view(uint8_t *ptr, const uint8_t *end) const;
@@ -83,7 +83,7 @@ private:
void assertCanAccessIndex(uint8_t *p) const;
- const uint8_t *bytes;
+ const std::shared_ptr<uint8_t> bytes;
const size_t capacity;
const uint8_t *zero;
const uint8_t *end;