ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::bitbuffer::BitReader Class Reference

Description:

Reads bits from a BitBufferBase.

Definition at line 1011 of file bitbuffer.inl.

Inheritance diagram for alib::bitbuffer::BitReader:
[legend]
Collaboration diagram for alib::bitbuffer::BitReader:
[legend]

Public Method Index:

 BitReader (BitBufferBase &buffer)
 
 BitReader (BitBufferBase &buffer, const BitBufferBase::Index &index)
 
 ~BitReader ()
 
template<lang::ShiftOpRHS TWidth, typename TResult = int>
requires ( std::integral<TResult> && ( TWidth <= bitsof(TStorage)) )
TResult Read ()
 
template<lang::ShiftOpRHS TWidth, typename TResult = int>
requires ( std::integral<TResult> && ( TWidth > bitsof(TStorage)) )
TResult Read ()
 
template<typename TUIntegral>
requires ( std::unsigned_integral<TUIntegral> && (bitsof(TUIntegral) == 8) )
TUIntegral Read ()
 
template<typename TUIntegral>
requires ( std::unsigned_integral<TUIntegral> && (bitsof(TUIntegral) == 16) )
TUIntegral Read ()
 
template<typename TUIntegral>
requires ( std::unsigned_integral<TUIntegral> && (bitsof(TUIntegral) == 32) )
TUIntegral Read ()
 
template<typename TUIntegral>
requires ( std::unsigned_integral<TUIntegral> && (bitsof(TUIntegral) == 64) )
TUIntegral Read ()
 
template<typename TSIntegral>
requires ( std::signed_integral<TSIntegral> )
TSIntegral Read ()
 
template<typename TResult = int>
requires ( sizeof(TResult) <= sizeof(TStorage) )
TResult Read (lang::ShiftOpRHS width)
 
template<typename TResult = int>
requires ( sizeof(TResult) > sizeof(TStorage) )
TResult Read (lang::ShiftOpRHS width)
 
void Reset ()
 Resets this reader to the start of the bit buffer.
 
void Reset (const BitBufferBase::Index &index)
 
BitReaderSync ()
 
- Public Method Index: inherited from alib::bitbuffer::BitRWBase
BitBufferBaseGetBuffer () const
 
BitBufferBase::Index GetIndex () const
 
uinteger RemainingSize () const
 
uinteger Usage () const
 

Protected Type Index:

using TStorage = BitBufferBase::TStorage
 Local type alias (shortcut)
 

Protected Field Index:

BitBufferBase::TStorage word
 The current word, which is partly read and shifted to start with current bit.
 
- Protected Field Index: inherited from alib::bitbuffer::BitRWBase
BitBufferBasebb
 The bit buffer to write into. Provided on construction.
 
BitBufferBase::Index idx
 The current reading/writing index within bb.
 

Protected Method Index:

ALIB_DLL uint16_t readUIntegral16 ()
 
ALIB_DLL uint32_t readUIntegral32 ()
 
ALIB_DLL uint64_t readUIntegral64 ()
 
ALIB_DLL uint8_t readUIntegral8 ()
 
- Protected Method Index: inherited from alib::bitbuffer::BitRWBase
 BitRWBase (BitBufferBase &buffer)
 

Type Definition Details:

◆ TStorage

Local type alias (shortcut)

Definition at line 1015 of file bitbuffer.inl.

Field Details:

◆ word

BitBufferBase::TStorage alib::bitbuffer::BitReader::word
protected

The current word, which is partly read and shifted to start with current bit.

Definition at line 1018 of file bitbuffer.inl.

Constructor(s) / Destructor Details:

◆ BitReader() [1/2]

alib::bitbuffer::BitReader::BitReader ( BitBufferBase & buffer)
inlineexplicit

Constructs a bit reader using the given bit buffer and starting to read at the beginning.

Parameters
bufferThe buffer to read from.

Definition at line 1023 of file bitbuffer.inl.

Here is the call graph for this function:

◆ BitReader() [2/2]

alib::bitbuffer::BitReader::BitReader ( BitBufferBase & buffer,
const BitBufferBase::Index & index )
inlineexplicit

Constructs a bit reader using the given bit buffer, starting to read at the given Index.

Parameters
bufferThe buffer to read from.
indexAn index providing the postion of the first bit to read in buffer.

