From c9f99e1f1a6e30b0e401d6c99b67457fb32c767c Mon Sep 17 00:00:00 2001 From: Joshua Scott Date: Sat, 20 Oct 2018 20:08:17 +0100 Subject: [PATCH] util: Add a postfix increment operator to BitStream::stream_pos --- include/ki/util/BitStream.h | 5 +++-- src/util/BitStream.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/ki/util/BitStream.h b/include/ki/util/BitStream.h index 709a30c..e5388f1 100644 --- a/include/ki/util/BitStream.h +++ b/include/ki/util/BitStream.h @@ -7,11 +7,10 @@ namespace ki { /** - * + * A readable/writeable stream of bits. */ class BitStream { - public: /** * Represents a position in a BitStream's buffer. @@ -34,6 +33,8 @@ namespace ki stream_pos &operator -=(int bits); stream_pos &operator ++(); stream_pos &operator --(); + stream_pos operator ++(int increment); + stream_pos operator --(int increment); private: intmax_t m_byte; diff --git a/src/util/BitStream.cpp b/src/util/BitStream.cpp index d368498..5f4284e 100644 --- a/src/util/BitStream.cpp +++ b/src/util/BitStream.cpp @@ -118,6 +118,20 @@ namespace ki return *this; } + BitStream::stream_pos BitStream::stream_pos::operator++(int increment) + { + auto copy(*this); + ++(*this); + return copy; + } + + BitStream::stream_pos BitStream::stream_pos::operator--(int increment) + { + auto copy(*this); + --(*this); + return copy; + } + BitStream::BitStream(const size_t buffer_size) { m_buffer = new uint8_t[buffer_size] { 0 };