aboutsummaryrefslogtreecommitdiff
path: root/ByteBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'ByteBuffer.h')
-rw-r--r--ByteBuffer.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/ByteBuffer.h b/ByteBuffer.h
index ee54a0a..479a227 100644
--- a/ByteBuffer.h
+++ b/ByteBuffer.h
@@ -17,12 +17,12 @@ public:
class ByteBuffer {
public:
- ByteBuffer(uint8_t *bytes, size_t capacity);
+ ByteBuffer(const uint8_t *bytes, size_t capacity);
- ByteBuffer(uint8_t *bytes, size_t capacity, size_t zero, size_t size);
+ ByteBuffer(const 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;
+ DF << "end=" << (uint64_t)end << ", zero=" << (uint64_t)zero << ", size=" << (end - zero);
return end - zero;
}
@@ -35,8 +35,8 @@ public:
}
inline void setCursor(size_t newCursor) {
- assertCanAccessRelative(newCursor);
- ptr = ptr + newCursor;
+// assertCanAccessRelative(newCursor);
+ ptr = (uint8_t *) &zero[newCursor];
}
inline void skip(size_t length) {
@@ -67,7 +67,9 @@ public:
std::string toString() const;
private:
- ByteBuffer(const uint8_t *bytes, size_t capacity, uint8_t *zero, uint8_t *end);
+ ByteBuffer(const uint8_t *bytes, size_t capacity, const uint8_t *zero, const uint8_t *end);
+
+ ByteBuffer view(uint8_t *ptr, const uint8_t *end) const;
void checkAndUpdateEnd(size_t count);