20 Meta m(
"coder",
"ascii",
"Simple ASCII encoding");
33 template<
typename value_t>
37 for(uint8_t c : s.str())
m_out->write_int(c);
38 m_out->write_int(
':');
41 template<
typename value_t>
43 m_out->write_int(uint8_t(v));
46 template<
typename value_t>
48 m_out->write_int(v ?
'1' :
'0');
57 template<
typename value_t>
59 std::ostringstream os;
60 for(uint8_t c = m_in->read_int<uint8_t>();
62 c = m_in->read_int<uint8_t>()) {
67 std::string s = os.str();
70 std::istringstream is(s);
75 template<
typename value_t>
77 return value_t(m_in->read_int<uint8_t>());
80 template<
typename value_t>
82 uint8_t b = m_in->read_int<uint8_t>();
89 inline void ASCIICoder::Encoder::encode<uliteral_t>(
uliteral_t v,
const Range& r) {
Represents a generic range of positive integers.
Encoder(Env &&env, std::shared_ptr< BitOStream > out, literals_t &&literals)
Constructor.
Contains the text compression and encoding framework.
Represents the range of valid tdc::uliteral_t values.
Represents a compiler-level fixed range.
Decodes data from an ASCII character stream.
value_t decode(const LiteralRange &)
uint8_t uliteral_t
Type to represent signed single literals.
void encode(value_t v, const BitRange &)
void encode(value_t v, const Range &)
Defines data encoding to and decoding from a stream of ASCII characters.
value_t decode(const BitRange &)
static Meta meta()
Yields the coder's meta information.
std::shared_ptr< BitOStream > m_out
The underlying bit output stream.
Decoder(Env &&env, std::shared_ptr< BitIStream > in)
Constructor.
value_t decode(const Range &)
void encode(value_t v, const LiteralRange &)
Interface for algorithms.
Encodes data to an ASCII character stream.