1 #ifndef UTIL_COMPRESS__ZLIB__HPP
2 #define UTIL_COMPRESS__ZLIB__HPP
97 fAllowTransparentRead = (1<<0),
102 fAllowEmptyData = (1<<1),
104 fCheckFileHeader = (1<<2),
111 fWriteGZipFormat = (1<<3),
118 fAllowConcatenatedGZip = (1<<4),
120 fGZip = fCheckFileHeader | fWriteGZipFormat | fAllowConcatenatedGZip,
125 fRestoreFileAttr = (1<<5)
142 {
return ELevel(eLevel_Default); };
172 const void* src_buf,
size_t src_len,
173 void* dst_buf,
size_t dst_size,
203 const void* src_buf,
size_t src_len,
204 void* dst_buf,
size_t dst_size,
279 const string& src_file,
280 const string& dst_file,
313 const string& src_file,
314 const string& dst_file,
347 const string& src_file,
348 const string& dst_dir,
476 m_cd_WindowBits = (window_bits ==
kZlibDefaultWbits) ? GetWindowBitsDefault() : window_bits;
524 ELevel level = eLevel_Default,
530 ELevel level = eLevel_Default
662 ELevel level = eLevel_Default,
679 {
return (
GetFlags() & fAllowEmptyData) == fAllowEmptyData; }
684 char* out_buf,
size_t out_size,
725 {
return (
GetFlags() & fAllowEmptyData) == fAllowEmptyData; }
730 char* out_buf,
size_t out_size,
768 streamsize in_bufsize,
769 streamsize out_bufsize,
821 streamsize in_bufsize,
822 streamsize out_bufsize,
CZipCompressor – zlib based compressor.
CZipDecompressor – zlib based decompressor.
CZipStreamCompressor – zlib based compression stream processor.
CZipStreamDecompressor – zlib based decompression stream processor.
Interface class to scan data source for seekable data chunks.
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
@ eNoOwnership
No ownership is assumed.
virtual long Write(const void *buf, size_t len)
Write data to compressed file.
virtual bool DecompressFileIntoDir(const string &src_file, const string &dst_dir, size_t file_io_bufsize=kCompressionDefaultBufSize, size_t decompression_in_bufsize=kCompressionDefaultBufSize, size_t decompression_out_bufsize=kCompressionDefaultBufSize)
Decompress file into specified directory.
void SetFileInfo(const SFileInfo &info)
Set information about compressed file.
void SetMemoryLevel(int mem_level)
Memory level.
void g_GZip_ScanForChunks(CNcbiIstream &is, IChunkHandler &handler)
Get list of positions of separate gzip files in the concatenated gzip file.
void GetStreamError(void)
Get error code/description of last stream operation (m_Stream).
static SRecommendedBufferSizes GetRecommendedBufferSizes(size_t round_up=0)
Get recommended buffer sizes for stream/file I/O.
virtual size_t EstimateCompressionBufferSize(size_t src_len)
Estimate buffer size for data compression.
void SetWindowBits(int window_bits)
Window bits.
unsigned long m_CRC32
CRC32 for compressed data.
virtual EStatus End(int abandon=0)
Free all dynamically allocated data structures.
bool m_NeedWriteHeader
Is true if needed to write a file header.
size_t m_SkipInput
Number of bytes to skip from input stream.
virtual bool Open(const string &file_name, EMode mode, size_t compression_in_bufsize=kCompressionDefaultBufSize, size_t compression_out_bufsize=kCompressionDefaultBufSize)
Opens a compressed file for reading or writing.
CZipStreamDecompressor(CZipCompression::TZipFlags flags=0)
Conventional constructor.
CZipCompressionFile(const CZipCompressionFile &)
Private copy constructor to prohibit copy.
string m_Cache
Buffer to cache small pieces of data.
virtual EStatus Flush(char *out_buf, size_t out_size, size_t *out_avail)
Flush compressed/decompressed data from the output buffer.
void * m_Stream
Compressor stream.
static int GetMemoryLevelMax(void)
virtual TFlags GetFlags(void) const
Get/set flags.
const int kZlibDefaultStrategy
CZipCompressor(ELevel level=eLevel_Default, TZipFlags flags=0)
Constructor.
static int GetMemoryLevelMin(void)
static int GetWindowBitsMin(void)
int GetMemoryLevel(void) const
virtual EStatus Init(void)
Initialize the internal stream state for compression/decompression.
CZipCompression::TFlags TZipFlags
Bitwise OR of EFlags.
virtual EStatus Finish(char *out_buf, size_t out_size, size_t *out_avail)
Finish the compression/decompression process.
virtual EStatus End(int abandon=0)
Free all dynamically allocated data structures.
virtual bool CompressFile(const string &src_file, const string &dst_file, size_t file_io_bufsize=kCompressionDefaultBufSize, size_t compression_in_bufsize=kCompressionDefaultBufSize, size_t compression_out_bufsize=kCompressionDefaultBufSize)
Compress file.
virtual long Read(void *buf, size_t len)
Read data from compressed file.
const streamsize kCompressionDefaultBufSize
Default compression I/O stream buffer size.
virtual EStatus Flush(char *out_buf, size_t out_size, size_t *out_avail)
Flush compressed/decompressed data from the output buffer.
const int kZlibDefaultCompression
CZipDecompressor * GetDecompressor(void) const
Return a pointer to decompressor.
virtual bool DecompressFile(const string &src_file, const string &dst_file, size_t file_io_bufsize=kCompressionDefaultBufSize, size_t decompression_in_bufsize=kCompressionDefaultBufSize, size_t decompression_out_bufsize=kCompressionDefaultBufSize)
Decompress file.
CZipStreamCompressor(CZipCompression::ELevel level, CZipCompression::TZipFlags flags=0)
Conventional constructor.
SFileInfo m_FileInfo
Compressed file info.
static int GetWindowBitsMax(void)
CNcbiFstream * m_File
File stream.
virtual bool CompressBuffer(const void *src_buf, size_t src_len, void *dst_buf, size_t dst_size, size_t *dst_len)
Compress data in the buffer.
int m_cd_WindowBits
The base two logarithm of the window size.
virtual bool AllowEmptyData() const
Return TRUE if fAllowEmptyData flag is set.
CZipCompressionFile(const string &file_name, EMode mode, ELevel level=eLevel_Default, size_t compression_in_bufsize=kCompressionDefaultBufSize, size_t compression_out_bufsize=kCompressionDefaultBufSize)
Constructor.
virtual EStatus Process(const char *in_buf, size_t in_len, char *out_buf, size_t out_size, size_t *in_avail, size_t *out_avail)
Compress/decompress as much data as possible, and stops when the input buffer becomes empty or the ou...
int m_c_MemLevel
The allocation memory level for the compression.
int GetWindowBits(void) const
CZipDecompressor(TZipFlags flags=0)
Constructor.
const int kZlibDefaultWbits
CCompressionIOStream * m_Stream
[De]comression stream.
virtual bool Open(const string &file_name, EMode mode, SFileInfo *info, size_t compression_in_bufsize=kCompressionDefaultBufSize, size_t compression_out_bufsize=kCompressionDefaultBufSize)
Opens a compressed file for reading or writing.
CZipCompression(ELevel level=eLevel_Default)
Constructor.
virtual ~CZipCompression(void)
Destructor.
~CZipCompressionFile(void)
Destructor.
string m_Cache
Buffer to cache small pieces of data.
bool m_IsGZ
TRUE if data have gzip format.
unsigned int TFlags
Compression flags.
virtual ~CZipCompressor(void)
Destructor.
CZipStreamCompressor(CZipCompression::TZipFlags flags=0)
Conventional constructor.
virtual EStatus Process(const char *in_buf, size_t in_len, char *out_buf, size_t out_size, size_t *in_avail, size_t *out_avail)
Compress/decompress as much data as possible, and stops when the input buffer becomes empty or the ou...
const int kZlibDefaultMemLevel
int m_c_Strategy
The parameter to tune up a compression algorithm.
virtual EStatus Finish(char *out_buf, size_t out_size, size_t *out_avail)
Finish the compression/decompression process.
virtual bool SetDictionary(CCompressionDictionary &dict, ENcbiOwnership own=eNoOwnership)
Set a dictionary for all compression/decompression operations.
virtual bool Close(void)
Close compressed file.
virtual bool AllowEmptyData() const
Return TRUE if fAllowEmptyData flag is set.
virtual CVersionInfo GetVersion(void) const
Return name and version of the compression library.
static int GetStrategyMax(void)
virtual bool HaveSupport(ESupportFeature feature)
Check if compression have support for a specified feature.
string FormatErrorMessage(string where, size_t pos=0) const
Format string with last error description.
virtual ELevel GetDefaultLevel(void) const
Returns default compression level for a compression algorithm.
EStatus
Type of the result of all basic functions.
void SetStrategy(int strategy)
Compression strategy.
static int GetStrategyMin(void)
virtual EStatus Init(void)
Initialize the internal stream state for compression/decompression.
bool m_NeedCheckHeader
TRUE if needed to check to file header.
static int GetWindowBitsDefault(void)
CZipStreamDecompressor(streamsize in_bufsize, streamsize out_bufsize, CZipCompression::TZipFlags flags=0)
Full constructor.
CZipCompressionFile(ELevel level=eLevel_Default)
Conventional constructor.
static bool Initialize(void)
Initialize compression library (for API compatibility, zlib don't need it).
int GetStrategy(void) const
static int GetMemoryLevelDefault(void)
CZipCompression(const CZipCompression &)
Private copy constructor to prohibit copy.
CZipCompressor * GetCompressor(void) const
Return a pointer to compressor.
static int GetStrategyDefault(void)
CZipStreamCompressor(CZipCompression::ELevel level, streamsize in_bufsize, streamsize out_bufsize, CZipCompression::TZipFlags flags=0)
Full constructor.
EMode m_Mode
I/O mode (read/write).
virtual ~CZipDecompressor(void)
Destructor.
ESupportFeature
Supported features.
EFlags
Compression/decompression flags.
virtual bool DecompressBuffer(const void *src_buf, size_t src_len, void *dst_buf, size_t dst_size, size_t *dst_len)
Decompress data in the buffer.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::fstream CNcbiFstream
Portable alias for fstream.
ENcbiOwnership
Ownership relations between objects.
strategy
Block allocation strategies.
NCBI_XUTIL_EXPORT
Parameter to control printing diagnostic message about conversion of static array data from a differe...
Structure to get information about recommended buffer sizes for file/stream I/O to tune up a (de)comp...
Structure to keep compressed file information.