Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
818 B

#include "./bitreader.h"
using namespace std;
namespace CppUtilities {
/*!
* \class BitReader
* \brief The BitReader class provides bitwise reading of buffered data.
*/
/*!
* \brief Skips the specified number of bits without reading it.
* \param bitCount Specifies the number of bits to skip.
* \throws Throws std::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)
{
if (bitCount <= m_bitsAvail) {
m_bitsAvail -= static_cast<std::uint8_t>(bitCount);
} else {
if ((m_buffer += 1 + (bitCount -= m_bitsAvail) / 8) >= m_end) {
throw ios_base::failure("end of buffer exceeded");
}
m_bitsAvail = 8 - (bitCount % 8);
}
}
} // namespace CppUtilities