diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-17 16:20:30 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2015-02-17 16:20:30 +0100 |
commit | 0d0749ff0f842f10fea6929dc466e4e1be458234 (patch) | |
tree | 6d1198f23da97c65c5b1936484c9dae6126ed654 /ByteBuffer.h | |
parent | 076fbdda4477b87deb322e43925e010d24d9fa5d (diff) | |
download | ble-toys-0d0749ff0f842f10fea6929dc466e4e1be458234.tar.gz ble-toys-0d0749ff0f842f10fea6929dc466e4e1be458234.tar.bz2 ble-toys-0d0749ff0f842f10fea6929dc466e4e1be458234.tar.xz ble-toys-0d0749ff0f842f10fea6929dc466e4e1be458234.zip |
o More tests, more passing tests.
Diffstat (limited to 'ByteBuffer.h')
-rw-r--r-- | ByteBuffer.h | 14 |
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); |