Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages | Examples

rdaData Class Reference

Allows clients and servers to exchange values whose types are not fixed at compile time. More...

List of all members.

Public Member Functions

 rdaData ()
 Constructs an empty rdaData object.

 rdaData (const rdaData &data)
 Copy constructs an rdaData object.

virtual ~rdaData ()
 Destructor.

rdaDataoperator= (const rdaData &data)
 Removes all entries from this rdaData object and copies into it all entries conatained in the specified data object.

void asciiDump (unsigned long maxElements=5) const
 Prints contents of this Data object to the standard output.

bool contains (const char *tag) const
 Returns true if this rdaData object contains an entry with the specified tag;false otherwise.

bool isEmpty () const
 Returns true if this rdaData contains no entries; false otherwise.

rdaDataEntryget (const char *tag) const
 Returns a pointer to the entry with the specified tag, or NULL if there is no such entry in this rdaData object.

void remove (const char *tag)
 Removes an entry with the specified tag from this data object.

void removeAll ()
 Removes all entries from this data object.

Print methods
These methods send a text representation of the data object to the standard output or a file.

The printout includes tags, data types, and values for all entries contained in this data.

void print (FILE *fp, unsigned long maxElements) const
 Prints contents of this data object to the specified file.

void print (unsigned long maxElements) const
 Prints contents of this data object to the standard output.

void print () const
 Prints contents of this data object to the standard output.

Extraction methods
Used to extract values from the data object

bool extractBoolean (const char *tag) const
 Returns the boolean value stored in the data entry identified by tag.

bool * extractBooleanArray (const char *tag, unsigned long &size) const
 Returns a copy of the boolean array stored in the data entry identified by tag.

const bool * getBooleanArray (const char *tag, unsigned long &size) const
 Returns a pointer to the boolean array stored in the entry identified by tag.

signed char extractByte (const char *tag) const
 Returns the byte value stored in the data entry identified by tag.

signed char * extractByteArray (const char *tag, unsigned long &size) const
 Returns a copy of the byte array stored in the data entry identified by tag.

const signed char * getByteArray (const char *tag, unsigned long &size) const
 Returns a pointer to the byte array stored in the entry identified by tag.

short extractShort (const char *tag) const
 Returns the short value stored in the data entry identified by tag.

short * extractShortArray (const char *tag, unsigned long &size) const
 Returns a copy of the short array stored in the data entry identified by tag.

const short * getShortArray (const char *tag, unsigned long &size) const
 Returns a pointer to the short array stored in the entry identified by tag.

long extractInt (const char *tag) const
 Returns the integer value stored in the data entry identified by tag.

long * extractIntArray (const char *tag, unsigned long &size) const
 Returns a copy of the integer array stored in the data entry identified by tag.

const long * getIntArray (const char *tag, unsigned long &size) const
 Returns a pointer to the integer array stored in the entry identified by tag.

longlong extractLong (const char *tag) const
 Returns the longlong value stored in the data entry identified by tag.

longlongextractLongArray (const char *tag, unsigned long &size) const
 Returns a copy of the longlong array stored in the data entry identified by tag.

const longlonggetLongArray (const char *tag, unsigned long &size) const
 Returns a pointer to the longlong array stored in the entry identified by tag.

float extractFloat (const char *tag) const
 Returns the float value stored in the data entry identified by tag.

float * extractFloatArray (const char *tag, unsigned long &size) const
 Returns a copy of the float array stored in the data entry identified by tag.

const float * getFloatArray (const char *tag, unsigned long &size) const
 Returns a pointer to the float array stored in the entry identified by tag.

double extractDouble (const char *tag) const
 Returns the double value stored in the data entry identified by tag.

double * extractDoubleArray (const char *tag, unsigned long &size) const
 Returns a copy of the double array stored in the data entry identified by tag.

const double * getDoubleArray (const char *tag, unsigned long &size) const
 Returns a pointer to the double array stored in the entry identified by tag.

char * extractString (const char *tag) const
 Returns a copy of the string stored in the data entry identified by tag.

const char * getString (const char *tag) const
 Returns a pointer to the string stored in the entry identified by tag.

char ** extractStringArray (const char *tag, unsigned long &size) const
 Returns a deep copy of the string array stored in the data entry identified by tag.

const char ** getStringArray (const char *tag, unsigned long &size) const
 Returns a pointer to the string array stored in the entry identified by tag.

Insertion methods
Used to insert values into the data object.

