diff --git a/io/bitreader.h b/io/bitreader.h index b11e308..bec1c65 100644 --- a/io/bitreader.h +++ b/io/bitreader.h @@ -17,6 +17,7 @@ public: BitReader(const char *buffer, const char *end); template intType readBits(byte bitCount); + byte readBit(); template intType showBits(byte bitCount); void skipBits(std::size_t bitCount); void align(); @@ -77,6 +78,16 @@ intType BitReader::readBits(byte bitCount) return val; } +/*! + * \brief Reads the one bit from the buffer advancing the current position by one bit. + * \throws Throws ios_base::failure if the end of the buffer is exceeded. + * The reader becomes invalid in that case. + */ +inline byte BitReader::readBit() +{ + return readBits(1) == 1; +} + /*! * \brief Reads the specified number of bits from the buffer without advancing the current position. */