Definition at line 1034 of file bitbuffer.inl.

Here is the call graph for this function:

◆ ~BitReader()

alib::bitbuffer::BitReader::~BitReader ( )
inline

Destructs a bit reader. In debug compilations an ALib assertion is raised if the a read operation passed the end of the underlying buffer was performed.

Definition at line 1044 of file bitbuffer.inl.

Method Details:

◆ Read() [1/9]

template<lang::ShiftOpRHS TWidth, typename TResult = int>
requires ( std::integral<TResult> && ( TWidth <= bitsof(TStorage)) )
TResult alib::bitbuffer::BitReader::Read ( )
inline

Reads the given number of bits from the stream into the given unsigned integral value.

Note
Two different template functions (selected by keyword requires) for the different integral types exist.
This is version 1/2: Bits to read are less or equal to the internal buffer width
See also
This method uses a template parameter for the number of bits to read. A slightly slower, non-templated version is available with Read<TResult>(ShiftOpRHS), which is to be used when the number of bits to write is determined only at run-time.
Template Parameters
TWidthThe number of bits in value to write.
TResultThe type of the value to return.
Returns
The value read.

Definition at line 1092 of file bitbuffer.inl.

Here is the call graph for this function:

◆ Read() [2/9]

template<lang::ShiftOpRHS TWidth, typename TResult = int>
requires ( std::integral<TResult> && ( TWidth > bitsof(TStorage)) )
TResult alib::bitbuffer::BitReader::Read ( )
inline

Reads the given number of bits from the stream into the given unsigned integral value.

Note
Two different template functions (selected by keyword requires) for the different integral types exist.
This is version 2/2: Bits to read are more than the internal buffer width.
See also
This method uses a template parameter for the number of bits to read. A slightly slower, non-templated version is available with Read<TResult>(ShiftOpRHS), which is to be used when the number of bits to write is determined only at run-time.
Template Parameters
TWidthThe number of bits in value to write.
TResultThe type of the value to return.
Returns
The value read.

Definition at line 1157 of file bitbuffer.inl.

Here is the call graph for this function:

◆ Read() [3/9]

template<typename TUIntegral>
requires ( std::unsigned_integral<TUIntegral> && (bitsof(TUIntegral) == 8) )
TUIntegral alib::bitbuffer::BitReader::Read ( )
inline

Reads the given integral value from the stream. Information about the encoding of the values is given with the documentation of BitWriter::Write<TIntegral>(TIntegral).
This overload reads unsigned integral types of 8-bit width.

Template Parameters
TUIntegralThe unsigned integral type to read.
Returns
The value read from the bit buffer.

Definition at line 1321 of file bitbuffer.inl.

Here is the call graph for this function:

◆ Read() [4/9]

template<typename TUIntegral>
requires ( std::unsigned_integral<TUIntegral> && (bitsof(TUIntegral) == 16) )
TUIntegral alib::bitbuffer::BitReader::Read ( )
inline

Reads the given integral value from the stream. Information about the encoding of the values is given with the documentation of BitWriter::Write<TIntegral>(TIntegral).
This overload reads unsigned integral types of 16-bit width.

Template Parameters
TUIntegralThe unsigned integral type to read.
Returns
The value read from the bit buffer.

Definition at line 1331 of file bitbuffer.inl.

Here is the call graph for this function:

◆ Read() [5/9]

template<typename TUIntegral>
requires ( std::unsigned_integral<TUIntegral> && (bitsof(TUIntegral) == 32) )
TUIntegral alib::bitbuffer::BitReader::Read ( )
inline

Reads the given integral value from the stream. Information about the encoding of the values is given with the documentation of BitWriter::Write<TIntegral>(TIntegral).
This overload reads unsigned integral types of 32-bit width.

Template Parameters
TUIntegralThe unsigned integral type to read.
Returns
The value read from the bit buffer.

Definition at line 1342 of file bitbuffer.inl.

Here is the call graph for this function:

◆ Read() [6/9]

template<typename TUIntegral>
requires ( std::unsigned_integral<TUIntegral> && (bitsof(TUIntegral) == 64) )
TUIntegral alib::bitbuffer::BitReader::Read ( )
inline

Reads the given integral value from the stream. Information about the encoding of the values is given with the documentation of BitWriter::Write<TIntegral>(TIntegral).
This overload reads unsigned integral types of 64-bit width.