void insert (const char *tag, bool value)
 Inserts the boolean value into the entry identified by tag.

void insert (const char *tag, const bool *value, unsigned long size)
 Inserts the boolean array value into the entry identified by tag.

void put (const char *tag, const bool *value, unsigned long size)
 Inserts a boolean array "by pointer" into the entry identified by tag.

void insert (const char *tag, signed char value)
 Inserts the byte value into the entry identified by tag.

void insert (const char *tag, const signed char *value, unsigned long size)
 Inserts the byte array value into the entry identified by tag.

void put (const char *tag, const signed char *value, unsigned long size)
 Inserts a byte array "by pointer" into the entry identified by tag.

void insert (const char *tag, short value)
 Inserts the short value into the entry identified by tag.

void insert (const char *tag, const short *value, unsigned long size)
 Inserts the short array value into the entry identified by tag.

void put (const char *tag, const short *value, unsigned long size)
 Inserts a short array "by pointer" into the entry identified by tag.

void insert (const char *tag, long value)
 Inserts the integer value into the entry identified by tag.

void insert (const char *tag, const long *value, unsigned long size)
 Inserts the integer array value into the entry identified by tag.

void put (const char *tag, const long *value, unsigned long size)
 Inserts an integer array "by pointer" into the entry identified by tag.

void insert (const char *tag, longlong value)
 Inserts the longlong value into the entry identified by tag.

void insert (const char *tag, const longlong *value, unsigned long size)
 Inserts the longlong array value into the entry identified by tag.

void put (const char *tag, const longlong *value, unsigned long size)
 Inserts a longlong array "by pointer" into the entry identified by tag.

void insert (const char *tag, float value)
 Inserts the float value into the entry identified by tag.

void insert (const char *tag, const float *value, unsigned long size)
 Inserts the float array value into the entry identified by tag.

void put (const char *tag, const float *value, unsigned long size)
 Inserts a float array "by pointer" into the entry identified by tag.

void insert (const char *tag, double value)
 Inserts the double value into the entry identified by tag.

void insert (const char *tag, const double *value, unsigned long size)
 Inserts the double array value into the entry identified by tag.

void put (const char *tag, const double *value, unsigned long size)
 Inserts a double array "by pointer" into the entry identified by tag.

void insert (const char *tag, const char *value)
 Inserts the string value into the entry identified by tag.

void put (const char *tag, const char *value)
 Inserts the string value "by pointer" into the entry identified by tag.

void insert (const char *tag, const char **value, unsigned long size)
 Inserts the string array value into the entry identified by tag.

void put (const char *tag, const char **value, unsigned long size)
 Inserts a string array "by pointer" into the entry identified by tag.


Friends

class rdaDataIterator

Related Functions

(Note that these are not member functions.)

ostream & operator<< (ostream &os, const rdaData &data)
 Prints a string representation of the data object to the output stream os.


Detailed Description

Allows clients and servers to exchange values whose types are not fixed at compile time.

An rdaData object may contain zero or more rdaDataEntry objects; each entry is uniquely identified by a string tag. The entries can be accessed sequentially (see rdaDataIterator) or randomly by tags.

Each entry can store a value of different types: see rdaDataEntry for the description of supported data types. For each supported type, the rdaData class provides methods for inserting values into and extracting values from a data entry. For a given type X, these methods are:

void insert(const char* tag, X value)
This method inserts a scalar value of type X into an entry identified by tag. If there is no such entry, it will be created and added to the data object.

void insert(const char* tag, const X* value, unsigned long size)
Same for an array of values of type X. All array insertion methods make a copy of the array value speciifed by the arguments, and store it in the entry.

void put(const char* tag, const X* value, unsigned long size)
Similar to insert, but only the array pointer is stored in the data object (no copy). The array data is kept in the user space. Note that strings can also be inserted by pointer, see put(const char*, const char*).

Attention:
Be careful not to leave dangling pointers in data objects.
X extractX(const char* tag) const
This method allows the extraction of a scalar value of type X from an entry identified by tag. It throws the rdaBadParameter exception if there is no such entry in the data object, and the rdaTypeMismatch exception if the type of the value contained in the entry is not X.

X* extractXArray(const char* tag, unsigned long& size) const
Same for an array of values of type X. On return, the size argument contains the number of elements in the extracted array. The extracted array is a copy of the contained data; it is dynamically allocated and must be released by the caller. If the entry contains an empty array (size = 0) then the NULL value is returned.

