Structured data instance type. More...
#include "swdataapi.h"
Data Fields | |
unsigned char | type |
unsigned char | subtype |
unsigned char | flags |
unsigned char | owner_data |
const void * | owner |
size_t | length |
union { | |
const void * opaque | |
const char * string | |
int integer | |
HqBool boolean | |
float real | |
} | value |
Structured data instance type.
Modules may create raw sw_datum values, including arrays and dictionaries (associative arrays), but must ensure that all fields are initialised properly. Static initializers are provided which can be used to initialise local datums, which can then be used directly or copied to initialise dynamically allocated datums.
For a raw sw_datum array of n elements, value.opaque points to a contiguous array of n sw_datum items. For a dictionary of n key/value pairs it points to a contiguous array of n * 2 sw_datum items. (Raw stacks are not useful because their size cannot be safely changed, so push and pop are not supported.) The owner field must be set to NULL for raw datums created by a module, and should never be modified for data provided to the module. Note however it is possible for a module to implement the sw_data_api itself and hence build 'owned' datums.
Modules may treat all arrays and dictionaries as opaque and use the api access methods even for values it has created itself. However, arrays and dictionaries with a non-NULL owner are always opaque and their contents can only be accessed using the API.
HqBool sw_datum::boolean |
Value for booleans (TRUE or FALSE).
unsigned char sw_datum::flags |
No flags defined yet, initialise to zero.
int sw_datum::integer |
Value of integers.
size_t sw_datum::length |
Length of a string, array or dictionary.
const void* sw_datum::opaque |
One of the opaque structured types.
const void* sw_datum::owner |
The owner of opaque values. The module should set to NULL for objects it creates, and should never alter this field for opaque objects provided by the RIP.
unsigned char sw_datum::owner_data |
Data value defined and used by the owner of the data. Initialise to zero for objects created by the module.
float sw_datum::real |
Value for reals.
const char* sw_datum::string |
Pointer to an unterminated read-only string.
unsigned char sw_datum::subtype |
Normally zero, see SW_DATUM_SUBTYPES.
unsigned char sw_datum::type |
One of the SW_DATUM_TYPES values.
union { ... } sw_datum::value |
A union containing the value of the datum. The branch of the value to use depends on the type field.