KlvLib  1.58
Public Member Functions | Related Functions | List of all members
IKlvEncoder Class Referenceabstract

IKlvEncoder class. More...

Public Member Functions

virtual ~IKlvEncoder (void)
 Virtual destructor.
 
virtual void SetOuterKey (const char *key)=0
 Set an outer key. For example, Universal key. More...
 
virtual void SetOuterKey (const char *key, IKlvItem::KEY_LENGTH keySize)=0
 Set an outer key (binary). More...
 
virtual void SetCheckSumKey (const char *key)=0
 Set Checksum item key. More...
 
virtual void SetCheckSumKey (const char *key, IKlvItem::KEY_LENGTH keySize)=0
 Set Checksum item key (binary). More...
 
virtual void AddKlvItem (IKlvItem *klvItem)=0
 Add KlvItem. More...
 
virtual void AddKlvItem (const char *key, const char *value, const size_t size)=0
 Create and Add KlvItem. More...
 
virtual void AddKlvItem (const char *key, IKlvItem::KEY_LENGTH keySize, const char *value, const size_t size)=0
 Create and Add KLV item More...
 
virtual void AddKlvItem (const char key, const unsigned char value)=0
 Create and Add KLV item 1 byte key, char value. More...
 
virtual void AddKlvItem (const char key, const unsigned short value)=0
 Create and Add KLV item 1 byte key, short value. More...
 
virtual void AddKlvItem (const char key, const unsigned int value)=0
 Create and Add KLV item 1 byte key, int value. More...
 
virtual void AddKlvItem (const char key, const unsigned __int64 value)=0
 Create and Add KLV item 1 byte key, __int64 value. More...
 
virtual void AddKlvItem (const char *key, const unsigned char value)=0
 Create and Add KLV item 1 byte key, char value. More...
 
virtual void AddKlvItem (const char *key, const unsigned short value)=0
 Create and Add KLV item, short value. More...
 
virtual void AddKlvItem (const char *key, const unsigned int value)=0
 Create and Add KLV item, int value. More...
 
virtual void AddKlvItem (const char *key, const unsigned __int64 value)=0
 Create and Add KLV item, __int64 value. More...
 
virtual void AddKlvItemBin (const char *key, const unsigned char value)=0
 Create and Add KLV Item using Binary Key and char value. More...
 
virtual void AddKlvItemBin (const char *key, const unsigned short value)=0
 Create and Add KLV Item using Binary Key and short value. More...
 
virtual void AddKlvItemBin (const char *key, const unsigned int value)=0
 Create and Add KLV Item using Binary Key and int value. More...
 
virtual void AddKlvItemBin (const char *key, const unsigned __int64 value)=0
 Create and Add KLV Item using Binary Key and __int64 value. More...
 
virtual void AddKlvItem (const char *key, IKlvItem::KEY_LENGTH keySize, const unsigned char value)=0
 Create and Add KLV item binary key, char value. More...
 
virtual void AddKlvItem (const char *key, IKlvItem::KEY_LENGTH keySize, const unsigned short value)=0
 Create and Add KLV item binary key, short value. More...
 
virtual void AddKlvItem (const char *key, IKlvItem::KEY_LENGTH keySize, const unsigned int value)=0
 Create and Add KLV item binary key, char value. More...
 
virtual void AddKlvItem (const char *key, IKlvItem::KEY_LENGTH keySize, const unsigned __int64 value)=0
 Create and Add KLV item binary key, __int64 value. More...
 
virtual void Sort ()=0
 Sort items. More...
 
virtual char * Encode (size_t &size)=0
 Encode KLV data. More...
 
virtual void SetBuffer (char *buf, const size_t size=MAX_KLV_SIZE)=0
 Configure KLV buffer. More...
 
virtual void FreeInternalBuffer ()=0
 FreeInternalBuffer. More...
 

Related Functions

(Note that these are not member functions.)

KLVLIB_API IKlvEncoderCreateKlvEncoder (IKlvItem::KEY_LENGTH innerKeyLength=IKlvItem::ONE_BYTE, BOOL EndianSwap=TRUE)
 Creates KlvEncoder instance. More...
 
KLVLIB_API void EndianSwap (unsigned short &x)
 Swap 16 bit values. More...
 
KLVLIB_API void EndianSwap (unsigned int &x)
 Swap 32 bit values. More...
 
KLVLIB_API void EndianSwap (unsigned __int64 &x)
 Swap 64 bit values. More...
 
