Example 4:
Compressing and decoding a file.
This example also demonstrates a nice feature
of the AutoDecoder:
If you query a description after the decoding,
the object tells you which combination has been used for
encoding the input.
#include <LEDA/coding/coder_util.h>
#include <LEDA/coding/compression.h>
using namespace leda;
typedef CoderPipe2<MD5SumCoder, HuffmanCoder> Coder;
int main()
{
Coder coder("foo", "bar");
coder.encode();
if (coder.fail()) std::cout << "error
encoding foo" << "\n";
AutoDecoder
auto("bar", "foo");
auto.decode();
if (auto.fail()) std::cout << "error decoding
bar" << "\n";
std::cout << "Decoding
info: " << auto.get_description() << "\n";
return 0;
} |