Diffusion C API  6.4.3
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
diffusion-recordv2-record-model.h File Reference

DIFFUSION_RECORDV2_RECORD_MODEL data model. More...

Typedefs

typedef struct
DIFFUSION_RECORDV2_RECORD_MODEL_T 
DIFFUSION_RECORDV2_RECORD_MODEL_T
 Opaque recordv2 record model data type.
 

Functions

bool diffusion_recordv2_record_model_as_value (const DIFFUSION_RECORDV2_RECORD_MODEL_T *record_model, DIFFUSION_VALUE_T **value, DIFFUSION_API_ERROR *error)
 Creates an immutable DIFFUSION_VALUE_T generated from the model. More...
 
bool diffusion_recordv2_record_model_field_count (const DIFFUSION_RECORDV2_RECORD_MODEL_T *record_model, const char *record_name, int record_index, const char *field_name, int *field_count, DIFFUSION_API_ERROR *error)
 Returns the actual number of occurrences of a named field within a specified record occurrences. More...
 
bool diffusion_recordv2_record_model_get_field_value_with_key (const DIFFUSION_RECORDV2_RECORD_MODEL_T *record_model, const char *key, char **field_value, DIFFUSION_API_ERROR *error)
 Get a field value. More...
 
bool diffusion_recordv2_record_model_get_field_value (const DIFFUSION_RECORDV2_RECORD_MODEL_T *record_model, const char *record_name, int record_index, const char *field_name, int field_index, char **field_value, DIFFUSION_API_ERROR *error)
 Get a field value. More...
 
bool diffusion_recordv2_record_model_record_count (const DIFFUSION_RECORDV2_RECORD_MODEL_T *record_model, const char *record_name, int *record_count, DIFFUSION_API_ERROR *error)
 Returns the actual number of occurrences of a named record. More...
 
void diffusion_recordv2_record_model_free (DIFFUSION_RECORDV2_RECORD_MODEL_T *record_model)
 Free a recordv2 record model. More...
 

Detailed Description

DIFFUSION_RECORDV2_RECORD_MODEL data model.

A read only model can be created from any RecordV2 DIFFUSION_VALUE_T object using the diffusion_recordv2_as_model function. The model then provides direct access to the fields within the data. Fields may be accessed either by explicitly specifying the record and field occurrence or by specifying a key of the form:

recordName(recordIndex).fieldName(fieldIndex)

Function Documentation

bool diffusion_recordv2_record_model_as_value ( const DIFFUSION_RECORDV2_RECORD_MODEL_T record_model,
DIFFUSION_VALUE_T **  value,
DIFFUSION_API_ERROR error 
)

Creates an immutable DIFFUSION_VALUE_T generated from the model.

Parameters
record_modelthe model to generate the value from
valuepointer to a pointer which will have its value set to the DIFFUSION_VALUE_T
errorpopulated if an error occurs. Can be NULL.
Returns
true if the record model was transformed into a DIFFUSION_VALUE_T. False otherwise.
bool diffusion_recordv2_record_model_field_count ( const DIFFUSION_RECORDV2_RECORD_MODEL_T record_model,
const char *  record_name,
int  record_index,
const char *  field_name,
int *  field_count,
DIFFUSION_API_ERROR error 
)

Returns the actual number of occurrences of a named field within a specified record occurrences.

For all but variable fields this simply returns the schema defined number of occurrences of the field.

Parameters
record_modelthe model to retrieve the field count from
record_namethe record's name
record_indexthe record index
field_namethe field name
field_countpointer to a variable which will have its value set to the field count
errorpopulated if an error occurs. Can be NULL.
Returns
true if the record model's field count was successfully retrieved. False otherwise.
void diffusion_recordv2_record_model_free ( DIFFUSION_RECORDV2_RECORD_MODEL_T record_model)

Free a recordv2 record model.

Parameters
record_modelrecord model to be freed.
bool diffusion_recordv2_record_model_get_field_value ( const DIFFUSION_RECORDV2_RECORD_MODEL_T record_model,
const char *  record_name,
int  record_index,
const char *  field_name,
int  field_index,
char **  field_value,
DIFFUSION_API_ERROR error 
)

Get a field value.

Parameters
record_modelthe record model
record_namethe record name
record_indexthe record's index
field_namethe field name
field_indexthe field's index
field_valuepointer to a variable which will have its value set to the field value. Must be freed after use.
errorpopulated if an error occurs. Can be NULL.
Returns
true if the record model's field value was successfully retrieved. False otherwise.
bool diffusion_recordv2_record_model_get_field_value_with_key ( const DIFFUSION_RECORDV2_RECORD_MODEL_T record_model,
const char *  key,
char **  field_value,
DIFFUSION_API_ERROR error 
)

Get a field value.

This allows an item to be addressed using a key of the form recordName(recordIndex).fieldName(fieldIndex). Indexes may be omitted in which case 0 is assumed. The record part may also be omitted in which case the first occurrence of the first record is assumed.

Parameters
record_modelthe record model to retrieve the field value from
key
field_valuepointer to the field_value variable which will have its value set to the field value.
errorpopulated if an error occurs. Can be NULL.
Returns
true if the record model's field value was successfully retrieved. False otherwise.
bool diffusion_recordv2_record_model_record_count ( const DIFFUSION_RECORDV2_RECORD_MODEL_T record_model,
const char *  record_name,
int *  record_count,
DIFFUSION_API_ERROR error 
)

Returns the actual number of occurrences of a named record.

If the record is not variable, this is the same as the defined number of occurrences in the schema.

Parameters
record_modelthe record model
record_namethe record name
record_countpointer to a variable which will have its value set to the record count.
errorpopulated if an error occurs. Can be NULL.
Returns
true if the record model's record count was successfully retrieved. False otherwise.