company logo

Attribute access

In order to access an attribute, a value handle is required. For changing attribute values, the assign operator (=) or the function assign might be used. The data type for the attribute and the value assigned may differ, i.e. one may assign e.g. a string value to Date attribute. When conversion error happens, the assignment throws an exception.

In order to extract the content from a value, conversion functions are provided. Typically, toString(), toInteger() and toDouble() are used to return the content from a value handle in the required format. There are conversion functions for all elementary data types. Conversion function always try to convert the attribute value in to the required format, regardless of the format used for storing the value.

When calling toDate(), toDateTime() or toTime(), a Date, DateTime or Time object is returned. Those classes provide additional functionality for operating with date and time values.

In order to access attributes within complex attributes, a property path can be provided in order to create a value handle. The same way one may access elements in attribute arrays.

... fragment ( Property &person ) {

  Value  name(person,"name");

  Value  firstName(person,"first_name");

  person.top();

  while ( person.next() )

    printf("%s, %s\n",name.toString(),firstName.toString())

}