Belle II Software  release-08-01-10
BitStream Class Reference

Bit stream struct. More...

#include <BitStream.h>

Collaboration diagram for BitStream:

Public Member Functions

 BitStream ()
 Default constructor for ROOT. More...
 
 BitStream (int n)
 Constructor with the reserved and cleared storage prepared for incoming bits. More...
 
void putNBits (unsigned int value, unsigned int n)
 Push n least significant bits of "value" to the stream. More...
 
unsigned int getNBits (unsigned int n)
 Fetch n bits. More...
 
size_t getPos () const
 Get current position in the stream.
 
void setPos (size_t pos)
 Set position in the stream.
 
std::vector< unsigned int > & getStore ()
 Get data vector.
 
void resize ()
 Resize data vector to the current position.
 

Protected Attributes

size_t m_pos
 Current position in the storage.
 
std::vector< unsigned int > m_store
 The bit storage.
 

Detailed Description

Bit stream struct.

Class contains vector of unsigned ints as a storage and current bit position in the storage. One can put and fetch up to 32 bits at once.

Definition at line 19 of file BitStream.h.

Constructor & Destructor Documentation

◆ BitStream() [1/2]

BitStream ( )
inline

Default constructor for ROOT.

Current position is at begining of the storage.

Definition at line 24 of file BitStream.h.

24 : m_pos(0), m_store(1, 0) {}
std::vector< unsigned int > m_store
The bit storage.
Definition: BitStream.h:79
size_t m_pos
Current position in the storage.
Definition: BitStream.h:78

◆ BitStream() [2/2]

BitStream ( int  n)
inlineexplicit

Constructor with the reserved and cleared storage prepared for incoming bits.

Be sure the size is enough for incoming data since the class does not check bounds. Current position is at begining of the storage.

Definition at line 31 of file BitStream.h.

Member Function Documentation

◆ getNBits()

unsigned int getNBits ( unsigned int  n)
inline

Fetch n bits.

Update current position accordingly

Parameters
n– how many bits fetch from the current position in the stream
Returns
n fetched bits

Definition at line 52 of file BitStream.h.

◆ putNBits()

void putNBits ( unsigned int  value,
unsigned int  n 
)
inline

Push n least significant bits of "value" to the stream.

Update current position accordingly.

Parameters
value– value to put in the stream
n– how many least signfificant bits of "value" put in the stream (n<=32)

Definition at line 37 of file BitStream.h.


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