KLVLIB_API void doubleToByteArray (double val, unsigned char *arr)
 Convert val to byte array. More...
 
KLVLIB_API void uint64ToByteArray (__int64 num, unsigned char *arr)
 Convert num to byte array. More...
 

Detailed Description

IKlvEncoder KLV encoder interface

KLV Encoder class allows KLV Items addition and their encoding into the binary data buffer.

KLV items addition

There are different ways to add KlvItems to the KlvEncoder

Examples:
klvtestapp.cpp, and klvtestappuds.cpp.

Member Function Documentation

virtual void IKlvEncoder::AddKlvItem ( IKlvItem klvItem)
pure virtual

Adds KLV item to the internal container

Parameters
klvItema IKlvItem*. A pointer to KlvIem.
Returns
void.
Examples:
klvtestapp.cpp, and klvtestappuds.cpp.
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
const char *  value,
const size_t  size 
)
pure virtual

Adds KLV item. Creates KLV item from the supplied key string and value and adds it to the internal KlvItems container.

Parameters
keya const char*. A Key String.
valuea const char*. A binary Value.
sizea size_t. Value's size.
Returns
void.
Note
Note, 2 characters per byte MUST be used! For example - "060E2B34020101010E01010201010000"
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
IKlvItem::KEY_LENGTH  keySize,
const char *  value,
const size_t  size 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya const char*. A binary Key.
keySizea KEY_LENGTH. Key's size.
valuea const char*. A binary Value.
sizea size_t. Value's size.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char  key,
const unsigned char  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya const unsigned char. A binary Key (1 byte letgth).
valuea const char. A binary (short) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char  key,
const unsigned short  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya const unsigned short. A binary Key (2 byte letgth).
valuea const unsigned short. A binary (short) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char  key,
const unsigned int  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya const unsigned int. A binary Key (4 byte letgth).
valuea const unsigned int. A binary (int) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char  key,
const unsigned __int64  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya const unsigned __int64. A binary Key (8 byte letgth).
valuea const unsigned __int64. A binary (__int64) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
const unsigned char  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya pointer to array containing a Key.
valuea const char. A binary (short) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
const unsigned short  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya pointer to the buffer containing a key.
valuea const unsigned short. A binary (short) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
const unsigned int  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya pointer to the buffer containing a key.
valuea const unsigned int. A binary (int) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
const unsigned __int64  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya pointer to the buffer containing a key.
valuea const unsigned __int64. A binary (__int64) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
IKlvItem::KEY_LENGTH  keySize,
const unsigned char  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya const char*. A binary Key.
keySizea KEY_LENGTH. Key's size.
valuea const char. A binary (short) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
IKlvItem::KEY_LENGTH  keySize,
const unsigned short  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya const char*. A binary Key.
keySizea KEY_LENGTH. Key's size.
valuea const short. A binary (short) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
IKlvItem::KEY_LENGTH  keySize,
const unsigned int  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya const char*. A binary Key.
keySizea KEY_LENGTH. Key's size.
valuea const int. A binary (int) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItem ( const char *  key,
IKlvItem::KEY_LENGTH  keySize,
const unsigned __int64  value 
)
pure virtual

Creates and adds a KLV item to the internal container

Parameters
keya const char*. A binary Key.
keySizea KEY_LENGTH. Key's size.
valuea const __int64. A binary (__int64) Value.
Returns
void.
virtual void IKlvEncoder::AddKlvItemBin ( const char *  key,
const unsigned char  value 
)
pure virtual

Creates and adds a KLV item to the internal container using Binary Key and char value.

Parameters
keya pointer to array containing a Key.
valuea const char*. A binary (short) Value.
Returns
void.
Note
Note, you should define a Key Length in the constructor in order to use this method.
Examples:
klvtestappuds.cpp.
virtual void IKlvEncoder::AddKlvItemBin ( const char *  key,
const unsigned short  value 
)
pure virtual

Creates and adds a KLV item to the internal container using Binary Key and short value.

Parameters
keya pointer to the buffer containing a key.
valuea const unsigned short. A binary (short) Value.
Returns
void.
Note
Note, you should define a Key Length in the constructor in order to use this method.
virtual void IKlvEncoder::AddKlvItemBin ( const char *  key,
const unsigned int  value 
)
pure virtual

Creates and adds a KLV item to the internal container using Binary Key and int value.

