1 #ifndef UTIL_COMPRESS__ZLIB_CLOUDFLARE__HPP
2 #define UTIL_COMPRESS__ZLIB_CLOUDFLARE__HPP
91 fAllowTransparentRead = (1<<0),
96 fAllowEmptyData = (1<<1),
98 fCheckFileHeader = (1<<2),
105 fWriteGZipFormat = (1<<3),
112 fAllowConcatenatedGZip = (1<<4),
114 fGZip = fCheckFileHeader | fWriteGZipFormat | fAllowConcatenatedGZip,
119 fRestoreFileAttr = (1<<5)
136 {
return ELevel(eLevel_Default); };
166 const void* src_buf,
size_t src_len,
167 void* dst_buf,
size_t dst_size,
197 const void* src_buf,
size_t src_len,
198 void* dst_buf,
size_t dst_size,
273 const string& src_file,
274 const string& dst_file,
307 const string& src_file,
308 const string& dst_file,
341 const string& src_file,
342 const string& dst_dir,
470 m_cd_WindowBits = (window_bits ==
kZlibDefaultWbits) ? GetWindowBitsDefault() : window_bits;
518 ELevel level = eLevel_Default,
524 ELevel level = eLevel_Default
656 ELevel level = eLevel_Default,
673 {
return (
GetFlags() & fAllowEmptyData) == fAllowEmptyData; }
678 char* out_buf,
size_t out_size,
719 {
return (
GetFlags() & fAllowEmptyData) == fAllowEmptyData; }
724 char* out_buf,
size_t out_size,
762 streamsize in_bufsize,
763 streamsize out_bufsize,
815 streamsize in_bufsize,
816 streamsize out_bufsize,
CZipCloudflareCompressionFile –.
CZipCloudflareCompression –.
CZipCloudflareCompressor – zlib based compressor.
CZipCloudflareDecompressor – zlib based decompressor.
CZipCloudflareStreamCompressor – zlib based compression stream processor.
CZipCloudflareStreamDecompressor – 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.
CZipCloudflareCompressor * GetCompressor(void) const
Return a pointer to compressor.
static int GetWindowBitsDefault(void)
CZipCloudflareCompressionFile(ELevel level=eLevel_Default)
Conventional constructor.
void * m_Stream
Compressor stream.
void SetStrategy(int strategy)
Compression strategy.
CZipCloudflareCompressor(ELevel level=eLevel_Default, TZipFlags flags=0)
Constructor.
virtual EStatus Finish(char *out_buf, size_t out_size, size_t *out_avail)
Finish the compression/decompression process.
static int GetMemoryLevelDefault(void)
virtual EStatus Finish(char *out_buf, size_t out_size, size_t *out_avail)
Finish the compression/decompression process.
int m_c_MemLevel
The allocation memory level for the compression.
bool m_NeedWriteHeader
Is true if needed to write a file header.
virtual ~CZipCloudflareCompression(void)
Destructor.
CZipCloudflareCompressionFile(const string &file_name, EMode mode, ELevel level=eLevel_Default, size_t compression_in_bufsize=kCompressionDefaultBufSize, size_t compression_out_bufsize=kCompressionDefaultBufSize)
Constructor.
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.
int GetWindowBits(void) const
CZipCloudflareCompression(const CZipCloudflareCompression &)
Private copy constructor to prohibit copy.
CZipCloudflareCompression(ELevel level=eLevel_Default)
Constructor.
virtual CVersionInfo GetVersion(void) const
Return name and version of the compression library.
CZipCloudflareStreamDecompressor(streamsize in_bufsize, streamsize out_bufsize, CZipCloudflareCompression::TZipFlags flags=0)
Full constructor.
CZipCloudflareCompression::TFlags TZipFlags
Bitwise OR of EFlags.
CZipCloudflareStreamDecompressor(CZipCloudflareCompression::TZipFlags flags=0)
Conventional constructor.
SFileInfo m_FileInfo
Compressed file info.
static int GetWindowBitsMin(void)
void SetWindowBits(int window_bits)
Window bits.
virtual TFlags GetFlags(void) const
Get/set flags.
const int kZlibDefaultStrategy
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.
virtual ~CZipCloudflareCompressor(void)
Destructor.
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.
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.
CNcbiFstream * m_File
File stream.
CZipCloudflareDecompressor(TZipFlags flags=0)
Constructor.
virtual EStatus Init(void)
Initialize the internal stream state for compression/decompression.
CZipCloudflareStreamCompressor(CZipCloudflareCompression::ELevel level, streamsize in_bufsize, streamsize out_bufsize, CZipCloudflareCompression::TZipFlags flags=0)
Full constructor.
static int GetWindowBitsMax(void)
void GetStreamError(void)
Get error code/description of last stream operation (m_Stream).
virtual bool AllowEmptyData() const
Return TRUE if fAllowEmptyData flag is set.
virtual long Read(void *buf, size_t len)
Read data from compressed file.
virtual long Write(const void *buf, size_t len)
Write data to compressed file.
const streamsize kCompressionDefaultBufSize
Default compression I/O stream buffer size.
string m_Cache
Buffer to cache small pieces of data.
int GetStrategy(void) const
string FormatErrorMessage(string where, size_t pos=0) const
Format string with last error description.
void SetFileInfo(const SFileInfo &info)
Set information about compressed file.
unsigned long m_CRC32
CRC32 for compressed data.
const int kZlibDefaultWbits
virtual bool HaveSupport(ESupportFeature feature)
Check if compression have support for a specified feature.
virtual bool Close(void)
Close compressed file.
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.
static int GetMemoryLevelMin(void)
virtual EStatus Flush(char *out_buf, size_t out_size, size_t *out_avail)
Flush compressed/decompressed data from the output buffer.
~CZipCloudflareCompressionFile(void)
Destructor.
unsigned int TFlags
Compression flags.
CZipCloudflareStreamCompressor(CZipCloudflareCompression::TZipFlags flags=0)
Conventional constructor.
int m_c_Strategy
The parameter to tune up a compression algorithm.
static SRecommendedBufferSizes GetRecommendedBufferSizes(size_t round_up=0)
Get recommended buffer sizes for stream/file I/O.
bool m_IsGZ
TRUE if data have gzip format.
virtual bool SetDictionary(CCompressionDictionary &dict, ENcbiOwnership own=eNoOwnership)
Set a dictionary for all compression/decompression operations.
virtual bool AllowEmptyData() const
Return TRUE if fAllowEmptyData flag is set.
const int kZlibDefaultMemLevel
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.
virtual size_t EstimateCompressionBufferSize(size_t src_len)
Estimate buffer size for data compression.
virtual EStatus End(int abandon=0)
Free all dynamically allocated data structures.
bool m_NeedCheckHeader
TRUE if needed to check to file header.
int m_cd_WindowBits
The base two logarithm of the window size.
static int GetMemoryLevelMax(void)
EFlags
Compression/decompression flags.
virtual ~CZipCloudflareDecompressor(void)
Destructor.
CZipCloudflareDecompressor * GetDecompressor(void) const
Return a pointer to decompressor.
EStatus
Type of the result of all basic functions.
static int GetStrategyMin(void)
static int GetStrategyMax(void)
EMode m_Mode
I/O mode (read/write).
CZipCloudflareCompressionFile(const CZipCloudflareCompressionFile &)
Private copy constructor to prohibit copy.
virtual EStatus Flush(char *out_buf, size_t out_size, size_t *out_avail)
Flush compressed/decompressed data from the output buffer.
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.
static bool Initialize(void)
Initialize compression library (for API compatibility, zlib don't need it).
int GetMemoryLevel(void) const
size_t m_SkipInput
Number of bytes to skip from input stream.
static int GetStrategyDefault(void)
void SetMemoryLevel(int mem_level)
Memory level.
void g_GZip_Cloudflare_ScanForChunks(CNcbiIstream &is, IChunkHandler &handler)
Get list of positions of separate gzip files in the concatenated gzip file.
virtual ELevel GetDefaultLevel(void) const
Returns default compression level for a compression algorithm.
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...
virtual EStatus Init(void)
Initialize the internal stream state for compression/decompression.
CZipCloudflareStreamCompressor(CZipCloudflareCompression::ELevel level, CZipCloudflareCompression::TZipFlags flags=0)
Conventional constructor.
string m_Cache
Buffer to cache small pieces of data.
ESupportFeature
Supported features.
virtual EStatus End(int abandon=0)
Free all dynamically allocated data structures.
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...
CCompressionIOStream * m_Stream
[De]comression stream.
#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.