From 0d0749ff0f842f10fea6929dc466e4e1be458234 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 17 Feb 2015 16:20:30 +0100 Subject: o More tests, more passing tests. --- ByteBuffer.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'ByteBuffer.h') 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); -- cgit v1.2.3