|  |  |  | Rasqal RDF Query Library Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
typedef rasqal_variables_table; rasqal_variables_table * rasqal_new_variables_table (rasqal_world *world); void rasqal_free_variables_table (rasqal_variables_table *vt); rasqal_variable * rasqal_variables_table_add (rasqal_variables_table *vt,rasqal_variable_type type,const char *name,rasqal_literal *value); int rasqal_variables_table_add_variable (rasqal_variables_table *vt,rasqal_variable *variable); rasqal_variable * rasqal_variables_table_get_by_name (rasqal_variables_table *vt,rasqal_variable_type type,const char *name); int rasqal_variables_table_contains (rasqal_variables_table *vt,rasqal_variable_type type,const char *name);
A table of rasqal_variable usually associated with a rasqal_query query or rasqal_query_results query result set. The order of the variables in the table may be significant, such as for a standalone query result set in which case it might define the order of variables in resulting rows.
typedef struct rasqal_variables_table_s rasqal_variables_table;
Internal - for now
rasqal_variables_table * rasqal_new_variables_table     (rasqal_world *world);
Constructor - create a new variables table
| 
 | rasqal world | 
| Returns : | new variables table or NULL On failure | 
void                rasqal_free_variables_table         (rasqal_variables_table *vt);
Destructor - destroy a new variables table
| 
 | rasqal variables table | 
rasqal_variable * rasqal_variables_table_add (rasqal_variables_table *vt,rasqal_variable_type type,const char *name,rasqal_literal *value);
Constructor - Create a new variable and add it to the variables table
The name and value become owned by the rasqal_variable
structure.  If a variable with the name already exists, that is
returned and the new value is ignored.
| 
 | rasqal_variables_table to associate the variable with | 
| 
 | variable type defined by enumeration rasqal_variable_type | 
| 
 | variable name | 
| 
 | variable rasqal_literal value (or NULL) | 
| Returns : | a new rasqal_variable or NULL on failure. | 
int rasqal_variables_table_add_variable (rasqal_variables_table *vt,rasqal_variable *variable);
Constructor - Add an existing variable to the variables table
The variables table vt takes a reference to variable.  This
function will fail if the variable is already in the table.  Use
rasqal_variables_table_contains() to check before calling.
| 
 | rasqal_variables_table to associate the variable with | 
| 
 | existing variable to add | 
| Returns : | non-0 on failure (such as name already exists) | 
rasqal_variable * rasqal_variables_table_get_by_name (rasqal_variables_table *vt,rasqal_variable_type type,const char *name);
Lookup a variable by type and name in the variables table.
Note that looking up for any type RASQAL_VARIABLE_TYPE_UNKNOWN may a name match but for any type so in cases where the query has both a named and anonymous (extensional) variable, an arbitrary one will be returned.
| 
 | the variables table | 
| 
 | the variable type to match or RASQAL_VARIABLE_TYPE_UNKNOWN for any. | 
| 
 | the variable type | 
| Returns : | a shared pointer to the rasqal_variable or NULL if not found | 
int rasqal_variables_table_contains (rasqal_variables_table *vt,rasqal_variable_type type,const char *name);
Check if there is a variable with the given type and name in the variables table
| 
 | rasqal_variables_table to lookup | 
| 
 | variable type | 
| 
 | variable name | 
| Returns : | non-0 if the variable is present |