Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

wvgzip.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 * Gzip encoder/decoder based on zlib. 00006 */ 00007 #ifndef __WVGZIP_H 00008 #define __WVGZIP_H 00009 00010 #include "wvencoder.h" 00011 #include "wvencoderstream.h" 00012 00013 struct z_stream_s; 00014 00015 /** 00016 * An encoder implementing Gzip encryption and decryption. 00017 * 00018 * When compressing: 00019 * 00020 * - On flush(), the encoded data stream is synchronized such that 00021 * all data compressed up to this point can be fully decompressed. 00022 * 00023 * - On finish(), the encoded data stream is finalized an a Gzip 00024 * end of data marker is emitted. 00025 * 00026 * 00027 * When decompressing: 00028 * 00029 * - The encoder will transition to isfinished() == true on its own 00030 * if a Gzip end of data marker is detected in the input. After 00031 * this point, no additional data can be decompressed. 00032 * 00033 * 00034 */ 00035 class WvGzipEncoder : public WvEncoder 00036 { 00037 public: 00038 enum Mode { 00039 Deflate, /*!< Compress using deflate */ 00040 Inflate /*!< Decompress using inflate */ 00041 }; 00042 00043 /** 00044 * Creates a Gzip encoder. 00045 * 00046 * "mode" is the compression mode 00047 */ 00048 WvGzipEncoder(Mode mode); 00049 virtual ~WvGzipEncoder(); 00050 00051 protected: 00052 virtual bool _encode(WvBuf &inbuf, WvBuf &outbuf, bool flush); 00053 virtual bool _finish(WvBuf &outbuf); 00054 virtual bool _reset(); 00055 00056 private: 00057 struct z_stream_s *zstr; 00058 WvInPlaceBuf tmpbuf; 00059 Mode mode; 00060 00061 void init(); 00062 void close(); 00063 void prepare(WvBuf *inbuf); 00064 bool process(WvBuf &outbuf, bool flush, bool finish); 00065 }; 00066 00067 00068 #endif // __WVGZIP_H

Generated on Tue Oct 5 01:09:20 2004 for WvStreams by doxygen 1.3.7