Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
CZipCompressor Class Referenceabstract

#include <ZipCompressor.h>

Inheritance diagram for CZipCompressor:
Inheritance graph

Classes

struct  COptions
 
class  COptionsMap
 

Public Types

enum  CompressionLevel { levelDefault = -1, levelStore = 0, levelFastest = 1, levelBest = 9 }
 
enum  CompressionMethod { methodStore = 0, methodDeflate = 8, methodBzip2 = 12, methodWinZipAes = 99 }
 
enum  CompressorType { typeDeflate = 1, typeBzip2, typePPMd }
 

Public Member Functions

virtual bool CanProcess (WORD uMethod)=0
 
virtual void Compress (const void *pBuffer, DWORD uSize)=0
 
virtual DWORD Decompress (void *pBuffer, DWORD uSize)=0
 
virtual void FinishCompression (bool bAfterException)
 
virtual void FinishDecompression (bool bAfterException)
 
virtual const COptionsGetOptions () const
 
virtual void InitCompression (int iLevel, CZipFileHeader *pFile, CZipCryptograph *pCryptograph)
 
virtual void InitDecompression (CZipFileHeader *pFile, CZipCryptograph *pCryptograph)
 
void UpdateOptions (const COptionsMap &optionsMap)
 

Static Public Member Functions

static CZipCompressorCreateCompressor (WORD uMethod, CZipStorage *pStorage)
 
static bool IsCompressionSupported (WORD uCompressionMethod)
 

Public Attributes

ZIP_SIZE_TYPE m_uComprLeft
 The number of bytes left to compress.
 
DWORD m_uCrc32
 The CRC32 file checksum.
 
ZIP_SIZE_TYPE m_uUncomprLeft
 The number of bytes left to decompress.
 

Protected Member Functions

virtual int ConvertInternalError (int iErr) const
 
 CZipCompressor (CZipStorage *pStorage)
 
DWORD FillBuffer ()
 
void FlushWriteBuffer ()
 
void InitBuffer ()
 
void ReleaseBuffer ()
 
void ThrowError (int iErr, bool bInternal=false)
 
void UpdateCrc (const void *pBuffer, DWORD uSize)
 
void UpdateFileCrc (const void *pBuffer, DWORD uSize)
 
virtual void UpdateOptions (const COptions *pOptions)
 
void WriteBuffer (char *pBuffer, DWORD uSize)
 

Protected Attributes

CZipAutoBuffer m_pBuffer
 A buffer that receives compressed data or provides data for decompression.
 
CZipCryptographm_pCryptograph
 The current cryptograph.
 
CZipFileHeaderm_pFile
 The file header being compressed or decompressed.
 
CZipStoragem_pStorage
 The current storage object.
 

Detailed Description

A base class for compressors used in compression and decompression of data.

Definition at line 41 of file ZipCompressor.h.

Member Enumeration Documentation

The compression level.

Enumerator:
levelDefault 

The default compression level (equals 6 for deflate).

levelStore 

No compression used. Data is stored.

levelFastest 

The fastest compression. The compression ratio is the lowest (apart from levelStore).

levelBest 

The highest compression ratio. It's usually the slowest one.

Definition at line 80 of file ZipCompressor.h.

The compression method.

Enumerator:
methodStore 

A file is stored, not compressed.

methodDeflate 

The deflate compression method.

methodBzip2 

The bzip2 compression method.

See Also
Compressing Data
methodWinZipAes 

This value means that WinZip AES encryption is used. The original compression method is stored in a WinZip extra field. It is only an informational value - you cannot set it as a compression method. The ZipArchive Library handles this value internally.

See Also
Encryption Methods: How to Best Protect Your Data

Definition at line 91 of file ZipCompressor.h.

The type of a compressor.

Enumerator:
typeDeflate 

Deflate compression (default in zip archives).

typeBzip2 

Bzip2 compression.

typePPMd 

PPMd compression.

Definition at line 70 of file ZipCompressor.h.

Constructor & Destructor Documentation

CZipCompressor::CZipCompressor ( CZipStorage pStorage)
inlineprotected

Initializes a new instance of the CZipCompressor class.

