util: Add a postfix increment operator to BitStream::stream_pos

This commit is contained in:
Joshua Scott 2018-10-20 20:08:17 +01:00
parent 48dde6abe8
commit c9f99e1f1a
2 changed files with 17 additions and 2 deletions

View File

@ -7,11 +7,10 @@
namespace ki namespace ki
{ {
/** /**
* * A readable/writeable stream of bits.
*/ */
class BitStream class BitStream
{ {
public: public:
/** /**
* Represents a position in a BitStream's buffer. * Represents a position in a BitStream's buffer.
@ -34,6 +33,8 @@ namespace ki
stream_pos &operator -=(int bits); stream_pos &operator -=(int bits);
stream_pos &operator ++(); stream_pos &operator ++();
stream_pos &operator --(); stream_pos &operator --();
stream_pos operator ++(int increment);
stream_pos operator --(int increment);
private: private:
intmax_t m_byte; intmax_t m_byte;

View File

@ -118,6 +118,20 @@ namespace ki
return *this; 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) BitStream::BitStream(const size_t buffer_size)
{ {
m_buffer = new uint8_t[buffer_size] { 0 }; m_buffer = new uint8_t[buffer_size] { 0 };