Zserio C++17 runtime library  1.1.0
Built for Zserio 2.18.1
zserio::BitStreamReader Class Reference

#include <BitStreamReader.h>

Classes

struct  ReaderContext
 

Public Types

using BitPosType = size_t
 

Public Member Functions

 BitStreamReader (const uint8_t *buffer, size_t bufferByteSize, ArrayPreallocation maxArrayPrealloc={})
 
 BitStreamReader (Span< const uint8_t > buffer, ArrayPreallocation maxArrayPrealloc={})
 
 BitStreamReader (Span< const uint8_t > buffer, size_t bufferBitSize, ArrayPreallocation maxArrayPrealloc={})
 
 BitStreamReader (const uint8_t *buffer, size_t bufferBitSize, BitsTag, ArrayPreallocation maxArrayPrealloc={})
 
template<typename ALLOC >
 BitStreamReader (const BasicBitBuffer< ALLOC > &bitBuffer, ArrayPreallocation maxArrayPrealloc={})
 
 ~BitStreamReader ()=default
 
uint32_t readUnsignedBits32 (uint8_t numBits=32)
 
uint64_t readUnsignedBits64 (uint8_t numBits=64)
 
int32_t readSignedBits32 (uint8_t numBits=32)
 
int64_t readSignedBits64 (uint8_t numBits=64)
 
Bool readBool ()
 
VarInt16 readVarInt16 ()
 
VarInt32 readVarInt32 ()
 
VarInt64 readVarInt64 ()
 
VarInt readVarInt ()
 
VarUInt16 readVarUInt16 ()
 
VarUInt32 readVarUInt32 ()
 
VarUInt64 readVarUInt64 ()
 
VarUInt readVarUInt ()
 
VarSize readVarSize ()
 
Float16 readFloat16 ()
 
Float32 readFloat32 ()
 
Float64 readFloat64 ()
 
template<typename ALLOC = std::allocator<uint8_t>>
BasicBytes< ALLOC > readBytes (const ALLOC &alloc=ALLOC())
 
template<typename ALLOC = std::allocator<char>>
BasicString< ALLOC > readString (const ALLOC &alloc=ALLOC())
 
template<typename ALLOC = std::allocator<uint8_t>>
BasicBitBuffer< RebindAlloc< ALLOC, uint8_t > > readBitBuffer (const ALLOC &allocator=ALLOC())
 
BitPosType getBitPosition () const
 
void setBitPosition (BitPosType position)
 
void alignTo (size_t alignment)
 
size_t getBufferBitSize () const
 
size_t getMaxArrayPreallocation () const
 

Detailed Description

Reader class which allows to read various data from the bit stream.

Definition at line 54 of file BitStreamReader.h.

Member Typedef Documentation

◆ BitPosType

Type for bit position.

Definition at line 58 of file BitStreamReader.h.

Constructor & Destructor Documentation

◆ BitStreamReader() [1/5]

zserio::BitStreamReader::BitStreamReader ( const uint8_t *  buffer,
size_t  bufferByteSize,
ArrayPreallocation  maxArrayPrealloc = {} 
)
explicit

Constructor from raw buffer.

Parameters
bufferPointer to the buffer to read.
bufferByteSizeSize of the buffer in bytes.
maxArrayPreallocMaximum preallocation for arrays.

Definition at line 374 of file BitStreamReader.cpp.

◆ BitStreamReader() [2/5]

zserio::BitStreamReader::BitStreamReader ( Span< const uint8_t >  buffer,
ArrayPreallocation  maxArrayPrealloc = {} 
)
explicit

Constructor from buffer passed as a Span.

Parameters
bufferBuffer to read.
maxArrayPreallocMaximum preallocation for arrays.

Definition at line 379 of file BitStreamReader.cpp.

◆ BitStreamReader() [3/5]

zserio::BitStreamReader::BitStreamReader ( Span< const uint8_t >  buffer,
size_t  bufferBitSize,
ArrayPreallocation  maxArrayPrealloc = {} 
)
explicit

