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

rdaDataEntry Class Reference

Objects of this class serve as containers that can hold a value of different types. More...

List of all members.

Public Types

enum  ValueType {
  TYPE_NULL, TYPE_BOOLEAN, TYPE_BOOLEAN_ARRAY, TYPE_BYTE,
  TYPE_BYTE_ARRAY, TYPE_SHORT, TYPE_SHORT_ARRAY, TYPE_INT,
  TYPE_INT_ARRAY, TYPE_LONG, TYPE_LONG_ARRAY, TYPE_FLOAT,
  TYPE_FLOAT_ARRAY, TYPE_DOUBLE, TYPE_DOUBLE_ARRAY, TYPE_STRING,
  TYPE_STRING_ARRAY
}
 Type codes for supported value types. More...


Public Member Functions

rdaDataEntryoperator= (const rdaDataEntry &de)
 Inserts a value contained in the specified data entry into this entry.

const char * tag () const
 Returns the tag that is assigned to this data entry in the rdaData object in which it is contained.

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

ValueType getValueType () const
 Returns the type code for the value contained in this DataEntry object.

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

The printout includes the entry tag, data type, and value.

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

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

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

Comparison operators
Two data entries considered to be equal if they contain equal values of the same type.

bool operator== (const rdaDataEntry &) const
 Compares two data entries for equality.

bool operator!= (const rdaDataEntry &) const
 Compares two data entries for inequality.

Extraction methods
Extract values from a data entry

bool extractBoolean () const
 Returns the boolean value stored in this rdaDataEntry object.

bool * extractBooleanArray (unsigned long &size) const
 Returns a copy of the boolean array stored in this rdaDataEntry object.

const bool * getBooleanArray (unsigned long &size) const
 Returns a pointer to the boolean array stored in this rdaDataEntry object.

signed char extractByte () const
 Returns the byte value stored in this rdaDataEntry object.

signed char * extractByteArray (unsigned long &size) const
 Returns a copy of the byte array stored in this rdaDataEntry object.

const signed char * getByteArray (unsigned long &size) const
 Returns a pointer to the byte array stored in this rdaDataEntry object.

short extractShort () const
 Returns the short value stored in this rdaDataEntry object.

short * extractShortArray (unsigned long &size) const
 Returns a copy of the short array stored in this rdaDataEntry object.

const short * getShortArray (unsigned long &size) const
 Returns a pointer to the short array stored in this rdaDataEntry object.

long extractInt () const
 Returns the integer value stored in this rdaDataEntry object.

long * extractIntArray (unsigned long &size) const
 Returns a copy of the integer array stored in this rdaDataEntry object.

const long * getIntArray (unsigned long &size) const
 Returns a pointer to the integer array stored in this rdaDataEntry object.

longlong extractLong () const
 Returns the longlong value stored in this rdaDataEntry object.

longlongextractLongArray (unsigned long &size) const
 Returns a copy of the longlong array stored in this rdaDataEntry object.

const longlonggetLongArray (unsigned long &size) const
 Returns a pointer to the longlong array stored in this rdaDataEntry object.

float extractFloat () const
 Returns the float value stored in this rdaDataEntry object.

float * extractFloatArray (unsigned long &size) const
 Returns a copy of the float array stored in this rdaDataEntry object.

const float * getFloatArray (unsigned long &size) const
 Returns a pointer to the float array stored in this rdaDataEntry object.

double extractDouble () const
 Returns the double value stored in this rdaDataEntry object.

double * extractDoubleArray (unsigned long &size) const
 Returns a copy of the double array stored in this rdaDataEntry object.

const double * getDoubleArray (unsigned long &size) const
 Returns a pointer to the double array stored in this rdaDataEntry object.

char * extractString () const
 Returns a copy of the string stored in this rdaDataEntry object.

const char * getString () const
 Returns a pointer to the string stored in this rdaDataEntry object.

char ** extractStringArray (unsigned long &size) const
 Returns a deep copy of the string array stored in this rdaDataEntry object.

const char ** getStringArray (unsigned long &size) const
 Returns a pointer to the string array stored in this rdaDataEntry object.

Insertion methods
Insert values into a data entry.

