2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * Gzip encoder/decoder based on zlib.
10 #include "wvencoder.h"
11 #include "wvencoderstream.h"
16 * An encoder implementing Gzip encryption and decryption.
20 * - On flush(), the encoded data stream is synchronized such that
21 * all data compressed up to this point can be fully decompressed.
23 * - On finish(), the encoded data stream is finalized an a Gzip
24 * end of data marker is emitted.
29 * - The encoder will transition to isfinished() == true on its own
30 * if a Gzip end of data marker is detected in the input. After
31 * this point, no additional data can be decompressed.
35 class WvGzipEncoder
: public WvEncoder
39 Deflate
, /*!< Compress using deflate */
40 Inflate
/*!< Decompress using inflate */
44 * Creates a Gzip encoder.
46 * "mode" is the compression mode
48 WvGzipEncoder(Mode mode
, size_t _out_limit
= 0);
49 virtual ~WvGzipEncoder();
52 * Limit the amount of output produced in one call to encode().
53 * Defaults to 0, meaning no limit (empty the input buffer).
58 * Continue decompression if errors are found.
59 * If true, upon running into a decompression error, the encoder will
60 * seek to the next unbroken block. Most useful if at least some blocks
61 * are fully flushed (see 'full_flush' below). Defaults to false.
62 * Note that it may be impossible to ignore really bad decompression
63 * errors, in which case the encoder will go !isok(), as it would
64 * if this boolean is false.
66 bool ignore_decompression_errors
;
70 * Makes the encoder use Z_FULL_FLUSH instead of Z_SYNC_FLUSH, which
71 * resets the compression state to improve chances of recovering
72 * corrupted compressed data. Degrades compression, so don't use it too
73 * often. Defaults to false.
78 virtual bool _encode(WvBuf
&inbuf
, WvBuf
&outbuf
, bool flush
);
79 virtual bool _finish(WvBuf
&outbuf
);
80 virtual bool _reset();
83 struct z_stream_s
*zstr
;
90 void prepare(WvBuf
*inbuf
);
91 bool process(WvBuf
&outbuf
, bool flush
, bool finish
);