diff options
Diffstat (limited to 'ByteBuffer.h')
-rw-r--r-- | ByteBuffer.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ByteBuffer.h b/ByteBuffer.h new file mode 100644 index 0000000..a7e9f9f --- /dev/null +++ b/ByteBuffer.h @@ -0,0 +1,27 @@ +#ifndef BYTE_STREAM_WRAPPER_H +#define BYTE_STREAM_WRAPPER_H + +#include <cstdint> +#include <cstdlib> + +class ByteBuffer { +public: + ByteBuffer(uint8_t *bytes, ssize_t size, ssize_t zero = 0); + + ByteBuffer &add8(uint8_t value); + + ByteBuffer &add16le(uint16_t value); + + uint8_t get8(ssize_t index); + +private: + void canAccessNextBytes(ssize_t count); + void canAccessIndex(ssize_t count); + + uint8_t *bytes; + ssize_t zero; + ssize_t size; + ssize_t ptr; +}; + +#endif |