tudocomp
– The TU Dortmund Compression Framework
tdc::Decoder Class Reference

Base for data decoders. More...

#include <Coder.hpp>

Inheritance diagram for tdc::Decoder:
tdc::Algorithm tdc::ArithmeticCoder::Decoder tdc::ASCIICoder::Decoder tdc::BitCoder::Decoder tdc::EliasDeltaCoder::Decoder tdc::EliasGammaCoder::Decoder tdc::HuffmanCoder::Decoder tdc::SLECoder::Decoder tdc::TernaryCoder::Decoder

Public Member Functions

 Decoder (Env &&env, std::shared_ptr< BitIStream > in)
 Constructor. More...
 
 Decoder (Env &&env, Input &in)
 Convenience constructor. More...
 
bool eof () const
 Tests whether the end of the bit input stream has been reached. More...
 
template<typename value_t >
value_t decode (const Range &r)
 Decodes an arbitrary-range integer value. More...
 
template<typename value_t >
value_t decode (const BitRange &r)
 Decodes a bit. More...
 
const std::shared_ptr< BitIStream > & stream ()
 
- Public Member Functions inherited from tdc::Algorithm
virtual ~Algorithm ()=default
 
 Algorithm (Algorithm const &)=default
 
 Algorithm (Algorithm &&)=default
 
Algorithmoperator= (Algorithm const &)=default
 
Algorithmoperator= (Algorithm &&)=default
 
 Algorithm (Env &&env)
 Instantiates an algorithm in the specified environment. More...
 
Envenv ()
 Provides access to the environment that the algorithm works in. More...
 
const Envenv () const
 

Protected Attributes

std::shared_ptr< BitIStreamm_in
 The underlying bit input stream. More...
 

Detailed Description

Base for data decoders.

Used for decoding integer values from a certain bit representation.

Definition at line 87 of file Coder.hpp.

Constructor & Destructor Documentation

◆ Decoder() [1/2]

tdc::Decoder::Decoder ( Env &&  env,
std::shared_ptr< BitIStream in 
)
inline

Constructor.

Parameters
envThe algorithm's environment.
inThe bit stream to read from.

Definition at line 98 of file Coder.hpp.

◆ Decoder() [2/2]

tdc::Decoder::Decoder ( Env &&  env,
Input in 
)
inline

Convenience constructor.

Parameters
envThe algorithm's environment.
inThe input to read from.

Definition at line 106 of file Coder.hpp.

Member Function Documentation

◆ decode() [1/2]

template<typename value_t >
value_t tdc::Decoder::decode ( const Range r)
inline

Decodes an arbitrary-range integer value.

This default implementation computes the amount of bits required to store an integer value of the given range and reads its binary representation from the input.

Template Parameters
value_tThe return value type.
Parameters
rThe value range.
Returns
The decoded integer value.

Definition at line 127 of file Coder.hpp.

◆ decode() [2/2]

template<typename value_t >
value_t tdc::Decoder::decode ( const BitRange r)
inline

Decodes a bit.

This default implementation will read exactly one bit from the input.

Template Parameters
value_tThe return value type.
Parameters
rUnused.
Returns
The decoded bit value (zero or one).

Definition at line 140 of file Coder.hpp.

◆ eof()

bool tdc::Decoder::eof ( ) const
inline

Tests whether the end of the bit input stream has been reached.

Returns
true if the end of the underlying bit stream has been reached, false otherwise.

Definition at line 113 of file Coder.hpp.

◆ stream()

const std::shared_ptr<BitIStream>& tdc::Decoder::stream ( )
inline

Definition at line 144 of file Coder.hpp.

Member Data Documentation

◆ m_in

std::shared_ptr<BitIStream> tdc::Decoder::m_in
protected

The underlying bit input stream.

Definition at line 91 of file Coder.hpp.


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