#include <dballe/core/error.h>
#include <dballe/core/vartable.h>
#include <stdio.h>
Go to the source code of this file.
Typedefs | |
typedef struct _dba_var * | dba_var |
Holds a DBALLE variable. | |
typedef struct _dba_var_attr * | dba_var_attr_iterator |
Cursor for iterating through the attributes of a dba_var. | |
Functions | |
dba_err | dba_var_create (dba_varinfo info, dba_var *var) |
Create a new dba_var. | |
dba_err | dba_var_createi (dba_varinfo info, int val, dba_var *var) |
Create a new dba_var, setting it to an integer value. | |
dba_err | dba_var_created (dba_varinfo info, double val, dba_var *var) |
Create a new dba_var, setting it to a double value. | |
dba_err | dba_var_createc (dba_varinfo info, const char *val, dba_var *var) |
Create a new dba_var, setting it to a character value. | |
dba_err | dba_var_create_local (dba_varcode code, dba_var *var) |
Create a variable with informations from the local table. | |
dba_err | dba_var_copy (dba_var source, dba_var *dest) |
Make an exact copy of a dba_var. | |
void | dba_var_delete (dba_var var) |
Delete a dba_var. | |
int | dba_var_equals (const dba_var var1, const dba_var var2) |
Check if two variables contains the same data. | |
dba_err | dba_var_enqi (dba_var var, int *val) |
Get the value of a dba_var, as an integer. | |
dba_err | dba_var_enqd (dba_var var, double *val) |
Get the value of a dba_var, as a double. | |
dba_err | dba_var_enqc (dba_var var, const char **val) |
Get the value of a dba_var, as a string. | |
dba_err | dba_var_seti (dba_var var, int val) |
Set the value of a dba_var, from an integer value. | |
dba_err | dba_var_setd (dba_var var, double val) |
Set the value of a dba_var, from a double value. | |
dba_err | dba_var_setc (dba_var var, const char *val) |
Set the value of a dba_var, from a string value. | |
dba_err | dba_var_unset (dba_var var) |
Unset the value of a dba_var. | |
dba_err | dba_var_enqa (dba_var var, dba_varcode code, dba_var *attr) |
Query variable attributes. | |
dba_err | dba_var_seta (dba_var var, dba_var attr) |
Set an attribute of the variable. | |
dba_err | dba_var_seta_nocopy (dba_var var, dba_var attr) |
Set an attribute of the variable. | |
dba_err | dba_var_unseta (dba_var var, dba_varcode code) |
Remove the attribute with the given code. | |
void | dba_var_clear_attrs (dba_var var) |
Remove all attributes from the variable. | |
dba_varcode | dba_var_code (dba_var var) |
Retrieve the dba_varcode for a variable. | |
dba_varinfo | dba_var_info (dba_var var) |
Get informations about the variable. | |
const char * | dba_var_value (dba_var var) |
Retrieve the internal string representation of the value for a variable. | |
dba_var_attr_iterator | dba_var_attr_iterate (dba_var var) |
Start iterating through all the attributes of a variable. | |
dba_var_attr_iterator | dba_var_attr_iterator_next (dba_var_attr_iterator iter) |
Advance a dba_var_attr_iterator to point to the next attribute. | |
dba_var | dba_var_attr_iterator_attr (dba_var_attr_iterator iter) |
Get the attribute pointed by a dba_var_attr_iterator. | |
dba_err | dba_var_copy_val (dba_var dest, dba_var orig) |
Copy a value from a variable to another, performing conversions if needed. | |
dba_err | dba_var_copy_attrs (dba_var dest, dba_var src) |
Copy all the attributes from one variable to another. | |
dba_err | dba_var_convert (dba_var orig, dba_varinfo info, dba_var *conv) |
Convert a variable to an equivalent variable using different informations. | |
int | dba_var_encode_int (double fval, dba_varinfo info) |
Encode a double value into an integer value using varinfo encoding informations. | |
double | dba_var_decode_int (int val, dba_varinfo info) |
Decode a double value from integer value using varinfo encoding informations. | |
void | dba_var_print (dba_var var, FILE *out) |
Print the variable to an output stream. | |
void | dba_var_diff (dba_var var1, dba_var var2, int *diffs, FILE *out) |
Print the difference between two variables to an output stream. |
typedef struct _dba_var* dba_var |
Holds a DBALLE variable.
A dba_var contains:
dba_var_attr_iterator dba_var_attr_iterate | ( | dba_var | var | ) |
Start iterating through all the attributes of a variable.
var | The variable to work on |
dba_var dba_var_attr_iterator_attr | ( | dba_var_attr_iterator | iter | ) |
Get the attribute pointed by a dba_var_attr_iterator.
iter | The iterator to work on |
dba_var_attr_iterator dba_var_attr_iterator_next | ( | dba_var_attr_iterator | iter | ) |
Advance a dba_var_attr_iterator to point to the next attribute.
iter | The iterator to work on |
void dba_var_clear_attrs | ( | dba_var | var | ) |
Remove all attributes from the variable.
var | The variable to work on |
dba_varcode dba_var_code | ( | dba_var | var | ) |
Retrieve the dba_varcode for a variable.
This function cannot fail, as dba_var always have a varcode value.
var | Variable to query |
dba_err dba_var_convert | ( | dba_var | orig, | |
dba_varinfo | info, | |||
dba_var * | conv | |||
) |
Convert a variable to an equivalent variable using different informations.
orig | The variable to convert | |
info | The dba_varinfo describing the target of the conversion |
conv | The converted variable. It needs to be deallocated using dba_var_delete(). |
Make an exact copy of a dba_var.
source | The variable to copy |
dest | The new copy of source. It will need to be deallocated using dba_var_delete(). |
Copy all the attributes from one variable to another.
dest | The variable that will hold the attributes. | |
src | The variable with the attributes to copy. |
Copy a value from a variable to another, performing conversions if needed.
dest | The variable to write the value to | |
orig | The variable to read the value from |
dba_err dba_var_create | ( | dba_varinfo | info, | |
dba_var * | var | |||
) |
Create a new dba_var.
info | The dba_varinfo that describes the variable |
var | The variable created. It will need to be deallocated using dba_var_delete(). |
dba_err dba_var_create_local | ( | dba_varcode | code, | |
dba_var * | var | |||
) |
Create a variable with informations from the local table.
code | The dba_varcode that identifies the variable in the local B table. See vartable.h |
var | The variable created. It will need to be deallocated using dba_var_delete(). |
dba_err dba_var_createc | ( | dba_varinfo | info, | |
const char * | val, | |||
dba_var * | var | |||
) |
Create a new dba_var, setting it to a character value.
info | The dba_varinfo that describes the variable | |
val | The initial value for the variable |
var | The variable created. It will need to be deallocated using dba_var_delete(). |
dba_err dba_var_created | ( | dba_varinfo | info, | |
double | val, | |||
dba_var * | var | |||
) |
Create a new dba_var, setting it to a double value.
info | The dba_varinfo that describes the variable | |
val | The initial value for the variable |
var | The variable created. It will need to be deallocated using dba_var_delete(). |
dba_err dba_var_createi | ( | dba_varinfo | info, | |
int | val, | |||
dba_var * | var | |||
) |
Create a new dba_var, setting it to an integer value.
info | The dba_varinfo that describes the variable | |
val | The initial value for the variable |
var | The variable created. It will need to be deallocated using dba_var_delete(). |
double dba_var_decode_int | ( | int | val, | |
dba_varinfo | info | |||
) |
Decode a double value from integer value using varinfo encoding informations.
val | Value to decode | |
info | dba_varinfo structure to use for the encoding informations |
void dba_var_delete | ( | dba_var | var | ) |
Delete a dba_var.
var | The variable to delete |
Print the difference between two variables to an output stream.
If there is no difference, it does not print anything.
var1 | The first variable to compare | |
var2 | The second variable to compare |
diffs | Incremented by 1 if the variables differ |
out | The output stream to use for printing |
int dba_var_encode_int | ( | double | fval, | |
dba_varinfo | info | |||
) |
Encode a double value into an integer value using varinfo encoding informations.
fval | Value to encode | |
info | dba_varinfo structure to use for the encoding informations |
dba_err dba_var_enqa | ( | dba_var | var, | |
dba_varcode | code, | |||
dba_var * | attr | |||
) |
Query variable attributes.
var | The variable to query | |
code | The dba_varcode of the attribute requested. See vartable.h |
attr | A pointer to the attribute if it exists, else NULL. The pointer points to the internal representation and must not be deallocated by the caller. |
Get the value of a dba_var, as a string.
var | The variable to query |
val | The resulting value |
Get the value of a dba_var, as a double.
var | The variable to query |
val | The resulting value |
Get the value of a dba_var, as an integer.
var | The variable to query |
val | The resulting value |
Check if two variables contains the same data.
var1 | First variable to compare | |
var2 | Second variable to compare |
dba_varinfo dba_var_info | ( | dba_var | var | ) |
Get informations about the variable.
var | The variable to query informations for |
void dba_var_print | ( | dba_var | var, | |
FILE * | out | |||
) |
Print the variable to an output stream.
var | The variable to print | |
out | The output stream to use for printing |
Set an attribute of the variable.
An existing attribute with the same dba_varcode will be replaced.
var | The variable to work on | |
attr | The attribute to add. It will be copied inside var, and memory management will still be in charge of the caller. |
Set an attribute of the variable.
An existing attribute with the same dba_varcode will be replaced.
var | The variable to work on | |
attr | The attribute to add. It will be used directly, and var will take care of its memory management. |
Set the value of a dba_var, from a string value.
var | The variable to set | |
val | The value to set |
Set the value of a dba_var, from a double value.
var | The variable to set | |
val | The value to set |
Set the value of a dba_var, from an integer value.
var | The variable to set | |
val | The value to set |
Unset the value of a dba_var.
var | The variable to unset |
dba_err dba_var_unseta | ( | dba_var | var, | |
dba_varcode | code | |||
) |
Remove the attribute with the given code.
var | The variable to work on | |
code | The dba_varcode of the attribute to remove. See vartable.h |
const char* dba_var_value | ( | dba_var | var | ) |
Retrieve the internal string representation of the value for a variable.
var | Variable to query |