![]() |
![]() |
![]() |
Redland RDF Library Manual | ![]() |
---|---|---|---|---|
typedef librdf_query_results; librdf_stream* librdf_query_results_as_stream (librdf_query_results *query_results); int librdf_query_results_get_count (librdf_query_results *query_results); int librdf_query_results_next (librdf_query_results *query_results); int librdf_query_results_finished (librdf_query_results *query_results); int librdf_query_results_get_bindings (librdf_query_results *query_results, const char ***names, librdf_node **values); librdf_node* librdf_query_results_get_binding_value (librdf_query_results *query_results, int offset); const char* librdf_query_results_get_binding_name (librdf_query_results *query_results, int offset); librdf_node* librdf_query_results_get_binding_value_by_name (librdf_query_results *query_results, const char *name); int librdf_query_results_get_bindings_count (librdf_query_results *query_results); unsigned char* librdf_query_results_to_counted_string (librdf_query_results *query_results, librdf_uri *format_uri, librdf_uri *base_uri, size_t *length_p); unsigned char* librdf_query_results_to_string (librdf_query_results *query_results, librdf_uri *format_uri, librdf_uri *base_uri); int librdf_query_results_to_file_handle (librdf_query_results *query_results, FILE *handle, librdf_uri *format_uri, librdf_uri *base_uri); int librdf_query_results_to_file (librdf_query_results *query_results, const char *name, librdf_uri *format_uri, librdf_uri *base_uri); void librdf_free_query_results (librdf_query_results *query_results); int librdf_query_results_is_bindings (librdf_query_results *query_results); int librdf_query_results_is_boolean (librdf_query_results *query_results); int librdf_query_results_is_graph (librdf_query_results *query_results); int librdf_query_results_is_syntax (librdf_query_results *query_results); int librdf_query_results_get_boolean (librdf_query_results *query_results); librdf_query_results_formatter* librdf_new_query_results_formatter (librdf_query_results *query_results, const char *name, librdf_uri *uri); librdf_query_results_formatter* librdf_new_query_results_formatter_by_mime_type (librdf_query_results *query_results, const char *mime_type); void librdf_free_query_results_formatter (librdf_query_results_formatter *formatter); int librdf_query_results_formats_check (librdf_world *world, const char *name, librdf_uri *uri, const char *mime_type); int librdf_query_results_formats_enumerate (librdf_world *world, unsigned int counter, const char **name, const char **label, unsigned char **uri_string, const char **mime_type); typedef librdf_query_results_formatter; int librdf_query_results_formatter_write (raptor_iostream *iostr, librdf_query_results_formatter *formatter, librdf_query_results *results, librdf_uri *base_uri);
The results of an librdf_query execution as a sequence of individual results, an RDF graph as a sequence of triples or a boolean. For variable binding results, the binding names and values can be read in multiple forms and the number of results returned as well as the current result moved to the next. For an RDF graph result, the stream of triples can be returned. For a boolean result, the value can be returned. All results can be turned into a string XML format based on the SPARQL XML results format which can also be written to a file.
typedef struct librdf_query_results_s librdf_query_results;
Redland query results class.
librdf_stream* librdf_query_results_as_stream (librdf_query_results *query_results);
Get a query result as an RDF graph in librdf_stream form
The return value is only meaningful if this is an RDF graph query result - see librdf_query_results_is_graph
|
librdf_query_results query_results |
Returns : |
a new librdf_stream result or NULL on error |
int librdf_query_results_get_count (librdf_query_results *query_results);
Get number of bindings so far.
|
librdf_query_results query results |
Returns : |
number of bindings found so far |
int librdf_query_results_next (librdf_query_results *query_results);
Move to the next result.
|
librdf_query_results query results |
Returns : |
non-0 if failed or results exhausted |
int librdf_query_results_finished (librdf_query_results *query_results);
Find out if binding results are exhausted.
|
librdf_query_results query results |
Returns : |
non-0 if results are finished or query failed |
int librdf_query_results_get_bindings (librdf_query_results *query_results, const char ***names, librdf_node **values);
Get all binding names, values for current result.
If names is not NULL, it is set to the address of a shared array of names of the bindings (an output parameter). These names are shared and must not be freed by the caller
If values is not NULL, it is used as an array to store pointers to the librdf_node* of the results. These nodes must be freed by the caller. The size of the array is determined by the number of names of bindings, returned by librdf_query_get_bindings_count dynamically or will be known in advanced if hard-coded into the query string.
Example
const char **names=NULL; librdf_node* values[10];
if(librdf_query_results_get_bindings(results, &names, values)) ...
|
librdf_query_results query results |
|
pointer to an array of binding names (or NULL) |
|
pointer to an array of binding value librdf_node (or NULL) |
Returns : |
non-0 if the assignment failed |
librdf_node* librdf_query_results_get_binding_value (librdf_query_results *query_results, int offset);
Get one binding value for the current result.
|
librdf_query_results query results |
|
offset of binding name into array of known names |
Returns : |
a new librdf_node binding value or NULL on failure |
const char* librdf_query_results_get_binding_name (librdf_query_results *query_results, int offset);
Get binding name for the current result.
|
librdf_query_results query results |
|
offset of binding name into array of known names |
Returns : |
a pointer to a shared copy of the binding name or NULL on failure |
librdf_node* librdf_query_results_get_binding_value_by_name (librdf_query_results *query_results, const char *name);
Get one binding value for a given name in the current result.
|
librdf_query_results query results |
|
variable name |
Returns : |
a new librdf_node binding value or NULL on failure |
int librdf_query_results_get_bindings_count (librdf_query_results *query_results);
Get the number of bound variables in the result.
|
librdf_query_results query results |
Returns : |
<0 if failed or results exhausted |
unsigned char* librdf_query_results_to_counted_string (librdf_query_results *query_results, librdf_uri *format_uri, librdf_uri *base_uri, size_t *length_p);
Turn a query results into a string.
Values of format_uri currently supported (via Rasqal) are: http://www.w3.org/TR/2004/WD-rdf-sparql-XMLres-20041221/
The base URI may be used for the generated syntax, depending on the format.
The returned string must be freed by the caller
|
librdf_query_results object |
|
URI of syntax to format to |
|
Base URI of output formatted syntax or NULL |
|
Pointer to where to store length of string or NULL |
Returns : |
new string value or NULL on failure |
unsigned char* librdf_query_results_to_string (librdf_query_results *query_results, librdf_uri *format_uri, librdf_uri *base_uri);
Turn a query results into a string.
See librdf_query_results_to_counted_string for information on the format_uri and base_uri parameters.
The returned string must be freed by the caller
|
librdf_query_results object |
|
URI of syntax to format to |
|
Base URI of output formatted syntax |
Returns : |
new string value or NULL on failure |
int librdf_query_results_to_file_handle (librdf_query_results *query_results, FILE *handle, librdf_uri *format_uri, librdf_uri *base_uri);
Write a query results to a FILE*.
See librdf_query_results_to_counted_string for information on the format_uri and base_uri parameters.
|
librdf_query_results object |
|
file handle to write to |
|
URI of syntax to format to |
|
Base URI of output formatted syntax |
Returns : |
non 0 on failure |
int librdf_query_results_to_file (librdf_query_results *query_results, const char *name, librdf_uri *format_uri, librdf_uri *base_uri);
Write a query results to a file.
See librdf_query_results_to_counted_string for information on the format_uri and base_uri parameters.
|
librdf_query_results object |
|
filename to write to |
|
URI of syntax to format to |
|
Base URI of output formatted syntax |
Returns : |
non 0 on failure |
void librdf_free_query_results (librdf_query_results *query_results);
Destructor - destroy a librdf_query_results object.
|
librdf_query_results object |
int librdf_query_results_is_bindings (librdf_query_results *query_results);
Test if librdf_query_results is variable bindings format.
|
librdf_query_results object |
Returns : |
non-0 if true |
int librdf_query_results_is_boolean (librdf_query_results *query_results);
Test if librdf_query_results is boolean format.
If this function returns true, the result can be retrieved by
librdf_query_results_get_boolean()
.
|
librdf_query_results object |
Returns : |
non-0 if true |
int librdf_query_results_is_graph (librdf_query_results *query_results);
Test if librdf_query_results is RDF graph format.
|
librdf_query_results object |
Returns : |
non-0 if true |
int librdf_query_results_is_syntax (librdf_query_results *query_results);
Test if librdf_query_results is a syntax.
If this function returns true, the ONLY result available
from this query is a syntax that can be serialized using
one of the query_result_formatter class methods or with
librdf_query_results_to_counted_string()
, librdf_query_results_to_string()
,
librdf_query_results_to_file_handle()
or librdf_query_results_to_file()
|
librdf_query_results object |
Returns : |
non-0 if true |
int librdf_query_results_get_boolean (librdf_query_results *query_results);
Get boolean query result.
The return value is only meaningful if this is a boolean query result - see librdf_query_results_is_boolean
|
librdf_query_results query_results |
Returns : |
boolean query result - >0 is true, 0 is false, <0 on error or finished |
librdf_query_results_formatter* librdf_new_query_results_formatter (librdf_query_results *query_results, const char *name, librdf_uri *uri);
Constructor - create a new librdf_query_results_formatter object by identified format.
A query results format can be named or identified by a URI, both
of which are optional. The default query results format will be used
if both are NULL. librdf_query_results_formats_enumerate()
returns
information on the known query results names, labels and URIs.
|
librdf_query_results query_results |
|
the query results format name (or NULL) |
|
librdf_uri query results format uri (or NULL) |
Returns : |
a new librdf_query_results_formatter object or NULL on failure |
librdf_query_results_formatter* librdf_new_query_results_formatter_by_mime_type (librdf_query_results *query_results, const char *mime_type);
Constructor - create a new librdf_query_results_formatter object by mime type.
A query results format generates a syntax with a mime type which may be requested with this constructor.
Note that there may be several formatters that generate the same
MIME Type (such as SPARQL XML results format drafts) and in thot
case the librdf_new_query_results_formatter()
constructor allows
selecting of a specific one by name or URI.
|
librdf_query_results query_results |
|
mime type name |
Returns : |
a new librdf_query_results_formatter object or NULL on failure |
void librdf_free_query_results_formatter (librdf_query_results_formatter *formatter);
Destructor - destroy a librdf_query_results_formatter object.
|
librdf_query_results_formatter object |
int librdf_query_results_formats_check (librdf_world *world, const char *name, librdf_uri *uri, const char *mime_type);
Check if a query results formatter exists for the requested format.
|
librdf_world |
|
the query results format name (or NULL) |
|
librdf_uri query results format uri (or NULL) |
|
mime type name |
Returns : |
non-0 if a formatter exists. |
int librdf_query_results_formats_enumerate (librdf_world *world, unsigned int counter, const char **name, const char **label, unsigned char **uri_string, const char **mime_type);
Get information on query result syntaxes.
All returned strings are shared and must be copied if needed to be used dynamically.
|
librdf_world |
|
index into the list of query result syntaxes |
|
pointer to store the name of the query result syntax (or NULL) |
|
pointer to store query result syntax readable label (or NULL) |
|
pointer to store query result syntax URI string (or NULL) |
|
pointer to store query result syntax mime type string (or NULL) |
Returns : |
non 0 on failure of if counter is out of range |
typedef struct librdf_query_results_formatter_s librdf_query_results_formatter;
Redland query results formatter class.
int librdf_query_results_formatter_write (raptor_iostream *iostr, librdf_query_results_formatter *formatter, librdf_query_results *results, librdf_uri *base_uri);
Write the query results using the given formatter to an iostream
See librdf_query_results_formats_enumerate()
to get the
list of syntax URIs and their description.
|
raptor_iostream to write the query to |
|
librdf_query_results_formatter object |
|
librdf_query_results query results format |
|
librdf_uri base URI of the output format |
Returns : |
non-0 on failure |