8 template<
typename string_coder_t>
14 Meta m(
"lz78u_strategy",
"streaming");
19 template<
typename ref_coder_t>
21 typename ref_coder_t::Encoder m_ref_coder;
22 typename string_coder_t::Encoder m_string_coder;
24 std::shared_ptr<BitOStream> m_out;
29 std::shared_ptr<BitOStream> out):
32 m_string_coder(
std::move(this->
env().env_for_option(
"string_coder")), out,
NoLiterals()),
36 DVLOG(2) <<
"encode ref: " << ref;
37 m_ref_coder.encode(ref, ref_range);
41 DVLOG(2) <<
"encode char: '" << c <<
"' (" << int(c) <<
")";
53 DVLOG(2) <<
"encode sep: " << int(val == 1);
54 m_out->write_bit(val);
58 template<
typename ref_coder_t>
60 typename ref_coder_t::Decoder m_ref_coder;
61 typename string_coder_t::Decoder m_string_coder;
63 std::vector<uliteral_t> m_buf;
64 std::shared_ptr<BitIStream> m_in;
68 std::shared_ptr<BitIStream> in):
70 m_ref_coder(
std::move(ref_env), in),
71 m_string_coder(
std::move(this->
env().env_for_option(
"string_coder")), in),
75 return m_ref_coder.template decode<size_t>(ref_range);
79 return m_string_coder.template decode<uliteral_t>(
literal_r);
85 auto c = decode_char();
95 return m_in->read_bit();
99 return m_ref_coder.eof();
Represents a generic range of positive integers.
Contains the text compression and encoding framework.
void encode_str(View str)
A const view into a slice of memory.
uint8_t uliteral_t
Type to represent signed single literals.
void encode_char(uliteral_t c)
void encode_sep(bool val)
Decompression(Env &&env, Env &&ref_env, std::shared_ptr< BitIStream > in)
Algorithm(Algorithm const &)=default
Env & env()
Provides access to the environment that the algorithm works in.
An empty literal iterator that yields no literals whatsoever.
constexpr auto literal_r
Global predefined reange for literals.
Compression(Env &&env, Env &&ref_env, std::shared_ptr< BitOStream > out)
size_t decode_ref(Range ref_range)
void clear()
Sets the size to 0.
void encode_ref(size_t ref, Range ref_range)
Local environment for a compression/encoding/decompression call.
Interface for algorithms.