Constructor from buffer passed as a Span with exact bit size.

Parameters
bufferBuffer to read.
bufferBitSizeSize of the buffer in bits.
maxArrayPreallocMaximum preallocation for arrays.

Definition at line 383 of file BitStreamReader.cpp.

◆ BitStreamReader() [4/5]

zserio::BitStreamReader::BitStreamReader ( const uint8_t *  buffer,
size_t  bufferBitSize,
BitsTag  ,
ArrayPreallocation  maxArrayPrealloc = {} 
)
explicit

Constructor from raw buffer with exact bit size.

Parameters
bufferPointer to buffer to read.
bufferBitSizeSize of the buffer in bits.
maxArrayPreallocMaximum preallocation for arrays.

Definition at line 394 of file BitStreamReader.cpp.

◆ BitStreamReader() [5/5]

template<typename ALLOC >
zserio::BitStreamReader::BitStreamReader ( const BasicBitBuffer< ALLOC > &  bitBuffer,
ArrayPreallocation  maxArrayPrealloc = {} 
)
inlineexplicit

Constructor from bit buffer.

Parameters
bitBufferBit buffer to read from.
maxArrayPreallocMaximum preallocation for arrays.

Definition at line 147 of file BitStreamReader.h.

◆ ~BitStreamReader()

zserio::BitStreamReader::~BitStreamReader ( )
default

Destructor.

Member Function Documentation

◆ alignTo()

void zserio::BitStreamReader::alignTo ( size_t  alignment)

Moves current bit position to perform the requested bit alignment.

Parameters
alignmentSize of the alignment in bits.

Definition at line 863 of file BitStreamReader.cpp.

◆ getBitPosition()

BitPosType zserio::BitStreamReader::getBitPosition ( ) const
inline

Gets current bit position.

Returns
Current bit position.

Definition at line 407 of file BitStreamReader.h.

◆ getBufferBitSize()

size_t zserio::BitStreamReader::getBufferBitSize ( ) const
inline

Gets size of the underlying buffer in bits.

Returns
Buffer bit size.

Definition at line 431 of file BitStreamReader.h.

◆ getMaxArrayPreallocation()

size_t zserio::BitStreamReader::getMaxArrayPreallocation ( ) const
inline

Gets the maximum initial array allocation in bytes.

Returns
Maximum initial array allocation.

Definition at line 441 of file BitStreamReader.h.

◆ readBitBuffer()

template<typename ALLOC = std::allocator<uint8_t>>
BasicBitBuffer<RebindAlloc<ALLOC, uint8_t> > zserio::BitStreamReader::readBitBuffer ( const ALLOC &  allocator = ALLOC())
inline

Reads a bit buffer.

Parameters
allocAllocator to use.
Returns
Read bit buffer.

Definition at line 365 of file BitStreamReader.h.

◆ readBool()

Bool zserio::BitStreamReader::readBool ( )

Reads bool as a single bit.

Returns
Read bool value.

Definition at line 457 of file BitStreamReader.cpp.

◆ readBytes()

template<typename ALLOC = std::allocator<uint8_t>>
BasicBytes<ALLOC> zserio::BitStreamReader::readBytes ( const ALLOC &  alloc = ALLOC())
inline

Reads bytes.

Parameters
allocAllocator to use.
Returns
Read bytes as a vector.

Definition at line 291 of file BitStreamReader.h.

◆ readFloat16()

Float16 zserio::BitStreamReader::readFloat16 ( )

Reads 16-bit float.

Returns
Read float16.

Definition at line 822 of file BitStreamReader.cpp.

◆ readFloat32()

Float32 zserio::BitStreamReader::readFloat32 ( )

Reads 32-bit float.

Returns
Read float32.

Definition at line 829 of file BitStreamReader.cpp.

◆ readFloat64()

Float64 zserio::BitStreamReader::readFloat64 ( )

Reads 64-bit float double.

Returns
Read float64.

Definition at line 836 of file BitStreamReader.cpp.

