2015-09-06 20:19:09 +02:00
|
|
|
#include "./bitreader.h"
|
2015-06-08 22:09:09 +02:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace IoUtilities {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \class IoUtilities::BitReader
|
2016-01-18 23:41:30 +01:00
|
|
|
* \brief The BitReader class provides bitwise reading of buffered data.
|
2015-06-08 22:09:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Skips the specified number of bits without reading it.
|
|
|
|
* \param Specifies the number of bits to skip.
|
|
|
|
* \throws Throws ios_base::failure if the end of the buffer is exceeded.
|
|
|
|
* The reader becomes invalid in that case.
|
|
|
|
*/
|
|
|
|
void BitReader::skipBits(std::size_t bitCount)
|
|
|
|
{
|
2015-07-27 23:16:49 +02:00
|
|
|
if(bitCount <= m_bitsAvail) {
|
2015-06-08 22:09:09 +02:00
|
|
|
m_bitsAvail -= bitCount;
|
|
|
|
} else {
|
2015-07-27 23:16:49 +02:00
|
|
|
if((m_buffer += 1 + (bitCount -= m_bitsAvail) / 8) >= m_end) {
|
2015-06-08 22:09:09 +02:00
|
|
|
throw ios_base::failure("end of buffer exceeded");
|
|
|
|
}
|
|
|
|
m_bitsAvail = 8 - (bitCount % 8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace IoUtilities
|
|
|
|
|