- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# zlib.h

    00001 #ifndef CRYPTOPP_ZLIB_H
    00002 #define CRYPTOPP_ZLIB_H
    00003
    00004 #include "adler32.h"
    00005 #include "zdeflate.h"
    00006 #include "zinflate.h"
    00007
    00008 NAMESPACE_BEGIN(CryptoPP)
    00009
    00010 /// ZLIB Compressor (RFC 1950)
    00011 class ZlibCompressor : public Deflator
    00012 {
    00013 public:
    00014         ZlibCompressor(BufferedTransformation *attachment=NULL, unsigned int deflateLevel=DEFAULT_DEFLATE_LEVEL, unsigned int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, bool detectUncompressible=true)
    00015                 : Deflator(attachment, deflateLevel, log2WindowSize, detectUncompressible) {}
    00016         ZlibCompressor(const NameValuePairs &parameters, BufferedTransformation *attachment=NULL)
    00017                 : Deflator(parameters, attachment) {}
    00018
    00019         unsigned int GetCompressionLevel() const;
    00020
    00021 protected:
    00022         void WritePrestreamHeader();
    00023         void ProcessUncompressedData(const byte *string, size_t length);
    00024         void WritePoststreamTail();
    00025
    00026         Adler32 m_adler32;
    00027 };
    00028
    00029 /// ZLIB Decompressor (RFC 1950)
    00030 class ZlibDecompressor : public Inflator
    00031 {
    00032 public:
    00033         typedef Inflator::Err Err;
    00034         class HeaderErr : public Err {public: HeaderErr() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: header decoding error") {}};
    00035         class Adler32Err : public Err {public: Adler32Err() : Err(DATA_INTEGRITY_CHECK_FAILED, "ZlibDecompressor: ADLER32 check error") {}};
    00036         class UnsupportedAlgorithm : public Err {public: UnsupportedAlgorithm() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: unsupported algorithm") {}};
    00037         class UnsupportedPresetDictionary : public Err {public: UnsupportedPresetDictionary() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: unsupported preset dictionary") {}};
    00038
    00039         /*! \param repeat decompress multiple compressed streams in series
    00040                 \param autoSignalPropagation 0 to turn off MessageEnd signal
    00041         */
    00042         ZlibDecompressor(BufferedTransformation *attachment = NULL, bool repeat = false, int autoSignalPropagation = -1);
    00043         unsigned int GetLog2WindowSize() const {return m_log2WindowSize;}
    00044
    00045 private:
    00046         unsigned int MaxPrestreamHeaderSize() const {return 2;}
    00047         void ProcessPrestreamHeader();
    00048         void ProcessDecompressedData(const byte *string, size_t length);
    00049         unsigned int MaxPoststreamTailSize() const {return 4;}
    00050         void ProcessPoststreamTail();
    00051
    00052         unsigned int m_log2WindowSize;
    00053         Adler32 m_adler32;
    00054 };
    00055
    00056 NAMESPACE_END
    00057
    00058 #endif