Yate
Public Member Functions | Protected Attributes
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:
formatCompression format
nameOptional object name
virtual ~Compressor ( ) [inline, virtual]

Destructor


Member Function Documentation

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:
bufPointer to input data
lenLength of input in bytes
destDestination 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:
bufPointer to input data
lenLength of input in bytes
destDestination buffer
Returns:
The number of bytes wrote to decompressor, negative on error
virtual void finalize ( bool  comp) [inline, virtual]

Finalize the (de)compression

Parameters:
compTrue to finalize compression, false to finalize decompression
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:
compTrue to initialize compressor
decompTrue to initialize decompressor
paramsOptional parameters
Returns:
True on success
virtual int readComp ( DataBlock buf,
bool  flush 
) [pure virtual]

Read data from compressor. Append it to 'buf'

Parameters:
bufDestination data block
flushTrue to flush all compressor input data
Returns:
The number of bytes read, negative on error
virtual int readDecomp ( DataBlock buf,
bool  flush 
) [pure virtual]

Read data from decompressor. Append it to 'buf'

Parameters:
bufDestination data block
flushTrue to flush all decompressor input data
Returns:
The number of bytes read, 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:
bufPointer to input data
lenLength of input in bytes
flushTrue 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:
dataInput data block
flushTrue 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(), DataBlock::length(), and Compressor::writeComp().

Referenced by Compressor::writeComp().

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

Push data to compressor

Parameters:
dataInput string
flushTrue 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(), String::length(), and Compressor::writeComp().

Referenced by Compressor::writeComp().

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

Push data to decompressor

Parameters:
bufPointer to input data
lenLength of input in bytes
flushTrue 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:
dataInput data block
flushTrue 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(), DataBlock::length(), and Compressor::writeDecomp().

Referenced by Compressor::writeDecomp().

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

Push data to decompressor

Parameters:
dataInput string
flushTrue 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(), String::length(), and Compressor::writeDecomp().

Referenced by Compressor::writeDecomp().


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