Parameters
pStorageThe current storage object.

Definition at line 56 of file ZipCompressor.h.

Member Function Documentation

virtual bool CZipCompressor::CanProcess ( WORD  uMethod)
pure virtual

Returns the value indicating whether the current CZipCompressor object supports the given compression method.

Parameters
uMethodThe compression method. It can be one of the CompressionMethod values.
Returns
true, if the compression method is supported; false otherwise.

Implemented in ZipArchiveLib::CDeflateCompressor.

virtual void CZipCompressor::Compress ( const void *  pBuffer,
DWORD  uSize 
)
pure virtual

Compresses the given data.

Parameters
pBufferThe buffer that holds the data to compress.
uSizeThe size of pBuffer.
See Also
InitCompression
FinishCompression

Implemented in ZipArchiveLib::CDeflateCompressor.

virtual int CZipCompressor::ConvertInternalError ( int  iErr) const
inlineprotectedvirtual

Converts an internal error code of the compressor to the ZipArchive Library error code.

Parameters
iErrAn internal error code.
Returns
A ZipArchive Library error code.

Reimplemented in ZipArchiveLib::CDeflateCompressor.

Definition at line 493 of file ZipCompressor.h.

static CZipCompressor* CZipCompressor::CreateCompressor ( WORD  uMethod,
CZipStorage pStorage 
)
static

A factory method that creates an appropriate compressor for the given compression method.

Parameters
uMethodThe compression method to create a compressor for. It can be one of the CompressionMethod values.
pStorageThe current storage object.
virtual DWORD CZipCompressor::Decompress ( void *  pBuffer,
DWORD  uSize 
)
pure virtual

Decompresses the given data.

Parameters
pBufferThe buffer that receives the decompressed data.
uSizeThe size of pBuffer.
Returns
The number of bytes decompressed and written to pBuffer.
Note
This method should be called repeatedly until it returns 0.
See Also
InitDecompression
FinishDecompression

Implemented in ZipArchiveLib::CDeflateCompressor.

DWORD CZipCompressor::FillBuffer ( )
inlineprotected

Fills the read buffer.

Returns
The number of bytes read.

Definition at line 449 of file ZipCompressor.h.

virtual void CZipCompressor::FinishCompression ( bool  bAfterException)
inlinevirtual

The method called at the end of the compression process.

Parameters
bAfterExceptionSet to true, if an exception occurred before or to false otherwise.
See Also
InitCompression
Compress

Reimplemented in ZipArchiveLib::CDeflateCompressor.

Definition at line 319 of file ZipCompressor.h.

virtual void CZipCompressor::FinishDecompression ( bool  bAfterException)
inlinevirtual

The method called at the end of the decompression process.

Parameters
bAfterExceptionSet to true, if an exception occurred before or to false otherwise.
See Also
InitDecompression
Decompress

Reimplemented in ZipArchiveLib::CDeflateCompressor.

Definition at line 332 of file ZipCompressor.h.

void CZipCompressor::FlushWriteBuffer ( )
inlineprotected

Flushes data in the buffer into the storage, encrypting the data if needed.

Definition at line 419 of file ZipCompressor.h.

virtual const COptions* CZipCompressor::GetOptions ( ) const
inlinevirtual

Returns the current options of the compressor.

Returns
The current options for the compressor.
See Also
Compressing Data
CZipArchive::SetCompressionOptions
UpdateOptions

Reimplemented in ZipArchiveLib::CDeflateCompressor.

Definition at line 347 of file ZipCompressor.h.

void CZipCompressor::InitBuffer ( )
protected

Initializes the internal buffer.

See Also
ReleaseBuffer
virtual void CZipCompressor::InitCompression ( int  iLevel,
CZipFileHeader pFile,
CZipCryptograph pCryptograph 
)
inlinevirtual

The method called when a new file is opened for compression.

Parameters
iLevelThe compression level.
pFileThe file being compressed.
pCryptographThe current CZipCryptograph. It can be NULL, if no encryption is used.
See Also
Compress
FinishCompression

Reimplemented in ZipArchiveLib::CDeflateCompressor.

Definition at line 237 of file ZipCompressor.h.