void insert (bool value)
 Inserts the speciifed boolean value into this rdaDataEntry object.

void insert (const bool *value, unsigned long size)
 Inserts a boolean array value into this rdaDataEntry object.

void put (const bool *value, unsigned long size)
 Inserts a boolean array "by pointer" into this rdaDataEntry object.

void insert (signed char value)
 Inserts the speciifed byte value into this rdaDataEntry object.

void insert (const signed char *value, unsigned long size)
 Inserts a byte array value into this rdaDataEntry object.

void put (const signed char *value, unsigned long size)
 Inserts a byte array "by pointer" into this rdaDataEntry object.

void insert (short value)
 Inserts the speciifed short value into this rdaDataEntry object.

void insert (const short *value, unsigned long size)
 Inserts a short array value into this rdaDataEntry object.

void put (const short *value, unsigned long size)
 Inserts a short array "by pointer" into this rdaDataEntry object.

void insert (long value)
 Inserts the speciifed integer value into this rdaDataEntry object.

void insert (const long *value, unsigned long size)
 Inserts an integer array value into this rdaDataEntry object.

void put (const long *value, unsigned long size)
 Inserts an integer array "by pointer" into this rdaDataEntry object.

void insert (longlong value)
 Inserts the speciifed long integer value into this rdaDataEntry object.

void insert (const longlong *value, unsigned long size)
 Inserts an long integer array value into this rdaDataEntry object.

void put (const longlong *value, unsigned long size)
 Inserts an long integer array "by pointer" into this rdaDataEntry object.

void insert (float value)
 Inserts the speciifed float value into this rdaDataEntry object.

void insert (const float *value, unsigned long size)
 Inserts a float array value into this rdaDataEntry object.

void put (const float *value, unsigned long size)
 Inserts a float array "by pointer" into this rdaDataEntry object.

void insert (double value)
 Inserts the speciifed double value into this rdaDataEntry object.

void insert (const double *value, unsigned long size)
 Inserts a double array value into this rdaDataEntry object.

void put (const double *value, unsigned long size)
 Inserts a double array "by pointer" into this rdaDataEntry object.

void insert (const char *value)
 Inserts the speciifed string value into this rdaDataEntry object.

void put (const char *value)
 Inserts the speciifed string "by pointer" into this rdaDataEntry object.

void insert (const char **value, unsigned long size)
 Inserts a string array value into this rdaDataEntry object.

void put (const char **value, unsigned long size)
 Inserts a string array "by pointer" into this rdaDataEntry object.


Static Public Member Functions

const char * getTypeName (ValueType typeCode)
 Returns the data type name for the specified type code.


Friends

class rdaData

Related Functions

(Note that these are not member functions.)

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


Detailed Description

Objects of this class serve as containers that can hold a value of different types.

The contained values can be single instances or single-dimensional arrays of the types listed in the table below. An rdaDataEntry object stores the value type code along with the value. Since the data entry objects can be passed between C++ and Java applications, the table provides also the correspondance between C++ and Java types.

type name C++ type Java type
Boolean bool boolean
Byte signed char byte
Short short short
Int long int
Long longlong long
Float float float
Double double double
String null-terminated char string String

A large part of the rdaDataEntry API consists of the methods for inserting values into and extracting values from a data entry.

For a given type X, these methods are:

void insert(X value)
These methods allow the insertion of a scalar value of type X.

void insert(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 X* value, unsigned long size)
Similar to insert, but only the array pointer is stored in the 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*).

Attention:
Be careful not to leave dangling pointers in data entry objects.
X extractX() const
These methods allow the extraction of a scalar value of type X from the rdaDataEntry object. They throw rdaTypeMismatch if the value contained in the entry is not of type X.