Attention:
Do not forget to delete extracted arrays when they are not needed anymore.
const X* getXArray(const char* tag, unsigned long& size) const
Returns a pointer to the array of values of type X stored in the entry identified by tag. On return, the size argument contains the number of elements in the stored array. If the entry contains an empty array (size = 0) then the NULL value is returned. Note that strings can also be extracted by pointer, see #getString(const char*).

Attention:
Keep in mind that the extracted pointer may become invalid when the data object is modified or deleted.
Examples:

Decode.cpp, and Encode.cpp.


Member Function Documentation

void rdaData::asciiDump unsigned long  maxElements = 5  )  const
 

Prints contents of this Data object to the standard output.

If a data entry contains an array, at most maxElements of the array will be included in the printout.

Deprecated:
use print methods

bool rdaData::extractBoolean const char *  tag  )  const
 

Returns the boolean value stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a boolean, or nothing.

bool* rdaData::extractBooleanArray const char *  tag,
unsigned long &  size
const
 

Returns a copy of the boolean array stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a boolean array, or nothing.

signed char rdaData::extractByte const char *  tag  )  const
 

Returns the byte value stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a byte, or nothing.

signed char* rdaData::extractByteArray const char *  tag,
unsigned long &  size
const
 

Returns a copy of the byte array stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a byte array, or nothing.

double rdaData::extractDouble const char *  tag  )  const
 

Returns the double value stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a double, or nothing.

double* rdaData::extractDoubleArray const char *  tag,
unsigned long &  size
const
 

Returns a copy of the double array stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a double array, or nothing.

float rdaData::extractFloat const char *  tag  )  const
 

Returns the float value stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a float, or nothing.

float* rdaData::extractFloatArray const char *  tag,
unsigned long &  size
const
 

Returns a copy of the float array stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a float array, or nothing.

long rdaData::extractInt const char *  tag  )  const
 

Returns the integer value stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than an int, or nothing.

long* rdaData::extractIntArray const char *  tag,
unsigned long &  size
const
 

Returns a copy of the integer array stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than an integer array, or nothing.

longlong rdaData::extractLong const char *  tag  )  const
 

Returns the longlong value stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a longlong, or nothing.

longlong* rdaData::extractLongArray const char *  tag,
unsigned long &  size
const
 

Returns a copy of the longlong array stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a longlong array, or nothing.

short rdaData::extractShort const char *  tag  )  const
 

Returns the short value stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a short, or nothing.

short* rdaData::extractShortArray const char *  tag,
unsigned long &  size
const
 

Returns a copy of the short array stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a short array, or nothing.

char* rdaData::extractString const char *  tag  )  const
 

Returns a copy of the string stored in the data entry identified by tag.

The returned string must be released by the caller when it is no longer needed.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a string, or nothing.

char** rdaData::extractStringArray const char *  tag,
unsigned long &  size
const
 

Returns a deep copy of the string array stored in the data entry identified by tag.

Exceptions:
BadParameter thrown if this rdaData does not contain the specified entry
TypeMismatch thrown if the entry contains something other than a string array, or nothing.

const bool* rdaData::getBooleanArray const char *  tag,
unsigned long &  size
const
 

Returns a pointer to the boolean array stored in the entry identified by tag.

Exceptions:
BadParameter thrown if this data object does not contain the specified entry
rdaTypeMismatch thrown if the entry contains something other than a boolean array, or nothing.

const signed char* rdaData::getByteArray const char *  tag,
unsigned long &  size
const
 

Returns a pointer to the byte array stored in the entry identified by tag.

Exceptions:
BadParameter thrown if this data object does not contain the specified entry
rdaTypeMismatch thrown if the entry contains something other than a byte array, or nothing.

const double* rdaData::getDoubleArray const char *  tag,
unsigned long &  size
const
 

Returns a pointer to the double array stored in the entry identified by tag.

Exceptions:
BadParameter thrown if this data object does not contain the specified entry
rdaTypeMismatch thrown if the entry contains something other than a double array, or nothing.

const float* rdaData::getFloatArray const char *  tag,
unsigned long &  size
const
 

Returns a pointer to the float array stored in the entry identified by tag.

Exceptions:
BadParameter thrown if this data object does not contain the specified entry
rdaTypeMismatch thrown if the entry contains something other than a float array, or nothing.

const long* rdaData::getIntArray const char *  tag,
unsigned long &  size
const
 