◆ readSignedBits32()

int32_t zserio::BitStreamReader::readSignedBits32 ( uint8_t  numBits = 32)

Reads signed bits up to 32-bits.

Parameters
numBitsNumber of bits to read.
Returns
Read bits.

Definition at line 450 of file BitStreamReader.cpp.

◆ readSignedBits64()

int64_t zserio::BitStreamReader::readSignedBits64 ( uint8_t  numBits = 64)

Reads signed bits up to 64-bits.

Parameters
numBitsNumber of bits to read.
Returns
Read bits.

Definition at line 422 of file BitStreamReader.cpp.

◆ readString()

template<typename ALLOC = std::allocator<char>>
BasicString<ALLOC> zserio::BitStreamReader::readString ( const ALLOC &  alloc = ALLOC())
inline

Reads an UTF-8 string.

Parameters
allocAllocator to use.
Returns
Read string.

Definition at line 327 of file BitStreamReader.h.

◆ readUnsignedBits32()

uint32_t zserio::BitStreamReader::readUnsignedBits32 ( uint8_t  numBits = 32)

Reads unsigned bits up to 32-bits.

Parameters
numBitsNumber of bits to read.
Returns
Read bits.

Definition at line 399 of file BitStreamReader.cpp.

◆ readUnsignedBits64()

uint64_t zserio::BitStreamReader::readUnsignedBits64 ( uint8_t  numBits = 64)

Reads unsigned bits up to 64-bits.

Parameters
numBitsNumber of bits to read.
Returns
Read bits.

Definition at line 406 of file BitStreamReader.cpp.

◆ readVarInt()

VarInt zserio::BitStreamReader::readVarInt ( )

Reads signed variable integer up to 72 bits.

Returns
Read varint.

Definition at line 561 of file BitStreamReader.cpp.

◆ readVarInt16()

VarInt16 zserio::BitStreamReader::readVarInt16 ( )

Reads signed variable integer up to 16 bits.

Returns
Read varint16.

Definition at line 462 of file BitStreamReader.cpp.

◆ readVarInt32()

VarInt32 zserio::BitStreamReader::readVarInt32 ( )

Reads signed variable integer up to 32 bits.

Returns
Read varint32.

Definition at line 477 of file BitStreamReader.cpp.

◆ readVarInt64()

VarInt64 zserio::BitStreamReader::readVarInt64 ( )

Reads signed variable integer up to 32 bits.

Returns
Read VarInt64.

Definition at line 505 of file BitStreamReader.cpp.

◆ readVarSize()

VarSize zserio::BitStreamReader::readVarSize ( )

Read variable size integer up to 40 bits.

Returns
Read varsize.

Definition at line 782 of file BitStreamReader.cpp.

◆ readVarUInt()

VarUInt zserio::BitStreamReader::readVarUInt ( )

Read unsigned variable integer up to 72 bits.

Returns
Read varuint.

Definition at line 720 of file BitStreamReader.cpp.

◆ readVarUInt16()

VarUInt16 zserio::BitStreamReader::readVarUInt16 ( )

Read unsigned variable integer up to 16 bits.

Returns
Read varuint16.

Definition at line 624 of file BitStreamReader.cpp.

◆ readVarUInt32()

VarUInt32 zserio::BitStreamReader::readVarUInt32 ( )

Read unsigned variable integer up to 32 bits.

Returns
Read varuint32.

Definition at line 638 of file BitStreamReader.cpp.

◆ readVarUInt64()

VarUInt64 zserio::BitStreamReader::readVarUInt64 ( )

Read unsigned variable integer up to 64 bits.

Returns
Read varuint64.

Definition at line 665 of file BitStreamReader.cpp.

◆ setBitPosition()

void zserio::BitStreamReader::setBitPosition ( BitPosType  position)

Sets current bit position. Use with caution!

Parameters
positionNew bit position.

Definition at line 847 of file BitStreamReader.cpp.


The documentation for this class was generated from the following files: