<< "] Exception: " << e.what()); \
104ERR_POST_X(subcode, Error \
105<< "[" << message << "] Unknown exception"); \
144eLevel_NoCompression = 0,
148eLevel_MediumLow = 4,
150eLevel_MediumHigh = 6,
225 const void* src_buf,
size_tsrc_len,
226 void* dst_buf,
size_tdst_size,
231 const void* src_buf,
size_tsrc_len,
232 void* dst_buf,
size_tdst_size,
242 const string& src_file,
243 const string& dst_file,
249 const string& src_file,
250 const string& dst_file,
284 virtual voidSetLevel(
ELevellevel);
285 virtual ELevelGetLevel(
void)
const;
289 virtual intGetErrorCode(
void)
const;
290 virtual stringGetErrorDescription(
void)
const;
293 virtual TFlagsGetFlags(
void)
const;
311 voidSetError(
intstatus,
const char* description = 0);
312 voidSetError(
intstatus,
const string& description);
316 virtual boolx_CompressFile(
317 const string& src_file,
323 virtual boolx_DecompressFile(
325 const string& dst_file,
334eMode_TransparentRead
379 size_tcompression_in_bufsize = 0,
380 size_tcompression_out_bufsize = 0);
386 size_tcompression_in_bufsize = 0,
387 size_tcompression_out_bufsize = 0) = 0;
437 const void*
GetData(
void) {
returnm_Data; };
446 size_tLoadFromStream(istream& is,
size_t size);
492 boolIsBusy(
void)
const;
502 size_tGetProcessedSize(
void);
503 size_tGetOutputSize(
void);
515(
const char* in_buf,
556 voidSetBusy(
boolbusy =
true);
559 voidIncreaseProcessedSize(
size_tn_bytes);
560 voidIncreaseOutputSize(
size_tn_bytes);
589 switch(GetErrCode()) {
590 caseeCompression :
return "eCompression";
591 caseeCompressionFile :
return "eCompressionFile";
610 static voidStoreUI4(
void*
buf,
unsigned long value);
613 static Uint4GetUI4(
const void*
buf);
616 static voidStoreUI2(
void*
buf,
unsigned long value);
619 static Uint2GetUI2(
const void*
buf);
690 if( busy && m_Busy ) {
692 "CCompression::SetBusy(): The compressor is busy now");
700m_ProcessedSize += n_bytes;
706m_OutputSize += n_bytes;
712 returnm_ProcessedSize;
Interface class to scan data source for seekable data chunks.
Include a standard set of the NCBI C++ Toolkit most basic headers.
@ eNoOwnership
No ownership is assumed.
virtual ~IChunkHandler(void)
Destructor.
virtual bool HaveSupport(ESupportFeature feature)=0
Check if compression have support for a specified feature.
void IncreaseProcessedSize(size_t n_bytes)
virtual ~ICompression(void)
Destructor.
CCompressionFile(const string &path, EMode mode, size_t compression_in_bufsize=0, size_t compression_out_bufsize=0)
void IncreaseOutputSize(size_t n_bytes)
ENcbiOwnership m_DictOwn
Dictionary ownership.
TFile m_File
File handler.
virtual const char * GetErrCodeString(void) const override
Translate from the error code value to its string representation.
void Reset(void)
Reset internal state.
ELevel m_Level
Compression level.
size_t GetOutputSize(void)
TFlags m_Flags
Bitwise OR of flags.
virtual EStatus Finish(char *out_buf, size_t out_size, size_t *out_avail)=0
Finish the compression/decompression process.
void SetBusy(bool busy=true)
Set/unset compressor busy flag.
size_t compression_out
compression: recommended size for output buffer
virtual long Write(const void *buf, size_t len)=0
Writes the given number of uncompressed bytes into the compressed file.
bool IsBusy(void) const
Return compressor's busy flag.
virtual void SetFlags(TFlags flags)=0
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)=0
Compress/decompress as much data as possible, and stops when the input buffer becomes empty or the ou...
virtual CVersionInfo GetVersion(void) const =0
Return name and version of the compression library.
size_t RoundUp(size_t value, size_t precision)
ELevel
Compression level.
void * TFile
Compression file handler.
virtual long Read(void *buf, size_t len)=0
Read up to "len" uncompressed bytes from the compressed file "file" into the buffer "buf".
virtual bool SetDictionary(CCompressionDictionary &dict, ENcbiOwnership own=eNoOwnership)=0
Set a dictionary for all compression/decompression operations (if supported).
NCBI_EXCEPTION_DEFAULT(CCompressionException, CCoreException)
string m_ErrorMsg
Last compressor action error message.
virtual EAction OnChunk(TPosition raw_pos, TPosition data_pos)=0
Callback method, to be implemented by the end user.
virtual TFlags GetFlags(void) const =0
const streamsize kCompressionDefaultBufSize
Default compression I/O stream buffer size.
virtual bool Close(void)=0
Flushes all pending output if necessary, closes the compressed file.
virtual int GetErrorCode(void) const =0
virtual bool Open(const string &path, EMode mode, size_t compression_in_bufsize=0, size_t compression_out_bufsize=0)=0
Opens a compressed file for reading or writing.
virtual CVersionInfo GetVersion(void) const =0
Return name and version of the compression library.
EDecompressMode m_DecompressMode
Decompress mode (Decompress/TransparentRead/Unknown)
size_t decompression_out
decompression: recommended size for output buffer
CCompressionDictionary * m_Dict
Dictionary for compression/decompression.
virtual bool CompressBuffer(const void *src_buf, size_t src_len, void *dst_buf, size_t dst_size, size_t *dst_len)=0
(De)compress the source buffer into the destination buffer.
virtual EStatus Flush(char *out_buf, size_t out_size, size_t *out_avail)=0
Flush compressed/decompressed data from the output buffer.
size_t decompression_in
decompression: recommended size for input buffer
const void * m_Data
Pointer to the dictionary data.
virtual bool DecompressFile(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)=0
int m_ErrorCode
Last compressor action error/status.
virtual bool DecompressBuffer(const void *src_buf, size_t src_len, void *dst_buf, size_t dst_size, size_t *dst_len)=0
unsigned int TFlags
Compression flags.
virtual void SetLevel(ELevel level)=0
virtual bool AllowEmptyData() const =0
Return TRUE if fAllowEmptyData flag is set for this compression.
virtual ELevel GetDefaultLevel(void) const =0
Return the default compression level for current compression algorithm.
EDecompressMode
Decompression mode (see fAllowTransparentRead flag).
const void * GetData(void)
Return pointer to the dictionary data.
size_t GetSize(void)
Return dictionary data size.
size_t m_Size
Size of the data.
size_t compression_in
compression: recommended size for input buffer
EStatus
Type of the result of all basic functions.
virtual string GetErrorDescription(void) const =0
ENcbiOwnership m_Own
Data ownership.
virtual size_t EstimateCompressionBufferSize(size_t src_len)=0
Estimate buffer size for data compression (if supported).
ESupportFeature
Supported features.
virtual ELevel GetLevel(void) const =0
size_t GetProcessedSize(void)
Uint8 TPosition
Type to store stream positions.
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)=0
(De)compress file "src_file" and put result to file "dst_file".
EMode m_Mode
File open mode.
virtual EStatus End(int abandon=0)=0
Free all dynamically allocated data structures.
virtual EStatus Init(void)=0
Initialize the internal stream state for compression/decompression.
@ eAction_Continue
Continue scanning to the next data chunk, if any.
@ eMode_Decompress
Generic decompression.
@ eMode_Unknown
Not known yet (decompress/transparent read)
@ eStatus_Overflow
Output buffer overflow - not enough output space.
@ eStatus_Error
Error has occurred. The error code can be acquired by GetErrorCode().
@ eStatus_EndOfData
Special case of eStatus_Success.
@ eStatus_Success
Everything is fine, no errors occurred.
@ eStatus_Repeat
Special value. Just need to repeat last action.
@ eCompression
Compression/decompression error.
@ eFeature_Dictionary
Check if current compression have support for dictionaries.
@ eFeature_NoCompression
Check if current compression method have a real support for eLevel_NoCompression, so it can store dat...
@ eFeature_EstimateCompressionBufferSize
Check if current compression have implementation for the EstimateCompressionBufferSize() method.
@ eMode_Read
Reading from compressed file.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
EErrCode
Error types that an application can generate.
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint16_t Uint2
2-byte (16-bit) unsigned integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
ENcbiOwnership
Ownership relations between objects.
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
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...
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4