Returns a pointer to the integer array stored in the entry identified by tag.

Exceptions:
BadParameter thrown if this data object does not contain the specified entry
rdaTypeMismatch thrown if the entry contains something other than an integer array, or nothing.

const longlong* rdaData::getLongArray const char *  tag,
unsigned long &  size
const
 

Returns a pointer to the longlong array stored in the entry identified by tag.

Exceptions:
BadParameter thrown if this data object does not contain the specified entry
rdaTypeMismatch thrown if the entry contains something other than a longlong array, or nothing.

const short* rdaData::getShortArray const char *  tag,
unsigned long &  size
const
 

Returns a pointer to the short array stored in the entry identified by tag.

Exceptions:
BadParameter thrown if this data object does not contain the specified entry
rdaTypeMismatch thrown if the entry contains something other than a short array, or nothing.

const char* rdaData::getString const char *  tag  )  const
 

Returns a pointer to the string stored in the entry identified by tag.

Exceptions:
BadParameter thrown if this data object does not contain the specified entry
rdaTypeMismatch thrown if the entry contains something other than a string, or nothing.

const char** rdaData::getStringArray const char *  tag,
unsigned long &  size
const
 

Returns a pointer to the string array stored in the entry identified by tag.

Exceptions:
BadParameter thrown if this data object does not contain the specified entry
rdaTypeMismatch thrown if the entry contains something other than a string array, or nothing.

void rdaData::insert const char *  tag,
const char **  value,
unsigned long  size
 

Inserts the string array value into the entry identified by tag.

The method makes a deep copy of the value array, and stores it the data entry.

Parameters:
value pointer to the array data. Each element of the array must be a pointer to null-terminated character string.
size number of elements in the array

void rdaData::insert const char *  tag,
const char *  value
 

Inserts the string value into the entry identified by tag.

The method makes a copy of the value string, and stores it in the data entry.

Parameters:
value pointer to a null-terminated character string.

void rdaData::insert const char *  tag,
const double *  value,
unsigned long  size
 

Inserts the double array value into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::insert const char *  tag,
const float *  value,
unsigned long  size
 

Inserts the float array value into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::insert const char *  tag,
const longlong value,
unsigned long  size
 

Inserts the longlong array value into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::insert const char *  tag,
const long *  value,
unsigned long  size
 

Inserts the integer array value into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::insert const char *  tag,
const short *  value,
unsigned long  size
 

Inserts the short array value into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::insert const char *  tag,
const signed char *  value,
unsigned long  size
 

Inserts the byte array value into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::insert const char *  tag,
const bool *  value,
unsigned long  size
 

Inserts the boolean array value into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::print unsigned long  maxElements  )  const
 

Prints contents of this data object to the standard output.

For array values, at most maxElements of the array will be included in the printout.

void rdaData::print FILE *  fp,
unsigned long  maxElements
const
 

Prints contents of this data object to the specified file.

For for array values, at most maxElements of the array will be included in the printout.

Examples:
Decode.cpp.

void rdaData::put const char *  tag,
const char **  value,
unsigned long  size
 

Inserts a string array "by pointer" into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::put const char *  tag,
const char *  value
 

Inserts the string value "by pointer" into the entry identified by tag.

Parameters:
value pointer to a null-terminated character string.

void rdaData::put const char *  tag,
const double *  value,
unsigned long  size
 

Inserts a double array "by pointer" into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::put const char *  tag,
const float *  value,
unsigned long  size
 

Inserts a float array "by pointer" into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::put const char *  tag,
const longlong value,
unsigned long  size
 

Inserts a longlong array "by pointer" into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::put const char *  tag,
const long *  value,
unsigned long  size
 

Inserts an integer array "by pointer" into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::put const char *  tag,
const short *  value,
unsigned long  size
 

Inserts a short array "by pointer" into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::put const char *  tag,
const signed char *  value,
unsigned long  size
 

Inserts a byte array "by pointer" into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::put const char *  tag,
const bool *  value,
unsigned long  size
 

Inserts a boolean array "by pointer" into the entry identified by tag.

Parameters:
value pointer to the array data
size number of elements in the array

void rdaData::remove const char *  tag  ) 
 

Removes an entry with the specified tag from this data object.

This method does nothing if there is no such entry in the data.


The documentation for this class was generated from the following file:
RDA-2.3 documentation - 27 Jun 2007 - N.Trofimov