X* extractXArray(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. These methods throw rdaTypeMismatch if the entry contains something other than an array of type X, or nothing.

Attention:
Do not forget to delete extracted arrays when they are not needed anymore.
const X* getXArray(unsigned long& size) const
Return a pointer to the array of values of type X stored in the data entry. 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. This methods throw rdaTypeMismatch if the entry contains something other than an array of type X, or nothing. Note that strings can also be extracted by pointer, see getString().

Attention:
Keep in mind that the extracted pointer becomes invalid when the entry is modified or deleted.

An rdaDataEntry object is used as a component of an rdaData object. The C++ implementation of the data entry object, unlike the Java implementation, does not support "independent" data entries. The life cycle of a data entry is fully managed by the rdaData object in which it is contained. Normally, you would rarely need to use the rdaDataEntry API directly: most of the rdaDataEntry methods can (and should) be invoked through the wrapper functions of the rdaData class.

See also:
rdaData


Member Enumeration Documentation

enum rdaDataEntry::ValueType
 

Type codes for supported value types.

Enumeration values:
TYPE_NULL  indicates that a DataEntry does not contain anything.
TYPE_BOOLEAN  indicates a boolean value.
TYPE_BOOLEAN_ARRAY  indicates a boolean array value.
TYPE_BYTE  indicates a byte value.
TYPE_BYTE_ARRAY  indicates a byte array value.
TYPE_SHORT  indicates a short value.
TYPE_SHORT_ARRAY  indicates a short array value.
TYPE_INT  indicates an integer value.
TYPE_INT_ARRAY  indicates an integer array value.
TYPE_LONG  indicates a longlong value.
TYPE_LONG_ARRAY  indicates a longlong array value.
TYPE_FLOAT  indicates a float value.
TYPE_FLOAT_ARRAY  indicates a float array value.
TYPE_DOUBLE  indicates a double value.
TYPE_DOUBLE_ARRAY  indicates a double array value.
TYPE_STRING  indicates a string value.
TYPE_STRING_ARRAY  indicates a string array value.


Member Function Documentation

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

Prints contents of this data entry to the standard output.

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

Deprecated:
use print methods

bool rdaDataEntry::extractBoolean  )  const
 

Returns the boolean value stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a boolean, or nothing.

bool* rdaDataEntry::extractBooleanArray unsigned long &  size  )  const
 

Returns a copy of the boolean array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a boolean array, or nothing.

signed char rdaDataEntry::extractByte  )  const
 

Returns the byte value stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a byte, or nothing.

signed char* rdaDataEntry::extractByteArray unsigned long &  size  )  const
 

Returns a copy of the byte array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a byte array, or nothing.

double rdaDataEntry::extractDouble  )  const
 

Returns the double value stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a double, or nothing.

double* rdaDataEntry::extractDoubleArray unsigned long &  size  )  const
 

Returns a copy of the double array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a double array, or nothing.

float rdaDataEntry::extractFloat  )  const
 

Returns the float value stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a float, or nothing.

float* rdaDataEntry::extractFloatArray unsigned long &  size  )  const
 

Returns a copy of the float array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a float array, or nothing.

long rdaDataEntry::extractInt  )  const
 

Returns the integer value stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than an integer, or nothing.

long* rdaDataEntry::extractIntArray unsigned long &  size  )  const
 

Returns a copy of the integer array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than an integer array, or nothing.

longlong rdaDataEntry::extractLong  )  const
 

Returns the longlong value stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a longlong, or nothing.

longlong* rdaDataEntry::extractLongArray unsigned long &  size  )  const
 

Returns a copy of the longlong array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a longlong array, or nothing.

short rdaDataEntry::extractShort  )  const
 

Returns the short value stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a short, or nothing.

short* rdaDataEntry::extractShortArray unsigned long &  size  )  const
 

Returns a copy of the short array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a short array, or nothing.

char* rdaDataEntry::extractString  )  const
 

Returns a copy of the string stored in this rdaDataEntry object.

Caller must delete the returned string when finished with it.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a string, or nothing.

char** rdaDataEntry::extractStringArray unsigned long &  size  )  const
 

Returns a deep copy of the string array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a string array, or nothing.

const bool* rdaDataEntry::getBooleanArray unsigned long &  size  )  const
 

Returns a pointer to the boolean array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a boolean array, or nothing.

const signed char* rdaDataEntry::getByteArray unsigned long &  size  )  const
 

Returns a pointer to the byte array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a byte array, or nothing.

const double* rdaDataEntry::getDoubleArray unsigned long &  size  )  const
 

Returns a pointer to the double array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a double array, or nothing.

const float* rdaDataEntry::getFloatArray unsigned long &  size  )  const
 

