Download Source Code

CComp2 Class Reference

Simple wrapper for ZLIB compression routines. More...

#include <Comp2.h>

Collaboration diagram for CComp2:

Collaboration graph
[legend]
List of all members.

Public Member Functions

BOOL ExpandInit ()
 Initializes the ZLIB expand routines.
BOOL ExpandContinue (BOOL *pDone)
 Continues expansion.
BOOL ReadHeader ()
 Reads in the compression header.
BOOL CompressInit ()
 Initializes the ZLIB compressor.
BOOL CompressContinue (BOOL *pDone)
 Continues compression.
BOOL WriteHeader ()
 Writes out compression header.
BOOL Read (LPVOID buf, DWORD size, LPDWORD read=NULL)
 Reads data from compressed stream.
BOOL Write (LPVOID buf, DWORD size)
 Writes data to a compressed stream.
BOOL SetDest (LPBYTE buf, DWORD size)
 Sets the destination buffer for encoding or decoding.
BOOL SetSource (LPBYTE buf, DWORD size)
 Sets the source buffer.
void Destroy ()
 Releases all resources for this class.
BOOL SetDest (LPCTSTR pFile, HANDLE hFile=NULL)
 Sets the destination file for compression / decompression.
BOOL SetSource (LPCTSTR pFile, HANDLE hFile=NULL, BOOL bSaveFileName=FALSE, DWORD max=0)
 Sets file to use as data source for compression / decompression.
 CComp2 ()
 Constructor.
 ~CComp2 ()
 Destructor.
BOOL IsSource ()
 Returns non-zero if a valid source is set.
BOOL IsDest ()
 Returns non-zero if a valid destination is set.
DWORD GetBytesRead ()
 Returns the number of bytes read from source.
DWORD GetBytesWritten ()
 Returns the number of bytes written to destination.
DWORD GetExpandFileSize ()
 Returns the size of the expanded data.
DWORD GetSourceFileSize ()
 Returns the size of the source file.
LPCTSTR GetExpandFileName ()
 Returns the expanded file name from compressed stream if it was saved.
LPCTSTR GetFileID ()
 Returns the file id.
void SetFileID (LPCTSTR pID)
 Sets the file id.

Detailed Description

Simple wrapper for ZLIB compression routines.

Provides a simple wrapper for zlib compression routines.

Also provides functionality to do compression / decompression in another thread to prevent long operations from holding up the main thread.

Warning:
Must link to the ZLIB library.


Member Function Documentation

BOOL CComp2::CompressContinue BOOL *  pDone  ) 
 

Continues compression.

Parameters:
[in] pDone - Set to non-zero when complete.
Initialize pDone to zero, keep calling CompressContinue() until pDone is set to non-zero. If CompressContinue() returns zero, you should abort.

Returns:
Non-zero if success.
See also:

BOOL CComp2::CompressInit  ) 
 

Initializes the ZLIB compressor.

Returns:
Non-zero if success
See also:

BOOL CComp2::ExpandContinue BOOL *  pDone  ) 
 

Continues expansion.

Parameters:
[in] pDone - Set to non-zero when complete.
Initialize pDone to zero, keep calling ExpandContinue until pDone is set to non-zero. If ExpandContinue() returns zero, you should abort.

Returns:
Non-zero if success.
See also:

BOOL CComp2::ExpandInit  ) 
 

Initializes the ZLIB expand routines.

Returns:
Non-zero if success
See also:

BOOL CComp2::Read LPVOID  buf,
DWORD  size,
LPDWORD  read = NULL
 

Reads data from compressed stream.

Parameters:
[in] buf - Buffer that receives data.
[in] size - Size of buffer in buf.
[in] read - Number of bytes read into buf.
Returns:
Non-zero if success.
See also:

BOOL CComp2::ReadHeader  ) 
 

Reads in the compression header.

Returns:
Non-zero if success
See also:

BOOL CComp2::SetDest LPCTSTR  pFile,
HANDLE  hFile = NULL
 

Sets the destination file for compression / decompression.

Parameters:
[in] pFile - Filename
[in] hFile - Optional handle to file, used if pFile is NULL.
Returns:
Non-zero if success.
See also:

BOOL CComp2::SetDest LPBYTE  buf,
DWORD  size
 

Sets the destination buffer for encoding or decoding.

Parameters:
[in] buf - Buffer pointer.
[in] size - Size of buffer in buf.
Returns:
Non-zero if success
See also:

void CComp2::SetFileID LPCTSTR  pID  )  [inline]
 

Sets the file id.

Parameters:
[in] pID - File id string
The file id is used to identify the compressed file

BOOL CComp2::SetSource LPCTSTR  pFile,
HANDLE  hFile = NULL,
BOOL  bSaveFileName = FALSE,
DWORD  max = 0
 

Sets file to use as data source for compression / decompression.

Parameters:
[in] pFile - Filename
[in] hFile - Optional file handle, used if pFile is NULL
[in] bSaveFileName - If set to non-zero, filename is saved to compressed stream for later use.
[in] max - Maximum number of bytes to read.
Returns:
Non-zero if success.
See also:

BOOL CComp2::SetSource LPBYTE  buf,
DWORD  size
 

Sets the source buffer.

Parameters:
[in] buf - Pointer to buffer containing source data.
[in] size - Size of buffer in buf
Returns:
Non-zero if success
See also:

BOOL CComp2::Write LPVOID  buf,
DWORD  size
 

Writes data to a compressed stream.

Parameters:
[in] buf - Pointer to buffer containing data.
[in] size - Number of bytes in buf.
Returns:
Non-zero if success
See also:

BOOL CComp2::WriteHeader  ) 
 

Writes out compression header.

Writes a custom header that is used to setup the decompressor.

Returns:
Non-zero if success.
See also:


The documentation for this class was generated from the following files:
  • inc/Comp2.h
  • Comp2.cpp
Copyright Robert Umbehant
This documentation is covered by the LGPL