added method for restting the bit reader

This commit is contained in:
Martchus 2015-07-07 00:50:03 +02:00
parent 1e755b4489
commit f396b8afa1
1 changed files with 22 additions and 0 deletions

View File

@ -17,6 +17,8 @@ public:
template<typename intType> intType readBits(byte bitCount);
void skipBits(std::size_t bitCount);
std::size_t bitsAvailable();
void reset(const char *buffer, std::size_t bufferSize);
void reset(const char *buffer, const char *end);
private:
const byte *m_buffer;
@ -77,6 +79,26 @@ inline std::size_t BitReader::bitsAvailable()
return ((m_end - m_buffer) * 8) + m_bitsAvail;
}
/*!
* \brief Resets the reader.
*/
inline void BitReader::reset(const char *buffer, size_t bufferSize)
{
m_buffer = reinterpret_cast<const byte *>(buffer);
m_end = reinterpret_cast<const byte *>(buffer + bufferSize);
m_bitsAvail = 8;
}
/*!
* \brief Resets the reader.
*/
inline void BitReader::reset(const char *buffer, const char *end)
{
m_buffer = reinterpret_cast<const byte *>(buffer);
m_end = reinterpret_cast<const byte *>(end);
m_bitsAvail = 8;
}
} // namespace IoUtilities
#endif // IOUTILITIES_BITREADER_H