tudocomp
– The TU Dortmund Compression Framework
TernaryCoder.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <tudocomp/Coder.hpp>
4 
5 namespace tdc {
6 
7 class TernaryCoder : public Algorithm {
8 public:
9  inline static Meta meta() {
10  Meta m("coder", "ternary", "Ternary encoding");
11  return m;
12  }
13 
14  TernaryCoder() = delete;
15 
16  class Encoder : public tdc::Encoder {
17  public:
20 
21  template<typename value_t>
22  inline void encode(value_t v, const Range&) {
23  m_out->write_ternary(v);
24  }
25  };
26 
27  class Decoder : public tdc::Decoder {
28  public:
31 
32  template<typename value_t>
33  inline value_t decode(const Range&) {
34  return m_in->read_ternary<value_t>();
35  }
36  };
37 };
38 
39 }
40 
Represents a generic range of positive integers.
Definition: Range.hpp:16
Encoder(Env &&env, std::shared_ptr< BitOStream > out, literals_t &&literals)
Constructor.
Definition: Coder.hpp:29
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
Provides meta information about an Algorithm.
Definition: Meta.hpp:34
value_t decode(const Range &)
std::shared_ptr< BitOStream > m_out
The underlying bit output stream.
Definition: Coder.hpp:18
static Meta meta()
Definition: TernaryCoder.hpp:9
value_t decode(const Range &r)
Decodes an arbitrary-range integer value.
Definition: Coder.hpp:127
Decoder(Env &&env, std::shared_ptr< BitIStream > in)
Constructor.
Definition: Coder.hpp:98
Base for data encoders.
Definition: Coder.hpp:14
void encode(value_t v, const Range &)
TernaryCoder()=delete
void encode(value_t v, const Range &r)
Encodes an arbitrary-range integer value.
Definition: Coder.hpp:61
Base for data decoders.
Definition: Coder.hpp:87
Interface for algorithms.
Definition: Algorithm.hpp:15