31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9.24 Automatic Decoder ( AutoDecoder )<br />

1. Definition<br />

An instance C of AutoDecoder can be used for decoding any stream that has been encoded<br />

with a <strong>LEDA</strong> coder or a pipe of <strong>LEDA</strong> coders. Thus this class is useful if you want to<br />

decode a stream and have forgotten which combination of coders you have used to encode<br />

it. This class is also helpful if the encoding method is not known at compile-time. <strong>The</strong>n<br />

the decoding method cannot be fixed at compile-time either but it has to be determined<br />

at run-time.<br />

#include < <strong>LEDA</strong>/coding/auto decoder.h ><br />

2. Types<br />

In order to facilitate the usage of AutoDecoder with decoding istream we provide the<br />

typedef autodecoding istream as a shorthand for decoding istream.<br />

3. Creation<br />

AutoDecoder C(streambuf ∗ src stream = 0, streambuf ∗ tgt stream = 0,<br />

bool own streams = false);<br />

creates an instance C which uses the given source and target<br />

streams. If own streams is set, then C is responsible for the destruction<br />

of the streams, otherwise the pointers src stream and tgt stream<br />

must be valid during the life-time of C.<br />

AutoDecoder<br />

C(const char ∗ src file name, const char ∗ tgt file name);<br />

creates an instance C which uses file-streams for input and output.<br />

4. Operations<br />

Standard Operations<br />

void C.decode( ) decodes the source stream and writes the output to<br />

the target stream.<br />

streambuf ∗ C.get src stream( ) returns the current source stream.<br />

uint32 C.decode memory chunk(const char ∗ in buf , uint32 in len, char ∗ out buf ,<br />

uint32 out len)<br />

decodes the memory chunk starting at in buf with<br />

size in len into the buffer starting at out buf with size<br />

out len. <strong>The</strong> function returns actual length of the<br />

encoded chunk which may be smaller than out len. If<br />

the output buffer is too small for the decoded data<br />

the failure flag will be set (see below).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!