Parameters
keya pointer to the buffer containing a key.
valuea const unsigned int. A binary (int) Value.
Returns
void.
Note
Note, you should define a Key Length in the constructor in order to use this method.
virtual void IKlvEncoder::AddKlvItemBin ( const char *  key,
const unsigned __int64  value 
)
pure virtual

Creates and adds a KLV item to the internal container using Binary Key and __int64 value.

Parameters
keya const char*. A binary Key.
valuea const unsigned __int64. A binary (__int64) Value.
Returns
void.
Note
Note, you should define a Key Length in the constructor in order to use this method.
virtual char* IKlvEncoder::Encode ( size_t &  size)
pure virtual

Encodes KLV data, puts it into underlying byte array, returns encoded data buffer and its length.

Parameters
sizea size_t& Resulting byte array size.
Returns
char*. Returns a poiner to the encoded data buffer.
Note
When you start adding items after Encode function is called, all previously added items are deleted and a memory alocated for the encoded data is released.
Examples:
klvtestapp.cpp, and klvtestappuds.cpp.
virtual void IKlvEncoder::FreeInternalBuffer ( )
pure virtual

FreeInternalBuffer deletes an internal KLV buffer if allocated.

Returns
void.
virtual void IKlvEncoder::SetBuffer ( char *  buf,
const size_t  size = MAX_KLV_SIZE 
)
pure virtual

Configures KLV buffer. Upon class creation, the internal KLV buffer is allocated. If no call to the SetBuffer was made, the buffer is automatically allocated upon the first Encode call.

Parameters
bufa char*. The pointer to an externally allocated buffer. If NULL, the buffer will be allocated internally
sizea const size_t. Buffer size. If no parameter provided, the buffer will have MAX_KLV_SIZE size
Returns
void.
virtual void IKlvEncoder::SetCheckSumKey ( const char *  key)
pure virtual

Sets Checksum item key. If not NULL, a checksum item will be calculated and added after encoding

Parameters
keya const char*. An ASCI Key.
Returns
void.
Examples:
klvtestapp.cpp, and klvtestappuds.cpp.
virtual void IKlvEncoder::SetCheckSumKey ( const char *  key,
IKlvItem::KEY_LENGTH  keySize 
)
pure virtual

Sets Checksum item key (binary). If not NULL, a checksum item will be calculated and added after encoding

Parameters
keya const char*. A pointer to key buffer.
keya KEY_LENGTH. Key size.
Returns
void.
virtual void IKlvEncoder::SetOuterKey ( const char *  key)
pure virtual

Sets a high level (outer) key.

Parameters
keya const char*. A pointer to key string.
Returns
void.
Examples:
klvtestapp.cpp, and klvtestappuds.cpp.
virtual void IKlvEncoder::SetOuterKey ( const char *  key,
IKlvItem::KEY_LENGTH  keySize 
)
pure virtual

Sets a high level (outer) key (in binary format).

Parameters
keya const char*. A pointer to key buffer.
keya KEY_LENGTH. Key size.
Returns
void.
virtual void IKlvEncoder::Sort ( )
pure virtual

Sort Klv items by the tag

Returns
void.
Note
For LDS only.

Friends And Related Function Documentation

KLVLIB_API IKlvEncoder * CreateKlvEncoder ( IKlvItem::KEY_LENGTH  innerKeyLength = IKlvItem::ONE_BYTE,
BOOL  EndianSwap = TRUE 
)
related

Helper function. Instantiates KlvEncoder class

Parameters
innerKeyLengtha IKlvItem::KEY_LENGTH. Inner key length.
EndianSwapa BOOL. Defines whether Endian Swap should be performed on value data or not.
Returns
IKlvEncoder* Pointer to the KlvEncoder instance.
Note
Note, when no explicit key length provided, ONE_BYTE is used. By default, endian swap is perfromed
KLVLIB_API void doubleToByteArray ( double  val,
unsigned char *  arr 
)
related

Helper function. Converts val to byte array

KLVLIB_API void EndianSwap ( unsigned short &  x)
related

Helper function. Swaps 16 bit values

KLVLIB_API void EndianSwap ( unsigned int &  x)
related

Helper function. Swaps 32 bit values

KLVLIB_API void EndianSwap ( unsigned __int64 &  x)
related

Helper function. Swaps 64 bit values

KLVLIB_API void uint64ToByteArray ( __int64  num,
unsigned char *  arr 
)
related

Helper function. Converts __int64 to byte array

Untitled 1




 Copyright 2010,    IMPLEOTV SYSTEMS LTD