⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zlib.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
    // in this case Read() will directly read from the file without    // decompression.     // Return TRUE if file was opened succesfully or FALSE otherwise.    virtual bool Open(const string& file_name, EMode mode);    // Read up to "len" uncompressed bytes from the compressed file "file"    // into the buffer "buf". If the input file was not in gzip format,    // gzread copies the given number of bytes into the buffer.     // Return the number of bytes actually read    // (0 for end of file, -1 for error).    // The number of really readed bytes can be less than requested.    virtual int Read(void* buf, int len);    // Writes the given number of uncompressed bytes into the compressed file.    // Return the number of bytes actually written or -1 for error.    virtual int Write(const void* buf, int len);    // Flushes all pending output if necessary, closes the compressed file.    // Return TRUE on success, FALSE on error.    virtual bool Close(void);};////////////////////////////////////////////////////////////////////////////////// CZipCompressor class//class NCBI_XUTIL_EXPORT CZipCompressor : public CZipCompression,                                         public CCompressionProcessor{public:    // 'ctors    CZipCompressor(        ELevel               level       = eLevel_Default,        int                  window_bits = MAX_WBITS,        int                  mem_level   = DEF_MEM_LEVEL,        int                  strategy    = Z_DEFAULT_STRATEGY,        CCompression::TFlags flags       = 0    );    virtual ~CZipCompressor(void);protected:    virtual EStatus Init   (void);    virtual EStatus Process(const char* in_buf,  unsigned long  in_len,                            char*       out_buf, unsigned long  out_size,                            /* out */            unsigned long* in_avail,                            /* out */            unsigned long* out_avail);    virtual EStatus Flush  (char*       out_buf, unsigned long  out_size,                            /* out */            unsigned long* out_avail);    virtual EStatus Finish (char*       out_buf, unsigned long  out_size,                            /* out */            unsigned long* out_avail);    virtual EStatus End    (void);private:    unsigned long m_CRC32;  // CRC32 for compressed data    string        m_Cache;  // Buffer to cache small pieces of data    bool          m_NeedWriteHeader;                            // Is true if needed to write a file header};////////////////////////////////////////////////////////////////////////////////// CZipDecompressor class//class NCBI_XUTIL_EXPORT CZipDecompressor : public CZipCompression,                                           public CCompressionProcessor{public:    // 'ctors    CZipDecompressor(        int                  window_bits = MAX_WBITS,        CCompression::TFlags flags       = 0    );    virtual ~CZipDecompressor(void);protected:    virtual EStatus Init   (void);     virtual EStatus Process(const char* in_buf,  unsigned long  in_len,                            char*       out_buf, unsigned long  out_size,                            /* out */            unsigned long* in_avail,                            /* out */            unsigned long* out_avail);    virtual EStatus Flush  (char*       out_buf, unsigned long  out_size,                            /* out */            unsigned long* out_avail);    virtual EStatus Finish (char*       out_buf, unsigned long  out_size,                            /* out */            unsigned long* out_avail);    virtual EStatus End    (void);private:    bool   m_NeedCheckHeader; // Is true if needed to check at file header    string m_Cache;           // Buffer to cache small pieces of data};////////////////////////////////////////////////////////////////////////////////// Compression/decompression stream processors (for details see "stream.hpp")//class NCBI_XUTIL_EXPORT CZipStreamCompressor    : public CCompressionStreamProcessor{public:    // Full constructor    CZipStreamCompressor(        CCompression::ELevel  level,        streamsize            in_bufsize,        streamsize            out_bufsize,        int                   window_bits,        int                   mem_level,        int                   strategy,        CCompression::TFlags  flags        )         : CCompressionStreamProcessor(              new CZipCompressor(level,window_bits,mem_level,strategy,flags),              eDelete, in_bufsize, out_bufsize)    {}    // Conventional constructors    CZipStreamCompressor(        CCompression::ELevel  level,        CCompression::TFlags  flags = 0        )        : CCompressionStreamProcessor(              new CZipCompressor(level, MAX_WBITS, DEF_MEM_LEVEL,                                 Z_DEFAULT_STRATEGY, flags),              eDelete, kCompressionDefaultBufSize, kCompressionDefaultBufSize)    {}    CZipStreamCompressor(CCompression::TFlags flags = 0)        : CCompressionStreamProcessor(              new CZipCompressor(CCompression::eLevel_Default, MAX_WBITS,                                 DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, flags),              eDelete, kCompressionDefaultBufSize, kCompressionDefaultBufSize)    {}};class NCBI_XUTIL_EXPORT CZipStreamDecompressor    : public CCompressionStreamProcessor{public:    // Full constructor    CZipStreamDecompressor(        streamsize            in_bufsize,        streamsize            out_bufsize,        int                   window_bits,        CCompression::TFlags  flags        )        : CCompressionStreamProcessor(               new CZipDecompressor(window_bits,flags),              eDelete, in_bufsize, out_bufsize)    {}    // Conventional constructor    CZipStreamDecompressor(CCompression::TFlags flags = 0)        : CCompressionStreamProcessor(               new CZipDecompressor(MAX_WBITS, flags),              eDelete, kCompressionDefaultBufSize, kCompressionDefaultBufSize)    {}};END_NCBI_SCOPE/* @} *//* * =========================================================================== * $Log: zlib.hpp,v $ * Revision 1000.2  2004/06/01 19:39:26  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.10 * * Revision 1.10  2004/05/14 15:16:46  vakatov * Take into account only USE_LOCAL_ZLIB, and not NCBI_COMPILER_MSVC * * Revision 1.9  2004/05/10 11:56:24  ivanov * Added gzip file format support * * Revision 1.8  2004/04/19 14:17:54  ivanov * Added gzip file format support into stream decompressor * * Revision 1.7  2004/04/05 16:55:13  ucko * Include the internal zlib.h when using MSVC until its build system * catches up. * * Revision 1.6  2004/04/05 15:54:12  ucko * Default to using external versions of zlib,bzlib, and libpcre if available. * * Revision 1.5  2003/07/15 15:45:45  ivanov * Improved error diagnostics * * Revision 1.4  2003/07/10 16:22:27  ivanov * Added buffer size parameter into [De]CompressFile() functions. * Cosmetic changes. * * Revision 1.3  2003/06/17 15:48:59  ivanov * Removed all standalone compression/decompression I/O classes. * Added CZipStream[De]compressor classes. Now all zlib-based I/O stream * classes can be constructed using unified CCompression[I/O]Stream * (see stream.hpp) and CZipStream[De]compressor classes. * * Revision 1.2  2003/06/03 20:09:54  ivanov * The Compression API redesign. Added some new classes, rewritten old. * * Revision 1.1  2003/04/07 20:42:11  ivanov * Initial revision * * =========================================================================== */#endif  /* UTIL_COMPRESS__ZLIB__HPP */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -