Project
Loading...
Searching...
No Matches
o2::algorithm::BitstreamReader< BufferType > Class Template Reference

#include <BitstreamReader.h>

Classes

class  Bits
 Helper class to get value of specified type which holds the number used bits. More...
 

Public Types

using self_type = BitstreamReader< BufferType >
 
using value_type = BufferType
 
using iterator = const value_type *
 

Public Member Functions

 BitstreamReader ()=delete
 
 BitstreamReader (iterator start, iterator end)
 
 ~BitstreamReader ()=default
 
bool good () const
 
bool eof () const
 
void reset ()
 Reset the reader, start over at beginning.
 
template<typename T , size_t N = sizeof(T) * 8>
size_t peek (T &v)
 
template<typename T >
size_t peek (T &v, size_t bitlength)
 
void seek (size_t bitlength)
 
template<typename T , size_t N = sizeof(T) * 8>
get ()
 Get the next n bits and move the read position.
 
template<typename T >
get (size_t bitlength=sizeof(T) *8)
 Get the next n and move the read position.
 
template<typename T , std::enable_if_t< std::is_integral< T >::value, int > = 0>
self_typeoperator>> (T &target)
 Read an integral value from the stream.
 
template<size_t N>
self_typeoperator>> (std::bitset< N > &target)
 Read a bitstream value from the stream.
 
template<typename T >
self_typeoperator>> (Bits< T > &target)
 Read a Bits object from the stream.
 

Static Public Attributes

static constexpr size_t value_size = sizeof(value_type) * 8
 

Detailed Description

template<typename BufferType>
class o2::algorithm::BitstreamReader< BufferType >

Definition at line 49 of file BitstreamReader.h.

Member Typedef Documentation

◆ iterator

template<typename BufferType >
using o2::algorithm::BitstreamReader< BufferType >::iterator = const value_type*

Definition at line 56 of file BitstreamReader.h.

◆ self_type

template<typename BufferType >
using o2::algorithm::BitstreamReader< BufferType >::self_type = BitstreamReader<BufferType>

Definition at line 52 of file BitstreamReader.h.

◆ value_type

template<typename BufferType >
using o2::algorithm::BitstreamReader< BufferType >::value_type = BufferType

Definition at line 55 of file BitstreamReader.h.

Constructor & Destructor Documentation

◆ BitstreamReader() [1/2]

template<typename BufferType >
o2::algorithm::BitstreamReader< BufferType >::BitstreamReader ( )
delete

◆ BitstreamReader() [2/2]

template<typename BufferType >
o2::algorithm::BitstreamReader< BufferType >::BitstreamReader ( iterator  start,
iterator  end 
)
inline

Definition at line 59 of file BitstreamReader.h.

◆ ~BitstreamReader()

template<typename BufferType >
o2::algorithm::BitstreamReader< BufferType >::~BitstreamReader ( )
default

Member Function Documentation

◆ eof()

template<typename BufferType >
bool o2::algorithm::BitstreamReader< BufferType >::eof ( ) const
inline

Indicates end of data

Returns
true if end of resource is reached

Definition at line 74 of file BitstreamReader.h.

◆ get() [1/2]

template<typename BufferType >
template<typename T , size_t N = sizeof(T) * 8>
T o2::algorithm::BitstreamReader< BufferType >::get ( )
inline

Get the next n bits and move the read position.

Definition at line 136 of file BitstreamReader.h.

◆ get() [2/2]

template<typename BufferType >
template<typename T >
T o2::algorithm::BitstreamReader< BufferType >::get ( size_t  bitlength = sizeof(T) * 8)
inline

Get the next n and move the read position.

Definition at line 146 of file BitstreamReader.h.

◆ good()

template<typename BufferType >
bool o2::algorithm::BitstreamReader< BufferType >::good ( ) const
inline

Check reader's state

Returns
true if not in error state

Definition at line 67 of file BitstreamReader.h.

◆ operator>>() [1/3]

template<typename BufferType >
template<typename T >
self_type & o2::algorithm::BitstreamReader< BufferType >::operator>> ( Bits< T > &  target)
inline

Read a Bits object from the stream.

Definition at line 233 of file BitstreamReader.h.

◆ operator>>() [2/3]

template<typename BufferType >
template<size_t N>
self_type & o2::algorithm::BitstreamReader< BufferType >::operator>> ( std::bitset< N > &  target)
inline

Read a bitstream value from the stream.

Definition at line 225 of file BitstreamReader.h.

◆ operator>>() [3/3]

template<typename BufferType >
template<typename T , std::enable_if_t< std::is_integral< T >::value, int > = 0>
self_type & o2::algorithm::BitstreamReader< BufferType >::operator>> ( T &  target)
inline

Read an integral value from the stream.

Definition at line 217 of file BitstreamReader.h.

◆ peek() [1/2]

template<typename BufferType >
template<typename T , size_t N = sizeof(T) * 8>
size_t o2::algorithm::BitstreamReader< BufferType >::peek ( T &  v)
inline

Get the next N bits without moving the read position if bitlength is smaller than the size of data type, result is aligned to LSB TODO: this also works nicely for bitsets, but then the bitlength has to be specified as template parameter, want to do a specific overload, but needs more work to catch all cases.

Parameters
vtarget variable passed by reference
Returns
number of poked bits

Definition at line 94 of file BitstreamReader.h.

◆ peek() [2/2]

template<typename BufferType >
template<typename T >
size_t o2::algorithm::BitstreamReader< BufferType >::peek ( T &  v,
size_t  bitlength 
)
inline

Get the next n bits without moving the read position if bitlength is smaller than the size of data type, result is aligned to LSB

Parameters
vtarget variable passed by reference
bitlengthnumber of bits to read
Returns
number of poked bits

Definition at line 106 of file BitstreamReader.h.

◆ reset()

template<typename BufferType >
void o2::algorithm::BitstreamReader< BufferType >::reset ( )
inline

Reset the reader, start over at beginning.

Definition at line 80 of file BitstreamReader.h.

◆ seek()

template<typename BufferType >
void o2::algorithm::BitstreamReader< BufferType >::seek ( size_t  bitlength)
inline

Move read position

Parameters
bitlengthmove count in number of bits

Definition at line 113 of file BitstreamReader.h.

Member Data Documentation

◆ value_size

template<typename BufferType >
constexpr size_t o2::algorithm::BitstreamReader< BufferType >::value_size = sizeof(value_type) * 8
staticconstexpr

Definition at line 57 of file BitstreamReader.h.


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