added method for reading a single bit

This commit is contained in:
Martchus 2015-08-08 01:18:24 +02:00
parent 1677f8fc1b
commit 72b7afb17e
1 changed files with 11 additions and 0 deletions

View File

@ -17,6 +17,7 @@ public:
BitReader(const char *buffer, const char *end);
template<typename intType> intType readBits(byte bitCount);
byte readBit();
template<typename intType> 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<byte>(1) == 1;
}
/*!
* \brief Reads the specified number of bits from the buffer without advancing the current position.
*/