Template Parameters
TUIntegralThe unsigned integral type to read.
Returns
The value read from the bit buffer.

Definition at line 1353 of file bitbuffer.inl.

Here is the call graph for this function:

◆ Read() [7/9]

template<typename TSIntegral>
requires ( std::signed_integral<TSIntegral> )
TSIntegral alib::bitbuffer::BitReader::Read ( )
inline

Reads the given signed integral value from the stream. Information about the encoding of the values is given with the documentation of BitWriter::Write<TIntegral>(TIntegral).
This overload reads signed integral types.

Template Parameters
TSIntegralThe signed integral type to read.
Returns
The value read from the bit buffer.

Definition at line 1364 of file bitbuffer.inl.

Here is the call graph for this function:

◆ Read() [8/9]

template<typename TResult = int>
requires ( sizeof(TResult) <= sizeof(TStorage) )
TResult alib::bitbuffer::BitReader::Read ( lang::ShiftOpRHS width)
inline

Reads the given number of bits from the stream into the given unsigned integral value.

Note
Different template functions for different integral types exist and are selected with keyword requires.
See also
A method that uses a template parameter for the number of bits to read, is available with Read<TWidth,TResult>. This might be slightly faster and should be used instead of this method, whenever the number of bits to read is known at compilation time.
Template Parameters
TResultThe type of the value to return. Defaults to type int.
Parameters
widthThe number of bits to read.
Returns
The value read.

Definition at line 1202 of file bitbuffer.inl.

Here is the call graph for this function:

◆ Read() [9/9]

template<typename TResult = int>
requires ( sizeof(TResult) > sizeof(TStorage) )
TResult alib::bitbuffer::BitReader::Read ( lang::ShiftOpRHS width)
inline

Reads the given number of bits from the stream into the given unsigned integral value.

Note
Different template functions for different integral types exist and are selected with keyword requires.
See also
A method that uses a template parameter for the number of bits to read, is available with Read<TWidth,TResult>. This might be slightly faster and should be used instead of this method, whenever the number of bits to read is known at compilation time.
Template Parameters
TResultThe type of the value to return. Defaults to type int.
Parameters
widthThe number of bits to read.
Returns
The value read.

Definition at line 1250 of file bitbuffer.inl.

Here is the call graph for this function:

◆ readUIntegral16()

uint16_t alib::bitbuffer::BitReader::readUIntegral16 ( )
protected

Internal method that reads a unsigned 16-bit value.

Returns
The value read.

Definition at line 259 of file bitbuffer.cpp.

Here is the call graph for this function:

◆ readUIntegral32()

uint32_t alib::bitbuffer::BitReader::readUIntegral32 ( )
protected

Internal method that reads a unsigned 32-bit value.

Returns
The value read.

Definition at line 269 of file bitbuffer.cpp.

Here is the call graph for this function:

◆ readUIntegral64()

uint64_t alib::bitbuffer::BitReader::readUIntegral64 ( )
protected

Internal method that reads a unsigned 64-bit value.

Returns
The value read.

Definition at line 281 of file bitbuffer.cpp.

Here is the call graph for this function:

◆ readUIntegral8()

uint8_t alib::bitbuffer::BitReader::readUIntegral8 ( )
protected

Internal method that reads a unsigned 8-bit value.

Returns
The value read.

Definition at line 249 of file bitbuffer.cpp.

Here is the call graph for this function:

◆ Reset() [1/2]

void alib::bitbuffer::BitReader::Reset ( )
inline

Resets this reader to the start of the bit buffer.

Definition at line 1051 of file bitbuffer.inl.

◆ Reset() [2/2]

void alib::bitbuffer::BitReader::Reset ( const BitBufferBase::Index & index)
inline

Resets this reader to the given index position and calls Sync().

Parameters
indexThe next read position.

Definition at line 1060 of file bitbuffer.inl.

Here is the call graph for this function:

◆ Sync()

BitReader & alib::bitbuffer::BitReader::Sync ( )
inline

Re-reads the currently fetched storage word from the memory.

Note
This method is not needed in common use cases and implemented solely for the purpose to support unit-tests which write and write in parallel to the same bit buffer.
Returns
A reference to this BitReader to allow concatenated operations.

Definition at line 1072 of file bitbuffer.inl.

Here is the call graph for this function:

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