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

Base for data encoders. More...

#include <Coder.hpp>

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

Public Member Functions

template<typename literals_t >
 Encoder (Env &&env, std::shared_ptr< BitOStream > out, literals_t &&literals)
 Constructor. More...
 
template<typename literals_t >
 Encoder (Env &&env, Output &out, literals_t &&literals)
 Convenience constructor. More...
 
template<typename value_t >
void encode (value_t v, const Range &r)
 Encodes an arbitrary-range integer value. More...
 
template<typename value_t >
void encode (value_t v, const BitRange &r)
 Encodes a bit. More...
 
const std::shared_ptr< BitOStream > & 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< BitOStreamm_out
 The underlying bit output stream. More...
 

Detailed Description

Base for data encoders.

Used for encoding integer values to a certain bit representation.

Definition at line 14 of file Coder.hpp.

Constructor & Destructor Documentation

◆ Encoder() [1/2]

template<typename literals_t >
tdc::Encoder::Encoder ( Env &&  env,
std::shared_ptr< BitOStream out,
literals_t &&  literals 
)
inline

Constructor.

Template Parameters
literals_tThe literal iterator type.
Parameters
envThe algorithm's environment.
outThe bit stream to write to.
literalsThe literal iterator.

Definition at line 29 of file Coder.hpp.

◆ Encoder() [2/2]

template<typename literals_t >
tdc::Encoder::Encoder ( Env &&  env,
Output out,
literals_t &&  literals 
)
inline

Convenience constructor.

Template Parameters
literals_tThe literal iterator type.
Parameters
envThe algorithm's environment.
outThe output to write to.
literalsThe literal iterator.

Definition at line 44 of file Coder.hpp.

Member Function Documentation

◆ encode() [1/2]

template<typename value_t >
void tdc::Encoder::encode ( value_t  v,
const Range r 
)
inline

Encodes an arbitrary-range integer value.

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

Template Parameters
value_tThe input value type.
Parameters
vThe integer value to encode.
rThe value range.

Definition at line 61 of file Coder.hpp.

◆ encode() [2/2]

template<typename value_t >
void tdc::Encoder::encode ( value_t  v,
const BitRange r 
)
inline

Encodes a bit.

This default implementation will write exactly one bit to the output. A zero bit is written if the given value is zero, a one bit is written otherwise.

Template Parameters
value_tThe input value type.
Parameters
vThe value to encode.
rUnused.

Definition at line 75 of file Coder.hpp.

◆ stream()

const std::shared_ptr<BitOStream>& tdc::Encoder::stream ( )
inline

Definition at line 79 of file Coder.hpp.

Member Data Documentation

◆ m_out

std::shared_ptr<BitOStream> tdc::Encoder::m_out
protected

The underlying bit output stream.

Definition at line 18 of file Coder.hpp.


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