tudocomp
– The TU Dortmund Compression Framework
tdc::io::BitIStream Class Reference

Wrapper for input streams that provides bitwise reading functionality. More...

#include <BitIStream.hpp>

Public Member Functions

 BitIStream (InputStream &&input)
 Constructs a bitwise input stream. More...
 
 BitIStream (Input &input)
 Constructs a bitwise input stream. More...
 
uint8_t read_bit ()
 Reads the next single bit from the input. More...
 
template<class T >
read_int (size_t amount=sizeof(T)*CHAR_BIT)
 Reads the integer value of the next amount bits in MSB first order. More...
 
template<typename value_t >
value_t read_unary ()
 
template<typename value_t >
value_t read_ternary ()
 
template<typename value_t >
value_t read_elias_gamma ()
 
template<typename value_t >
value_t read_elias_delta ()
 
template<typename T = size_t>
read_compressed_int (size_t b=7)
 Reads a compressed integer from the input. More...
 
bool eof () const
 TODO document. More...
 

Detailed Description

Wrapper for input streams that provides bitwise reading functionality.

The current byte in the underlying input stream is buffered and processed bitwise using another cursor.

Definition at line 16 of file BitIStream.hpp.

Constructor & Destructor Documentation

tdc::io::BitIStream::BitIStream ( InputStream &&  input)
inline

Constructs a bitwise input stream.

Parameters
inputThe underlying input stream.

Definition at line 69 of file BitIStream.hpp.

tdc::io::BitIStream::BitIStream ( Input input)
inline

Constructs a bitwise input stream.

Parameters
inputThe underlying input.

Definition at line 86 of file BitIStream.hpp.

Member Function Documentation

bool tdc::io::BitIStream::eof ( ) const
inline

TODO document.

Definition at line 191 of file BitIStream.hpp.

uint8_t tdc::io::BitIStream::read_bit ( )
inline

Reads the next single bit from the input.

Returns
1 if the next bit is set, 0 otherwise.

Definition at line 91 of file BitIStream.hpp.

template<typename T = size_t>
T tdc::io::BitIStream::read_compressed_int ( size_t  b = 7)
inline

Reads a compressed integer from the input.

The compressed form of an integer n is achieved by splitting up the bit representation of n in blocks of width b. For each non-zero block (in little endian order), a 1-bit and the block itself is written. The compressed integer is finally terminated by a 0-bit.

Template Parameters
Theinteger type to read.
Parameters
bThe block width in bits. The default is 7 bits.
Returns
The read integer value.

Definition at line 175 of file BitIStream.hpp.

template<typename value_t >
value_t tdc::io::BitIStream::read_elias_delta ( )
inline

Definition at line 159 of file BitIStream.hpp.

template<typename value_t >
value_t tdc::io::BitIStream::read_elias_gamma ( )
inline

Definition at line 153 of file BitIStream.hpp.

template<class T >
T tdc::io::BitIStream::read_int ( size_t  amount = sizeof(T) * CHAR_BIT)
inline

Reads the integer value of the next amount bits in MSB first order.

Template Parameters
Theinteger type to read.
Parameters
amountThe bit width of the integer to read. By default, this equals the bit width of type T.
Returns
The integer value of the next amount bits in MSB first order.

Definition at line 119 of file BitIStream.hpp.

template<typename value_t >
value_t tdc::io::BitIStream::read_ternary ( )
inline

Definition at line 136 of file BitIStream.hpp.

template<typename value_t >
value_t tdc::io::BitIStream::read_unary ( )
inline

Definition at line 129 of file BitIStream.hpp.


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