class Compressor

# class Compressor | An abstract data (de)compressor. More...
Contains pure virtuals
Full name | `TelEngine::Compressor`
Definition | `#include <yateclass.h>`
Inherits | TelEngine::String [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- inline Compressor (const char* format, const char* name = 0)
- virtual ~Compressor ()
- inline const String& format () 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)
- inline int writeComp (const DataBlock& data, bool flush)
- inline int writeComp (const String& data, bool flush)
- virtual int readComp (DataBlock& buf, bool flush)
- virtual int writeDecomp (const void* buf, unsigned int len, bool flush)
- inline int writeDecomp (const DataBlock& data, bool flush)
- inline int writeDecomp (const String& data, bool flush)
- virtual int readDecomp (DataBlock& buf, bool flush)

#### Protected Members

- String m_format

## Detailed Description

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

inline Compressor (const char* format, const char* name = 0) | ### Compressor

Constructor

Parameters:

format | Compression format
name | Optional object name

~Compressor () | ### ~Compressor

[virtual]

Destructor

inline const String& format () | ### format

[const]

Retrieve (de)compressor format

Returns: The format of this (de)compressor

bool init (bool comp = true, bool decomp = true, const NamedList& params = NamedList::empty()) | ### init

[virtual]

Initialize

Parameters:

comp | True to initialize compressor
decomp | True to initialize decompressor
params | Optional parameters

Returns: True on success

void finalize (bool comp) | ### finalize

[virtual]

Finalize the (de)compression

Parameters:

comp | True to finalize compression, false to finalize decompression

int compress (const void* buf, unsigned int len, DataBlock& dest) | ### compress

[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

int decompress (const void* buf, unsigned int len, DataBlock& dest) | ### decompress

[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

int writeComp (const void* buf, unsigned int len, bool flush) | ### writeComp

[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

inline int writeComp (const DataBlock& data, bool flush) | ### writeComp

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

inline int writeComp (const String& data, bool flush) | ### writeComp

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

int readComp (DataBlock& buf, bool flush) | ### readComp

[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

int writeDecomp (const void* buf, unsigned int len, bool flush) | ### writeDecomp

[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

inline int writeDecomp (const DataBlock& data, bool flush) | ### writeDecomp

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

inline int writeDecomp (const String& data, bool flush) | ### writeDecomp

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

int readDecomp (DataBlock& buf, bool flush) | ### readDecomp

[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

String m_format | ### m_format

[protected]

Generated by: paulc on bussard on Fri May 8 12:37:22 2015, using kdoc 2.0a54.