latest version v1.9 - last update 10 Apr 2010 |
This is the base class for data encoding and decoding. More...
#include <ltiDataCodec.h>
Classes | |
class | parameters |
The parameters for the class dataTransformer. More... | |
Public Member Functions | |
dataCodec () | |
dataCodec (const parameters &par) | |
dataCodec (const dataCodec &other) | |
virtual | ~dataCodec () |
virtual const char * | getTypeName () const |
virtual bool | encode (bufferElement *srcdest, int nsrc, int &ndest) const |
virtual bool | encode (buffer &srcdest) const |
virtual bool | encode (const bufferElement *src, int nsrc, bufferElement *dest, int &ndest) const |
virtual bool | encode (const buffer &src, buffer &dest) const |
virtual bool | decode (bufferElement *srcdest, int nsrc, int &ndest) const |
virtual bool | decode (buffer &srcdest) const |
virtual bool | decode (const bufferElement *src, int nsrc, bufferElement *dest, int &ndest) const |
virtual bool | decode (const buffer &src, buffer &dest) const |
virtual bool | apply (bufferElement *srcdest, int nsrc, int &ndest) const |
virtual bool | apply (buffer &srcdest) const |
virtual bool | apply (const bufferElement *src, int nsrc, bufferElement *dest, int &ndest) const |
virtual bool | apply (const buffer &src, buffer &dest) const |
const parameters & | getParameters () const |
dataCodec & | copy (const dataCodec &other) |
dataCodec & | operator= (const dataCodec &other) |
virtual int | estimateEncodedSize (int originalSize) const |
virtual int | estimateDecodedSize (int encodedSize) const |
Protected Member Functions | |
virtual bool | decodeImplementation (const buffer &src, buffer &dest, int nsrc, int &ndest) const =0 |
virtual bool | encodeImplementation (const buffer &src, buffer &dest, int nsrc, int &ndest) const =0 |
virtual int | getNewEncodingBufferSize (int originalSize) const |
virtual int | getNewDecodingBufferSize (int originalSize) const |
This is the base class for data encoding and decoding.
This an abstract class.
lti::dataCodec::dataCodec | ( | ) |
default constructor
lti::dataCodec::dataCodec | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::dataCodec::dataCodec | ( | const dataCodec & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::dataCodec::~dataCodec | ( | ) | [virtual] |
destructor
Operates on the given argument.
Implements lti::dataTransformer.
virtual bool lti::dataCodec::apply | ( | const bufferElement * | src, | |
int | nsrc, | |||
bufferElement * | dest, | |||
int & | ndest | |||
) | const [virtual] |
Operates on a copy of the given arguments.
src | pointer to an array of bufferElement which contains the source data | |
nsrc | the number of input bytes that should be transformed. | |
dest | pointer to an array of bufferElement which will receive the transformed data. The array must be allocated by the caller | |
ndest | When called, must contain the size of the output buffer. When the function returns, it contains the number of bytes actually used, or -1 if the buffer was too small. |
Implements lti::dataTransformer.
virtual bool lti::dataCodec::apply | ( | buffer & | srcdest | ) | const [virtual] |
Operates on the given argument.
If the data is encoded or decoded depends on the coding direction parameter.
srcdest | vector with the input data which will also receive the transformed data. |
Implements lti::dataTransformer.
virtual bool lti::dataCodec::apply | ( | bufferElement * | srcdest, | |
int | nsrc, | |||
int & | ndest | |||
) | const [virtual] |
Operates on the given arguments.
If the data is encoded or decoded depends on the coding direction parameter.
srcdest | pointer to an array of bufferElement. The input array must be allocated and have enough space for input as well as output data. | |
nsrc | the number of input bytes that should be transformed. | |
ndest | the number of bytes of the transformed data. If the buffer was too small, it will contain -1 when the function returns. |
Implements lti::dataTransformer.
Copy another dataCodec.
Reimplemented from lti::dataTransformer.
Reimplemented in lti::ascii85Codec, lti::asciiHexCodec, lti::binarizationCodec, lti::combinedCodec, lti::identityCodec, and lti::runLengthCodec.
Decodes data on copy.
virtual bool lti::dataCodec::decode | ( | const bufferElement * | src, | |
int | nsrc, | |||
bufferElement * | dest, | |||
int & | ndest | |||
) | const [virtual] |
Decodes data on copy.
virtual bool lti::dataCodec::decode | ( | buffer & | srcdest | ) | const [virtual] |
Decodes data in place.
virtual bool lti::dataCodec::decode | ( | bufferElement * | srcdest, | |
int | nsrc, | |||
int & | ndest | |||
) | const [virtual] |
Decodes data in place.
virtual bool lti::dataCodec::decodeImplementation | ( | const buffer & | src, | |
buffer & | dest, | |||
int | nsrc, | |||
int & | ndest | |||
) | const [protected, pure virtual] |
Implementation of on-copy data decoder.
This method must not, under no circumstances, resize the destination vector.
src | the source of the data. | |
dest | the destination for the decoded data. | |
nsrc | tells how many elements of the src vector must be decoded. | |
ndest | tells how many elements of the destination vector can be used for the decoded data. When the method returns, this value tells how many elements were actually used, or notEnoughSpace if not enough elements were available. |
Implemented in lti::ascii85Codec, lti::asciiHexCodec, lti::binarizationCodec, lti::combinedCodec, lti::identityCodec, and lti::runLengthCodec.
Encodes data on copy.
virtual bool lti::dataCodec::encode | ( | const bufferElement * | src, | |
int | nsrc, | |||
bufferElement * | dest, | |||
int & | ndest | |||
) | const [virtual] |
Encodes data on copy.
virtual bool lti::dataCodec::encode | ( | buffer & | srcdest | ) | const [virtual] |
Encodes data in place.
virtual bool lti::dataCodec::encode | ( | bufferElement * | srcdest, | |
int | nsrc, | |||
int & | ndest | |||
) | const [virtual] |
Encodes data in place.
virtual bool lti::dataCodec::encodeImplementation | ( | const buffer & | src, | |
buffer & | dest, | |||
int | nsrc, | |||
int & | ndest | |||
) | const [protected, pure virtual] |
Implementation of on-copy data encoder.
This method must not, under no circumstances, resize the destination vector.
src | the source of the data. | |
dest | the destination for the encoded data. | |
nsrc | tells how many elements of the src vector must be decoded. | |
ndest | tells how many elements of the destination vector can be used for the decoded data. When the method returns, this value tells how many elements were actually used, or notEnoughSpace if not enough elements were available. |
Implemented in lti::ascii85Codec, lti::asciiHexCodec, lti::binarizationCodec, lti::combinedCodec, lti::identityCodec, and lti::runLengthCodec.
virtual int lti::dataCodec::estimateDecodedSize | ( | int | encodedSize | ) | const [virtual] |
Computes the default buffer size for decoded data.
The source of the encoded data buffer is given as argument. The default is to return the given value.
encodedSize | the size of the data buffer to be decoded |
Reimplemented in lti::ascii85Codec, lti::asciiHexCodec, lti::binarizationCodec, lti::combinedCodec, and lti::runLengthCodec.
virtual int lti::dataCodec::estimateEncodedSize | ( | int | originalSize | ) | const [virtual] |
Computes the default buffer size for encoded data.
The source of the original data buffer is given as argument. The default is to return the given value.
originalSize | the size of the data buffer to be encoded |
Reimplemented in lti::ascii85Codec, lti::asciiHexCodec, lti::binarizationCodec, lti::combinedCodec, and lti::runLengthCodec.
virtual int lti::dataCodec::getNewDecodingBufferSize | ( | int | originalSize | ) | const [protected, virtual] |
Computes a new reasonable buffer size for encoded data if the given buffer size is too small.
The default is 2*orginialSize;
originalSize | the size of the data buffer |
virtual int lti::dataCodec::getNewEncodingBufferSize | ( | int | originalSize | ) | const [protected, virtual] |
Computes a new reasonable buffer size for encoded data if the given buffer size is too small.
The default is 2*orginialSize;
originalSize | the size of the data buffer |
const parameters& lti::dataCodec::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::dataTransformer.
Reimplemented in lti::binarizationCodec.
virtual const char* lti::dataCodec::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("dataCodec")
Reimplemented from lti::dataTransformer.
Reimplemented in lti::ascii85Codec, lti::asciiHexCodec, lti::binarizationCodec, lti::combinedCodec, lti::identityCodec, and lti::runLengthCodec.
Copy another dataCodec.
Reimplemented from lti::dataTransformer.
Reimplemented in lti::ascii85Codec, lti::asciiHexCodec, lti::binarizationCodec, lti::combinedCodec, lti::identityCodec, and lti::runLengthCodec.