/*! \param nbBits number of bits to use at once */ void EncodedData::initialize(unsigned short int nbBits) { _swap = nbBits; _andOperator = andOperator(_swap); _arrayCount = 0; _bitCount = 0; if(_buffer.size()>0) _car = _buffer.at(0); }
/*! \return integer representation of bits read (little indian). 0 if none available */ int EncodedData::read() { int val = 0; if(hasNext()) { int bitsLeft = 8 - _bitCount; if(bitsLeft < _swap) { val = _car & andOperator(bitsLeft); int bitsRemaining = _swap - bitsLeft; if(_arrayCount < (unsigned int)_buffer.size() - 1) { _car = _buffer.at(_arrayCount + 1); val += ((_car & andOperator(bitsRemaining)) << bitsLeft); _car = _car >> bitsRemaining; _bitCount = bitsRemaining; } _arrayCount++; }
SelectionSet& operator&= (const SelectionSet &ss) { andOperator (ss); return *this; }