Compressor Class Reference

An abstract data (de)compressor. More...

#include <yateclass.h>

Inheritance diagram for Compressor:

String GenObject

List of all members.

Public Member Functions

 Compressor (const char *format, const char *name=0)
virtual ~Compressor ()
const Stringformat () const
virtual bool init (bool comp=true, bool decomp=true, const NamedList &params=NamedList::empty())
virtual void finalize (bool comp)
virtual int compress (const void *buf, unsigned int len, DataBlock &dest)
virtual int decompress (const void *buf, unsigned int len, DataBlock &dest)
virtual int writeComp (const void *buf, unsigned int len, bool flush)=0
int writeComp (const DataBlock &data, bool flush)
int writeComp (const String &data, bool flush)
virtual int readComp (DataBlock &buf, bool flush)=0
virtual int writeDecomp (const void *buf, unsigned int len, bool flush)=0
int writeDecomp (const DataBlock &data, bool flush)
int writeDecomp (const String &data, bool flush)
virtual int readDecomp (DataBlock &buf, bool flush)=0

Protected Attributes

String m_format


Detailed Description

An abstract data (de)compressor.

The Compressor class provides an abstraction for data (de)compressor classes. The String component keeps an optional object name to be used for debug purposes


Constructor & Destructor Documentation

Compressor ( const char *  format,
const char *  name = 0 
) [inline]

Constructor

Parameters:
format Compression format
name Optional object name

virtual ~Compressor (  )  [inline, virtual]

Destructor


Member Function Documentation

const String& format (  )  const [inline]

Retrieve (de)compressor format

Returns:
The format of this (de)compressor

virtual bool init ( bool  comp = true,
bool  decomp = true,
const NamedList params = NamedList::empty() 
) [inline, virtual]

Initialize

Parameters:
comp True to initialize compressor
decomp True to initialize decompressor
params Optional parameters
Returns:
True on success

virtual void finalize ( bool  comp  )  [inline, virtual]

Finalize the (de)compression

Parameters:
comp True to finalize compression, false to finalize decompression

virtual int compress ( const void *  buf,
unsigned int  len,
DataBlock dest 
) [virtual]

Compress the input buffer, flush all pending data, append compressed data to the received data block

Parameters:
buf Pointer to input data
len Length of input in bytes
dest Destination buffer
Returns:
The number of bytes wrote to compressor, negative on error

virtual int decompress ( const void *  buf,
unsigned int  len,
DataBlock dest 
) [virtual]

Decompress the input buffer, flush all pending data, append decompressed data to the received data block

Parameters:
buf Pointer to input data
len Length of input in bytes
dest Destination buffer
Returns:
The number of bytes wrote to decompressor, negative on error

virtual int writeComp ( const void *  buf,
unsigned int  len,
bool  flush 
) [pure virtual]

Push data to compressor. Flush compressor input if input buffer is NULL or the length is 0 and flush is true

Parameters:
buf Pointer to input data
len Length of input in bytes
flush True to compress all now, false to let the compressor accumulate more data for better compression
Returns:
The number of bytes written, negative on error. An incomplete write may occur if the output buffer is full

int writeComp ( const DataBlock data,
bool  flush 
) [inline]

Push data to compressor

Parameters:
data Input data block
flush True to compress all now, false to let the compressor accumulate more data for better compression
Returns:
The number of bytes written, negative on error. An incomplete write may occur if the output buffer is full

References DataBlock::data(), and DataBlock::length().

int writeComp ( const String data,
bool  flush 
) [inline]

Push data to compressor

Parameters:
data Input string
flush True to compress all now, false to let the compressor accumulate more data for better compression
Returns:
The number of bytes written, negative on error. An incomplete write may occur if the output buffer is full

References String::c_str(), and String::length().

virtual int readComp ( DataBlock buf,
bool  flush 
) [pure virtual]

Read data from compressor. Append it to 'buf'

Parameters:
buf Destination data block
flush True to flush all compressor input data
Returns:
The number of bytes read, negative on error

virtual int writeDecomp ( const void *  buf,
unsigned int  len,
bool  flush 
) [pure virtual]

Push data to decompressor

Parameters:
buf Pointer to input data
len Length of input in bytes
flush True to try to decompress all data
Returns:
The number of bytes written, negative on error. An incomplete write may occur if the output buffer is full

int writeDecomp ( const DataBlock data,
bool  flush 
) [inline]

Push data to decompressor

Parameters:
data Input data block
flush True to try to decompress all data
Returns:
The number of bytes written, negative on error. An incomplete write may occur if the output buffer is full

References DataBlock::data(), and DataBlock::length().

int writeDecomp ( const String data,
bool  flush 
) [inline]

Push data to decompressor

Parameters:
data Input string
flush True to try to decompress all data
Returns:
The number of bytes written, negative on error. An incomplete write may occur if the output buffer is full

References String::c_str(), and String::length().

virtual int readDecomp ( DataBlock buf,
bool  flush 
) [pure virtual]

Read data from decompressor. Append it to 'buf'

Parameters:
buf Destination data block
flush True to flush all decompressor input data
Returns:
The number of bytes read, negative on error


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

Generated on Sat May 28 18:28:23 2011 for Yate by  doxygen 1.5.6