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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9.13 Checksummers ( checksummer base )<br />

1. Definition<br />

<strong>The</strong> class checksummer base is the base class for all <strong>LEDA</strong> checksummers. It cannot be<br />

instantiated. In order to avoid repeating this documentation for each derived class below<br />

we will discuss its members here.<br />

When a checksummer is used in encoding mode it can add checksums to the output stream.<br />

This is controlled by the checksums in stream flag. If this flag is set and the block size is<br />

zero (default setting) then one checksum is appended at the end of the stream. If the flag<br />

is switched on and the block size b is positive then a checksum is written for every block<br />

of b characters.<br />

When the checksummer is used in decoding mode this flag specifies whether the source<br />

stream contains checksums. If so, they will be compared against the computed checksum<br />

for the stream (or for the respective block if the block size is positive).<br />

If you use a checksummer in a coder pipe (cf. Section 9.23) then it should be the first<br />

coder in the pipe. This ensures that the checksum is computed for the original input.<br />

Finally, we want to point out that all checksummers provide fast seek operations (cf. Section<br />

9.22).<br />

#include < <strong>LEDA</strong>/coding/checksum.h ><br />

2. Creation<br />

checksummer base 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 />

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

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

3. Operations<br />

Standard Operations<br />

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

the target stream.<br />

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

the target stream.

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

Saved successfully!

Ooh no, something went wrong!