virtual void CZipCompressor::InitDecompression ( CZipFileHeader pFile,
CZipCryptograph pCryptograph 
)
inlinevirtual

The method called when a new file is opened for extraction.

Parameters
pFileThe file being extracted.
pCryptographThe current CZipCryptograph. It can be NULL, if no decryption is used.
See Also
Decompress
FinishDecompression

Reimplemented in ZipArchiveLib::CDeflateCompressor, and ZipArchiveLib::CBaseLibCompressor.

Definition at line 259 of file ZipCompressor.h.

static bool CZipCompressor::IsCompressionSupported ( WORD  uCompressionMethod)
inlinestatic

Returns the value indicating whether the given compression method is supported by the ZipArchive Library.

Parameters
uCompressionMethodThe compression method. It can be one of the CompressionMethod values.
Returns
true, if the compression method is supported, false otherwise.

Definition at line 197 of file ZipCompressor.h.

void CZipCompressor::ReleaseBuffer ( )
inlineprotected

Releases the internal buffer.

See Also
InitBuffer

Definition at line 479 of file ZipCompressor.h.

void CZipCompressor::ThrowError ( int  iErr,
bool  bInternal = false 
)
inlineprotected

Throws an exception with a given error code.

Parameters
iErrAn error code.
bInternaltrue, if iErr is an internal error code and needs a conversion to the ZipArchive Library error code; false otherwise.
See Also
ConvertInternalError

Definition at line 511 of file ZipCompressor.h.

void CZipCompressor::UpdateCrc ( const void *  pBuffer,
DWORD  uSize 
)
protected

Updates CRC value while decompression.

Parameters
pBufferA buffer with data for which the CRC value should be updated.
uSizeThe size of the buffer.
void CZipCompressor::UpdateFileCrc ( const void *  pBuffer,
DWORD  uSize 
)
protected

Updates CRC value while compression.

Parameters
pBufferA buffer with data for which the CRC value should be updated.
uSizeThe size of the buffer.
void CZipCompressor::UpdateOptions ( const COptionsMap optionsMap)

Updates the current options with the options stored in optionsMap, if the appropriate options are present in the map.

Parameters
optionsMapThe map to get the new options from.
See Also
Compressing Data
GetOptions
virtual void CZipCompressor::UpdateOptions ( const COptions pOptions)
inlineprotectedvirtual

Updates the current options with the new options.

Parameters
pOptionsThe new options to apply.

Reimplemented in ZipArchiveLib::CDeflateCompressor.

Definition at line 390 of file ZipCompressor.h.

void CZipCompressor::WriteBuffer ( char *  pBuffer,
DWORD  uSize 
)
inlineprotected

Writes the buffer into the storage, encrypting the data if needed.

Parameters
pBufferThe buffer with data to write.
uSizeThe size of the buffer.

Definition at line 434 of file ZipCompressor.h.

Member Data Documentation

CZipAutoBuffer CZipCompressor::m_pBuffer
protected

A buffer that receives compressed data or provides data for decompression.

Definition at line 45 of file ZipCompressor.h.

CZipCryptograph* CZipCompressor::m_pCryptograph
protected

The current cryptograph.

Definition at line 46 of file ZipCompressor.h.

CZipFileHeader* CZipCompressor::m_pFile
protected

The file header being compressed or decompressed.

Definition at line 47 of file ZipCompressor.h.

CZipStorage* CZipCompressor::m_pStorage
protected

The current storage object.

Definition at line 44 of file ZipCompressor.h.

ZIP_SIZE_TYPE CZipCompressor::m_uComprLeft

The number of bytes left to compress.

Definition at line 204 of file ZipCompressor.h.

DWORD CZipCompressor::m_uCrc32

The CRC32 file checksum.

Definition at line 205 of file ZipCompressor.h.

ZIP_SIZE_TYPE CZipCompressor::m_uUncomprLeft

The number of bytes left to decompress.

Definition at line 203 of file ZipCompressor.h.


The documentation for this class was generated from the following file:

The ZipArchive Library Copyright © 2000 - 2022 Artpol Software - Tadeusz Dracz. Generated at Sat Dec 17 2022 19:57:04.