15 template<
class char_type>
16 void rle_encode(std::basic_istream<char_type>& is, std::basic_ostream<char_type>& os,
size_t offset = 0) {
24 while(is.peek() == c) { ++run; is.get(); }
36 template<
class char_type>
37 void rle_decode(std::basic_istream<char_type>& is, std::basic_ostream<char_type>& os,
size_t offset = 0) {
44 size_t run = read_vbyte<size_t>(is)-offset;
45 while(run-- > 0) { os << c; }
55 Meta m(
"compressor",
"rle",
"Run Length Encoding Compressor");
Contains the text compression and encoding framework.
void write_vbyte(std::ostream &os, int_t v)
Store an integer as a bunch of bytes.
#define tdc_unlikely(x)
Provides a hint to the compiler that x is expected to resolve to false.
Base for data compressors.
virtual void decompress(Input &input, Output &output) override
Decompress the given input to the given output.
void rle_decode(std::basic_istream< char_type > &is, std::basic_ostream< char_type > &os, size_t offset=0)
Decodes a run length encoded stream.
RunLengthEncoder(Env &&env)
Env & env()
Provides access to the environment that the algorithm works in.
OutputStream as_stream() const
Creates a stream that allows for character-wise output.
An abstraction layer for algorithm output.
virtual void compress(Input &input, Output &output) override
Compress the given input to the given output.
void rle_encode(std::basic_istream< char_type > &is, std::basic_ostream< char_type > &os, size_t offset=0)
Encode a byte-stream with run length encoding each run of the same character is substituted with two ...
Local environment for a compression/encoding/decompression call.