8 namespace tdc {
namespace esp {
12 Meta m(
"slp_coder",
"plain");
28 DCHECK_GE(bit_width, 1);
29 DCHECK_LE(bit_width, 63);
34 DCHECK(slp.rules.empty());
35 DCHECK_EQ(slp.root_rule, 0);
38 bout.write_int(bit_width, 6);
41 bout.write_int(slp.root_rule, bit_width);
45 for (
auto& rule : slp.rules) {
47 DCHECK_LE(rule[0], max_val);
48 DCHECK_LE(rule[1], max_val);
49 bout.write_int(rule[0], bit_width);
50 bout.write_int(rule[1], bit_width);
57 auto bit_width = bin.
read_int<
size_t>(6);
58 bool empty = (bit_width == 0);
60 auto root_rule = bin.read_int<
size_t>(bit_width);
66 slp.root_rule = root_rule;
67 slp.rules.reserve(std::pow(2, bit_width));
70 auto a = bin.read_int<
size_t>(bit_width);
71 auto b = bin.read_int<
size_t>(bit_width);
72 auto array = std::array<size_t, 2>{{ a, b, }};
76 slp.rules.push_back(array);
Contains the text compression and encoding framework.
constexpr uint_fast8_t bits_for(size_t n)
Computes the number of bits required to store the given integer value.
size_t GRAMMAR_PD_ELLIDED_PREFIX
void encode_root_node(size_t node)
Wrapper for input streams that provides bitwise reading functionality.
void encode(DebugContext &debug, SLP &&slp, Output &output) const
Algorithm(Algorithm const &)=default
OutputStream as_stream() const
Creates a stream that allows for character-wise output.
void encode_max_value(size_t value, size_t bits)
Wrapper for output streams that provides bitwise writing functionality.
An abstraction layer for algorithm output.
SLP decode(Input &input) const
Interface for algorithms.
T read_int(size_t amount=sizeof(T) *CHAR_BIT)
Reads the integer value of the next amount bits in MSB first order.
void encode_rule(const T &rule)