ZlibByteArray Class Reference

#include <ZlibByteArray.h>

List of all members.

Public Types

enum  CompressionMethod { None, Gzip, Zlib }

Public Member Functions

 ZlibByteArray (QByteArray data)
QByteArray compress (const CompressionMethod method=Zlib, QString *errmsg=0) const
QByteArray uncompress (CompressionMethod method=Zlib, QString *errmsg=0) const

Static Public Member Functions

static QByteArray compress (const QByteArray in, const CompressionMethod method=Zlib, QString *errmsg=0)
static QByteArray uncompress (const QByteArray in, const CompressionMethod method=Zlib, QString *errmsg=0)
static bool isZlibAvailable ()
static bool isGzipSupported ()

Static Private Member Functions

static int methodBits (CompressionMethod method)
static QString methodString (CompressionMethod method)

Detailed Description

Definition at line 60 of file ZlibByteArray.h.


Member Enumeration Documentation

Available compression methods.

Enumerator:
None 

No compression method.

Gzip 

Gzip compression method.

Zlib 

Zlib compression method.

Definition at line 64 of file ZlibByteArray.h.


Constructor & Destructor Documentation

ZlibByteArray::ZlibByteArray ( QByteArray  data  ) 

Constructor.

Constructor

Definition at line 82 of file ZlibByteArray.cpp.


Member Function Documentation

QByteArray ZlibByteArray::compress ( const QByteArray  in,
const CompressionMethod  method = Zlib,
QString *  errmsg = 0 
) [static]

Compreses the contents of in using method.

Compresses in using method. Returns the compressed data if successful. If an error occurs, this will return an empty QByteArray and set the optional errmsg to a string describing the failure.

Definition at line 165 of file ZlibByteArray.cpp.

References z_stream_s::avail_in, z_stream_s::avail_out, deflateInit2, err(), Gzip, isGzipSupported(), methodBits(), methodString(), z_stream_s::msg, z_stream_s::next_in, z_stream_s::next_out, None, z_stream_s::opaque, z_stream_s::total_out, UINT_MAX, Z_BEST_COMPRESSION, Z_BUF_ERROR, Z_DEFAULT_STRATEGY, Z_DEFLATED, Z_FINISH, Z_NULL, Z_OK, Z_STREAM_END, z_stream_s::zalloc, z_stream_s::zfree, and ZLIB_VERSION.

QByteArray ZlibByteArray::compress ( const CompressionMethod  method = Zlib,
QString *  errmsg = 0 
) const

Compresses the current contents of this object using method.

Compresses the current contents of this object using method. Returns the compressed data if successful. If an error occurs, this will return an empty QByteArray and set the optional errmsg to a string describing the failure.

Definition at line 155 of file ZlibByteArray.cpp.

bool ZlibByteArray::isGzipSupported (  )  [static]

Returns true iff we support gzip-based compression. Otherwise, we need to use zlib.

Definition at line 133 of file ZlibByteArray.cpp.

Referenced by compress(), GeoIpRequest::createHeader(), and uncompress().

bool ZlibByteArray::isZlibAvailable (  )  [static]

Returns true if the Zlib compression library is available and usable.

Definition at line 109 of file ZlibByteArray.cpp.

References ZLIB_VERSION.

Referenced by GeoIpRequest::createHeader().

int ZlibByteArray::methodBits ( CompressionMethod  method  )  [static, private]

Return the 'bits' value to tell zlib to use method.

Definition at line 89 of file ZlibByteArray.cpp.

References Gzip.

Referenced by compress(), and uncompress().

QString ZlibByteArray::methodString ( CompressionMethod  method  )  [static, private]

Returns a string description of method.

Definition at line 97 of file ZlibByteArray.cpp.

References Gzip, None, and Zlib.

Referenced by compress(), and uncompress().

QByteArray ZlibByteArray::uncompress ( const QByteArray  in,
const CompressionMethod  method = Zlib,
QString *  errmsg = 0 
) [static]

Uncompresses the contents of in using method.

Uncompresses in using method. Returns the uncompressed data if successful. If an error occurs, this will return an empty QByteArray and set the optional errmsg to a string describing the failure.

Definition at line 272 of file ZlibByteArray.cpp.

References z_stream_s::avail_in, z_stream_s::avail_out, err(), Gzip, inflateInit2, isGzipSupported(), methodBits(), methodString(), z_stream_s::msg, z_stream_s::next_in, z_stream_s::next_out, None, z_stream_s::opaque, UINT_MAX, Z_BUF_ERROR, Z_FINISH, Z_NULL, Z_OK, Z_STREAM_END, z_stream_s::zalloc, z_stream_s::zfree, and ZLIB_VERSION.

QByteArray ZlibByteArray::uncompress ( CompressionMethod  method = Zlib,
QString *  errmsg = 0 
) const

Uncompresses the current contents of this object using method.

Uncompresses the current contents of this object using method. Returns the uncompressed data if successful. If an error occurs, this will return an empty QByteArray and set the optional errmsg to a string describing the failure.

Definition at line 262 of file ZlibByteArray.cpp.

Referenced by GeoIpResponse::GeoIpResponse().


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

Generated on 31 Mar 2010 for Vidalia by  doxygen 1.6.1