| 359 | } |
| 360 | |
| 361 | ByteVector SubByteReader::peekBytes(unsigned nrBytes) const |
| 362 | { |
| 363 | if (this->posInBufferBits != 0 && this->posInBufferBits != 8) |
| 364 | throw std::logic_error("When peeking bytes from the bitstream, it must be byte aligned."); |
| 365 | |
| 366 | auto pos = this->posInBufferBytes; |
| 367 | if (this->posInBufferBits == 8) |
| 368 | pos++; |
| 369 | |
| 370 | if (pos + nrBytes > this->byteVector.size()) |
| 371 | throw std::logic_error("Not enough data in the input to peek that far"); |
| 372 | |
| 373 | return ByteVector(this->byteVector.begin() + pos, this->byteVector.begin() + pos + nrBytes); |
| 374 | } |
| 375 | |
| 376 | bool SubByteReader::gotoNextByte() |
| 377 | { |