aboutsummaryrefslogtreecommitdiff
path: root/include/ble/ByteBuffer.h
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-12-20 08:35:51 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2018-12-20 08:35:51 +0100
commitffa313e80a27005405334db6491075442f6e1abd (patch)
tree23a48c91cfc0810afe88cc6104d0667516fbd4a9 /include/ble/ByteBuffer.h
parentaf416f81b14a3bee682e300b165a6efdb9739d54 (diff)
downloadble-toys-ffa313e80a27005405334db6491075442f6e1abd.tar.gz
ble-toys-ffa313e80a27005405334db6491075442f6e1abd.tar.bz2
ble-toys-ffa313e80a27005405334db6491075442f6e1abd.tar.xz
ble-toys-ffa313e80a27005405334db6491075442f6e1abd.zip
o Using more natural byte ordering in the code. No external effect. o Using global ==, != and < operators instead of in-class operators for better compatibility with STL. ByteBuffer: o Renaming setPosition() to setCursor().
Diffstat (limited to 'include/ble/ByteBuffer.h')
-rw-r--r--include/ble/ByteBuffer.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/include/ble/ByteBuffer.h b/include/ble/ByteBuffer.h
index 6b09049..1ba088f 100644
--- a/include/ble/ByteBuffer.h
+++ b/include/ble/ByteBuffer.h
@@ -42,7 +42,7 @@ public:
ByteBuffer(uint8_t *bytes, size_t size) noexcept : zero(bytes), end_(&bytes[size]), cursor(zero) {};
ByteBuffer(uint8_t *bytes, size_t size, size_t position) : zero(bytes), end_(&bytes[size]), cursor(zero) {
- setPosition(position);
+ setCursor(position);
};
template<size_t N>
@@ -64,8 +64,10 @@ public:
return end_ - cursor;
}
- inline ByteBuffer &setPosition(size_t newCursor) {
- cursor = &zero[newCursor];
+ inline ByteBuffer &setCursor(size_t newCursor) {
+ auto tmp = &zero[newCursor];
+ assertCanAccessPtr(tmp);
+ cursor = tmp;
return *this;
}