1 #ifndef ZSERIO_BIT_STREAM_READER_H_INC
2 #define ZSERIO_BIT_STREAM_READER_H_INC
104 template <
typename ALLOC>
241 template <
typename ALLOC = std::allocator<u
int8_t>>
244 const size_t len =
static_cast<size_t>(
readVarSize());
246 if ((beginBitPosition & 0x07U) != 0)
251 for (
size_t i = 0; i < len; ++i)
253 value.push_back(readByte());
273 template <
typename ALLOC = std::allocator<
char>>
276 const size_t len =
static_cast<size_t>(
readVarSize());
278 if ((beginBitPosition & 0x07U) != 0)
283 for (
size_t i = 0; i < len; ++i)
285 using char_traits = std::char_traits<char>;
286 const char readCharacter =
287 char_traits::to_char_type(
static_cast<char_traits::int_type
>(readByte()));
288 value.push_back(readCharacter);
315 template <
typename ALLOC = std::allocator<u
int8_t>>
318 const size_t bitSize =
static_cast<size_t>(
readVarSize());
319 const size_t numBytesToRead = bitSize / 8;
320 const uint8_t numRestBits =
static_cast<uint8_t
>(bitSize - numBytesToRead * 8);
325 if ((beginBitPosition & 0x07U) != 0)
330 *it =
static_cast<uint8_t
>(
readBits(8));
338 (void)std::copy(sourceIt, sourceIt + numBytesToRead, buffer.
begin());
343 *itEnd =
static_cast<uint8_t
>(
readBits(numRestBits) << (8U - numRestBits));
371 void alignTo(
size_t alignment);
386 ReaderContext m_context;
Span< const uint8_t > getData() const
void setBitPosition(BitPosType position)
void alignTo(size_t alignment)
uint64_t readBits64(uint8_t numBits=64)
BitStreamReader(const uint8_t *buffer, size_t bufferByteSize)
uint32_t readBits(uint8_t numBits=32)
BitStreamReader(const BasicBitBuffer< ALLOC > &bitBuffer)
BasicBitBuffer< RebindAlloc< ALLOC, uint8_t > > readBitBuffer(const ALLOC &allocator=ALLOC())
size_t getBufferBitSize() const
string< ALLOC > readString(const ALLOC &alloc=ALLOC())
vector< uint8_t, ALLOC > readBytes(const ALLOC &alloc=ALLOC())
int32_t readSignedBits(uint8_t numBits=32)
int64_t readSignedBits64(uint8_t numBits=64)
~BitStreamReader()=default
BitPosType getBitPosition() const
constexpr iterator begin() const noexcept
uint8_t numBits(uint64_t numValues)
std::basic_string< char, std::char_traits< char >, RebindAlloc< ALLOC, char > > string
std::vector< T, RebindAlloc< ALLOC, T > > vector
ReaderContext(Span< const uint8_t > readBuffer, size_t readBufferBitSize)
Span< const uint8_t > buffer
ReaderContext & operator=(const ReaderContext &&)=delete
const BitPosType bufferBitSize
ReaderContext(const ReaderContext &&)=delete
ReaderContext & operator=(const ReaderContext &)=delete
ReaderContext(const ReaderContext &)=delete