Returns a pointer to the float array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a float array, or nothing.

const long* rdaDataEntry::getIntArray unsigned long &  size  )  const
 

Returns a pointer to the integer array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than an integer array, or nothing.

const longlong* rdaDataEntry::getLongArray unsigned long &  size  )  const
 

Returns a pointer to the longlong array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a longlong array, or nothing.

const short* rdaDataEntry::getShortArray unsigned long &  size  )  const
 

Returns a pointer to the short array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a short array, or nothing.

const char* rdaDataEntry::getString  )  const
 

Returns a pointer to the string stored in this rdaDataEntry object.

Caller must delete the returned string when finished with it.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a string, or nothing.

const char** rdaDataEntry::getStringArray unsigned long &  size  )  const
 

Returns a pointer to the string array stored in this rdaDataEntry object.

Exceptions:
rdaTypeMismatch thrown if this entry contains something other than a string array, or nothing.

const char* rdaDataEntry::getTypeName ValueType  typeCode  )  [static]
 

Returns the data type name for the specified type code.

result string type code
"null" TYPE_NULL
"Boolean" TYPE_BOOLEAN
"Byte" TYPE_BYTE
"Short" TYPE_SHORT
"Int" TYPE_INT
"Long" TYPE_LONG
"Float" TYPE_FLOAT
"Double" TYPE_DOUBLE
"String" TYPE_STRING
"undefined" not defined in ValueType

For array types, the basic type name is followed by "[]", for example, "Byte[]" for TYPE_BYTE_ARRAY.

void rdaDataEntry::insert const char **  value,
unsigned long  size
 

Inserts a string array value into this rdaDataEntry object.

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 rdaDataEntry::insert const char *  value  ) 
 

Inserts the speciifed string value into this rdaDataEntry object.

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 rdaDataEntry::insert const double *  value,
unsigned long  size
 

Inserts a double array value into this rdaDataEntry object.

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

void rdaDataEntry::insert const float *  value,
unsigned long  size
 

Inserts a float array value into this rdaDataEntry object.

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

void rdaDataEntry::insert const longlong value,
unsigned long  size
 

Inserts an long integer array value into this rdaDataEntry object.

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

void rdaDataEntry::insert const long *  value,
unsigned long  size
 

Inserts an integer array value into this rdaDataEntry object.

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

void rdaDataEntry::insert const short *  value,
unsigned long  size
 

Inserts a short array value into this rdaDataEntry object.

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

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

Inserts a byte array value into this rdaDataEntry object.

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

void rdaDataEntry::insert const bool *  value,
unsigned long  size
 

Inserts a boolean array value into this rdaDataEntry object.

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

void rdaDataEntry::print unsigned long  maxElements  )  const
 

Prints contents of this data entry to the standard output.

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

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

Prints contents of this data entry to the specified file.

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

void rdaDataEntry::put const char **  value,
unsigned long  size
 

Inserts a string array "by pointer" into this rdaDataEntry object.

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 rdaDataEntry::put const char *  value  ) 
 

Inserts the speciifed string "by pointer" into this rdaDataEntry object.

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 rdaDataEntry::put const double *  value,
unsigned long  size
 

Inserts a double array "by pointer" into this rdaDataEntry object.

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

void rdaDataEntry::put const float *  value,
unsigned long  size
 

Inserts a float array "by pointer" into this rdaDataEntry object.

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

void rdaDataEntry::put const longlong value,
unsigned long  size
 

Inserts an long integer array "by pointer" into this rdaDataEntry object.

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

void rdaDataEntry::put const long *  value,
unsigned long  size
 

Inserts an integer array "by pointer" into this rdaDataEntry object.

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

void rdaDataEntry::put const short *  value,
unsigned long  size
 

Inserts a short array "by pointer" into this rdaDataEntry object.

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

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

Inserts a byte array "by pointer" into this rdaDataEntry object.

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

void rdaDataEntry::put const bool *  value,
unsigned long  size
 

Inserts a boolean array "by pointer" into this rdaDataEntry object.

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

const char* rdaDataEntry::tag  )  const
 

Returns the tag that is assigned to this data entry in the rdaData object in which it is contained.

See also:
rdaData


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