<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
]>
<refentry id="redland-query-results">
<refmeta>
<refentrytitle role="top_of_page" id="redland-query-results.top_of_page">Query results</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>REDLAND Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Query results</refname>
<refpurpose>RDF query results.</refpurpose>
<!--[<xref linkend="desc" endterm="desc.title"/>]-->
</refnamediv>

<refsynopsisdiv id="redland-query-results.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>
typedef             <link linkend="librdf-query-results">librdf_query_results</link>;
<link linkend="librdf-stream">librdf_stream</link>*      <link linkend="librdf-query-results-as-stream">librdf_query_results_as_stream</link>      (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-get-count">librdf_query_results_get_count</link>      (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-next">librdf_query_results_next</link>           (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-finished">librdf_query_results_finished</link>       (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-get-bindings">librdf_query_results_get_bindings</link>   (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> ***names,
                                                         <link linkend="librdf-node">librdf_node</link> **values);
<link linkend="librdf-node">librdf_node</link>*        <link linkend="librdf-query-results-get-binding-value">librdf_query_results_get_binding_value</link>
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="int">int</link> offset);
const <link linkend="char">char</link>*         <link linkend="librdf-query-results-get-binding-name">librdf_query_results_get_binding_name</link>
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="int">int</link> offset);
<link linkend="librdf-node">librdf_node</link>*        <link linkend="librdf-query-results-get-binding-value-by-name">librdf_query_results_get_binding_value_by_name</link>
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> *name);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-get-bindings-count">librdf_query_results_get_bindings_count</link>
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
unsigned <link linkend="char">char</link>*      <link linkend="librdf-query-results-to-counted-string">librdf_query_results_to_counted_string</link>
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="librdf-uri">librdf_uri</link> *format_uri,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri,
                                                         <link linkend="size-t">size_t</link> *length_p);
unsigned <link linkend="char">char</link>*      <link linkend="librdf-query-results-to-string">librdf_query_results_to_string</link>      (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="librdf-uri">librdf_uri</link> *format_uri,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-to-file-handle">librdf_query_results_to_file_handle</link> (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="FILE:CAPS">FILE</link> *handle,
                                                         <link linkend="librdf-uri">librdf_uri</link> *format_uri,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-to-file">librdf_query_results_to_file</link>        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> *name,
                                                         <link linkend="librdf-uri">librdf_uri</link> *format_uri,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri);
<link linkend="void">void</link>                <link linkend="librdf-free-query-results">librdf_free_query_results</link>           (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-is-bindings">librdf_query_results_is_bindings</link>    (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-is-boolean">librdf_query_results_is_boolean</link>     (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-is-graph">librdf_query_results_is_graph</link>       (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-is-syntax">librdf_query_results_is_syntax</link>      (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-get-boolean">librdf_query_results_get_boolean</link>    (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);
<link linkend="librdf-query-results-formatter">librdf_query_results_formatter</link>* <link linkend="librdf-new-query-results-formatter">librdf_new_query_results_formatter</link>
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> *name,
                                                         <link linkend="librdf-uri">librdf_uri</link> *uri);
<link linkend="librdf-query-results-formatter">librdf_query_results_formatter</link>* <link linkend="librdf-new-query-results-formatter-by-mime-type">librdf_new_query_results_formatter_by_mime_type</link>
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> *mime_type);
<link linkend="void">void</link>                <link linkend="librdf-free-query-results-formatter">librdf_free_query_results_formatter</link> (<link linkend="librdf-query-results-formatter">librdf_query_results_formatter</link> *formatter);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-formats-check">librdf_query_results_formats_check</link>  (<link linkend="librdf-world">librdf_world</link> *world,
                                                         const <link linkend="char">char</link> *name,
                                                         <link linkend="librdf-uri">librdf_uri</link> *uri,
                                                         const <link linkend="char">char</link> *mime_type);
<link linkend="int">int</link>                 <link linkend="librdf-query-results-formats-enumerate">librdf_query_results_formats_enumerate</link>
                                                        (<link linkend="librdf-world">librdf_world</link> *world,
                                                         unsigned <link linkend="int">int</link> counter,
                                                         const <link linkend="char">char</link> **name,
                                                         const <link linkend="char">char</link> **label,
                                                         unsigned <link linkend="char">char</link> **uri_string,
                                                         const <link linkend="char">char</link> **mime_type);
typedef             <link linkend="librdf-query-results-formatter">librdf_query_results_formatter</link>;
<link linkend="int">int</link>                 <link linkend="librdf-query-results-formatter-write">librdf_query_results_formatter_write</link>
                                                        (<link linkend="raptor-iostream">raptor_iostream</link> *iostr,
                                                         <link linkend="librdf-query-results-formatter">librdf_query_results_formatter</link> *formatter,
                                                         <link linkend="librdf-query-results">librdf_query_results</link> *results,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri);
</synopsis>
</refsynopsisdiv>









<refsect1 id="redland-query-results.description" role="desc">
<title role="desc.title">Description</title>
<para>
The results of an <link linkend="librdf-query"><type>librdf_query</type></link> 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.
</para>
</refsect1>

<refsect1 id="redland-query-results.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="librdf-query-results" role="typedef">
<title>librdf_query_results</title>
<indexterm zone="librdf-query-results"><primary>librdf_query_results</primary></indexterm><programlisting>typedef struct librdf_query_results_s librdf_query_results;
</programlisting>
<para>
Redland query results class.</para>
<para>

</para></refsect2>
<refsect2 id="librdf-query-results-as-stream" role="function">
<title>librdf_query_results_as_stream ()</title>
<indexterm zone="librdf-query-results-as-stream"><primary>librdf_query_results_as_stream</primary></indexterm><programlisting><link linkend="librdf-stream">librdf_stream</link>*      librdf_query_results_as_stream      (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Get a query result as an RDF graph in <link linkend="librdf-stream"><type>librdf_stream</type></link> form
</para>
<para>
The return value is only meaningful if this is an RDF graph
query result - see <link linkend="librdf-query-results-is-graph"><type>librdf_query_results_is_graph</type></link></para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query_results
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="librdf-stream"><type>librdf_stream</type></link> result or NULL on error
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-get-count" role="function">
<title>librdf_query_results_get_count ()</title>
<indexterm zone="librdf-query-results-get-count"><primary>librdf_query_results_get_count</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_get_count      (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Get number of bindings so far.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query results
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> number of bindings found so far
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-next" role="function">
<title>librdf_query_results_next ()</title>
<indexterm zone="librdf-query-results-next"><primary>librdf_query_results_next</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_next           (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Move to the next result.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query results
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 if failed or results exhausted
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-finished" role="function">
<title>librdf_query_results_finished ()</title>
<indexterm zone="librdf-query-results-finished"><primary>librdf_query_results_finished</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_finished       (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Find out if binding results are exhausted.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query results
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 if results are finished or query failed
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-get-bindings" role="function">
<title>librdf_query_results_get_bindings ()</title>
<indexterm zone="librdf-query-results-get-bindings"><primary>librdf_query_results_get_bindings</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_get_bindings   (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> ***names,
                                                         <link linkend="librdf-node">librdf_node</link> **values);</programlisting>
<para>
Get all binding names, values for current result.
</para>
<para>
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
</para>
<para>
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.
</para>
<para>
Example
</para>
<para>
const char **names=NULL;
librdf_node* values[10];
</para>
<para>
if(librdf_query_results_get_bindings(results, &amp;names, values))
  ...</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query results
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>names</parameter>&nbsp;:</term>
<listitem><simpara> pointer to an array of binding names (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>values</parameter>&nbsp;:</term>
<listitem><simpara> pointer to an array of binding value <link linkend="librdf-node"><type>librdf_node</type></link> (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 if the assignment failed
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-get-binding-value" role="function">
<title>librdf_query_results_get_binding_value ()</title>
<indexterm zone="librdf-query-results-get-binding-value"><primary>librdf_query_results_get_binding_value</primary></indexterm><programlisting><link linkend="librdf-node">librdf_node</link>*        librdf_query_results_get_binding_value
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="int">int</link> offset);</programlisting>
<para>
Get one binding value for the current result.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query results
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset</parameter>&nbsp;:</term>
<listitem><simpara> offset of binding name into array of known names
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="librdf-node"><type>librdf_node</type></link> binding value or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-get-binding-name" role="function">
<title>librdf_query_results_get_binding_name ()</title>
<indexterm zone="librdf-query-results-get-binding-name"><primary>librdf_query_results_get_binding_name</primary></indexterm><programlisting>const <link linkend="char">char</link>*         librdf_query_results_get_binding_name
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="int">int</link> offset);</programlisting>
<para>
Get binding name for the current result.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query results
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>offset</parameter>&nbsp;:</term>
<listitem><simpara> offset of binding name into array of known names
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a pointer to a shared copy of the binding name or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-get-binding-value-by-name" role="function">
<title>librdf_query_results_get_binding_value_by_name ()</title>
<indexterm zone="librdf-query-results-get-binding-value-by-name"><primary>librdf_query_results_get_binding_value_by_name</primary></indexterm><programlisting><link linkend="librdf-node">librdf_node</link>*        librdf_query_results_get_binding_value_by_name
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> *name);</programlisting>
<para>
Get one binding value for a given name in the current result.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query results
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>name</parameter>&nbsp;:</term>
<listitem><simpara> variable name
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="librdf-node"><type>librdf_node</type></link> binding value or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-get-bindings-count" role="function">
<title>librdf_query_results_get_bindings_count ()</title>
<indexterm zone="librdf-query-results-get-bindings-count"><primary>librdf_query_results_get_bindings_count</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_get_bindings_count
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Get the number of bound variables in the result.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query results
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> &lt;0 if failed or results exhausted
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-to-counted-string" role="function">
<title>librdf_query_results_to_counted_string ()</title>
<indexterm zone="librdf-query-results-to-counted-string"><primary>librdf_query_results_to_counted_string</primary></indexterm><programlisting>unsigned <link linkend="char">char</link>*      librdf_query_results_to_counted_string
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="librdf-uri">librdf_uri</link> *format_uri,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri,
                                                         <link linkend="size-t">size_t</link> *length_p);</programlisting>
<para>
Turn a query results into a string.
</para>
<para>
Values of format_uri currently supported (via Rasqal) are:
 http://www.w3.org/TR/2004/WD-rdf-sparql-XMLres-20041221/
</para>
<para>
The base URI may be used for the generated syntax, depending
on the format.
</para>
<para>
The returned string must be freed by the caller</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>format_uri</parameter>&nbsp;:</term>
<listitem><simpara> URI of syntax to format to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>base_uri</parameter>&nbsp;:</term>
<listitem><simpara> Base URI of output formatted syntax  or NULL
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>length_p</parameter>&nbsp;:</term>
<listitem><simpara> Pointer to where to store length of string or NULL
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> new string value or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-to-string" role="function">
<title>librdf_query_results_to_string ()</title>
<indexterm zone="librdf-query-results-to-string"><primary>librdf_query_results_to_string</primary></indexterm><programlisting>unsigned <link linkend="char">char</link>*      librdf_query_results_to_string      (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="librdf-uri">librdf_uri</link> *format_uri,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri);</programlisting>
<para>
Turn a query results into a string.
</para>
<para>
See librdf_query_results_to_counted_string for information on the
format_uri and base_uri parameters.
</para>
<para>
The returned string must be freed by the caller</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>format_uri</parameter>&nbsp;:</term>
<listitem><simpara> URI of syntax to format to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>base_uri</parameter>&nbsp;:</term>
<listitem><simpara> Base URI of output formatted syntax 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> new string value or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-to-file-handle" role="function">
<title>librdf_query_results_to_file_handle ()</title>
<indexterm zone="librdf-query-results-to-file-handle"><primary>librdf_query_results_to_file_handle</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_to_file_handle (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         <link linkend="FILE:CAPS">FILE</link> *handle,
                                                         <link linkend="librdf-uri">librdf_uri</link> *format_uri,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri);</programlisting>
<para>
Write a query results to a FILE*.
</para>
<para>
See librdf_query_results_to_counted_string for information on the
format_uri and base_uri parameters.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>handle</parameter>&nbsp;:</term>
<listitem><simpara> file handle to write to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>format_uri</parameter>&nbsp;:</term>
<listitem><simpara> URI of syntax to format to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>base_uri</parameter>&nbsp;:</term>
<listitem><simpara> Base URI of output formatted syntax 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non 0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-to-file" role="function">
<title>librdf_query_results_to_file ()</title>
<indexterm zone="librdf-query-results-to-file"><primary>librdf_query_results_to_file</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_to_file        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> *name,
                                                         <link linkend="librdf-uri">librdf_uri</link> *format_uri,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri);</programlisting>
<para>
Write a query results to a file.
</para>
<para>
See librdf_query_results_to_counted_string for information on the
format_uri and base_uri parameters.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>name</parameter>&nbsp;:</term>
<listitem><simpara> filename to write to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>format_uri</parameter>&nbsp;:</term>
<listitem><simpara> URI of syntax to format to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>base_uri</parameter>&nbsp;:</term>
<listitem><simpara> Base URI of output formatted syntax 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non 0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-free-query-results" role="function">
<title>librdf_free_query_results ()</title>
<indexterm zone="librdf-free-query-results"><primary>librdf_free_query_results</primary></indexterm><programlisting><link linkend="void">void</link>                librdf_free_query_results           (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Destructor - destroy a <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-is-bindings" role="function">
<title>librdf_query_results_is_bindings ()</title>
<indexterm zone="librdf-query-results-is-bindings"><primary>librdf_query_results_is_bindings</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_is_bindings    (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Test if librdf_query_results is variable bindings format.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 if true
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-is-boolean" role="function">
<title>librdf_query_results_is_boolean ()</title>
<indexterm zone="librdf-query-results-is-boolean"><primary>librdf_query_results_is_boolean</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_is_boolean     (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Test if librdf_query_results is boolean format.
</para>
<para>
If this function returns true, the result can be retrieved by
<link linkend="librdf-query-results-get-boolean"><function>librdf_query_results_get_boolean()</function></link>.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 if true
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-is-graph" role="function">
<title>librdf_query_results_is_graph ()</title>
<indexterm zone="librdf-query-results-is-graph"><primary>librdf_query_results_is_graph</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_is_graph       (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Test if librdf_query_results is RDF graph format.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 if true
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-is-syntax" role="function">
<title>librdf_query_results_is_syntax ()</title>
<indexterm zone="librdf-query-results-is-syntax"><primary>librdf_query_results_is_syntax</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_is_syntax      (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Test if librdf_query_results is a syntax.
</para>
<para>
If this function returns true, the ONLY result available
from this query is a syntax that can be serialized using
one of the <link linkend="query-result-formatter"><type>query_result_formatter</type></link> class methods or with
<link linkend="librdf-query-results-to-counted-string"><function>librdf_query_results_to_counted_string()</function></link>, <link linkend="librdf-query-results-to-string"><function>librdf_query_results_to_string()</function></link>,
<link linkend="librdf-query-results-to-file-handle"><function>librdf_query_results_to_file_handle()</function></link> or <link linkend="librdf-query-results-to-file"><function>librdf_query_results_to_file()</function></link></para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 if true
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-get-boolean" role="function">
<title>librdf_query_results_get_boolean ()</title>
<indexterm zone="librdf-query-results-get-boolean"><primary>librdf_query_results_get_boolean</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_get_boolean    (<link linkend="librdf-query-results">librdf_query_results</link> *query_results);</programlisting>
<para>
Get boolean query result.
</para>
<para>
The return value is only meaningful if this is a boolean
query result - see <link linkend="librdf-query-results-is-boolean"><type>librdf_query_results_is_boolean</type></link></para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query_results
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> boolean query result - &gt;0 is true, 0 is false, &lt;0 on error or finished
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-new-query-results-formatter" role="function">
<title>librdf_new_query_results_formatter ()</title>
<indexterm zone="librdf-new-query-results-formatter"><primary>librdf_new_query_results_formatter</primary></indexterm><programlisting><link linkend="librdf-query-results-formatter">librdf_query_results_formatter</link>* librdf_new_query_results_formatter
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> *name,
                                                         <link linkend="librdf-uri">librdf_uri</link> *uri);</programlisting>
<para>
Constructor - create a new librdf_query_results_formatter object by identified format.
</para>
<para>
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.  <link linkend="librdf-query-results-formats-enumerate"><function>librdf_query_results_formats_enumerate()</function></link> returns
information on the known query results names, labels and URIs.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query_results
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>name</parameter>&nbsp;:</term>
<listitem><simpara> the query results format name (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>uri</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-uri"><type>librdf_uri</type></link> query results format uri (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="librdf-query-results-formatter"><type>librdf_query_results_formatter</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-new-query-results-formatter-by-mime-type" role="function">
<title>librdf_new_query_results_formatter_by_mime_type ()</title>
<indexterm zone="librdf-new-query-results-formatter-by-mime-type"><primary>librdf_new_query_results_formatter_by_mime_type</primary></indexterm><programlisting><link linkend="librdf-query-results-formatter">librdf_query_results_formatter</link>* librdf_new_query_results_formatter_by_mime_type
                                                        (<link linkend="librdf-query-results">librdf_query_results</link> *query_results,
                                                         const <link linkend="char">char</link> *mime_type);</programlisting>
<para>
Constructor - create a new librdf_query_results_formatter object by mime type.
</para>
<para>
A query results format generates a syntax with a mime type which
may be requested with this constructor.
</para>
<para>
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 <link linkend="librdf-new-query-results-formatter"><function>librdf_new_query_results_formatter()</function></link> constructor allows
selecting of a specific one by name or URI.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>query_results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query_results
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>mime_type</parameter>&nbsp;:</term>
<listitem><simpara> mime type name
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> a new <link linkend="librdf-query-results-formatter"><type>librdf_query_results_formatter</type></link> object or NULL on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-free-query-results-formatter" role="function">
<title>librdf_free_query_results_formatter ()</title>
<indexterm zone="librdf-free-query-results-formatter"><primary>librdf_free_query_results_formatter</primary></indexterm><programlisting><link linkend="void">void</link>                librdf_free_query_results_formatter (<link linkend="librdf-query-results-formatter">librdf_query_results_formatter</link> *formatter);</programlisting>
<para>
Destructor - destroy a <link linkend="librdf-query-results-formatter"><type>librdf_query_results_formatter</type></link> object.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>formatter</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results-formatter"><type>librdf_query_results_formatter</type></link> object
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-formats-check" role="function">
<title>librdf_query_results_formats_check ()</title>
<indexterm zone="librdf-query-results-formats-check"><primary>librdf_query_results_formats_check</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_formats_check  (<link linkend="librdf-world">librdf_world</link> *world,
                                                         const <link linkend="char">char</link> *name,
                                                         <link linkend="librdf-uri">librdf_uri</link> *uri,
                                                         const <link linkend="char">char</link> *mime_type);</programlisting>
<para>
Check if a query results formatter exists for the requested format.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>world</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-world"><type>librdf_world</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>name</parameter>&nbsp;:</term>
<listitem><simpara> the query results format name (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>uri</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-uri"><type>librdf_uri</type></link> query results format uri (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>mime_type</parameter>&nbsp;:</term>
<listitem><simpara> mime type name
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 if a formatter exists.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-formats-enumerate" role="function">
<title>librdf_query_results_formats_enumerate ()</title>
<indexterm zone="librdf-query-results-formats-enumerate"><primary>librdf_query_results_formats_enumerate</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_formats_enumerate
                                                        (<link linkend="librdf-world">librdf_world</link> *world,
                                                         unsigned <link linkend="int">int</link> counter,
                                                         const <link linkend="char">char</link> **name,
                                                         const <link linkend="char">char</link> **label,
                                                         unsigned <link linkend="char">char</link> **uri_string,
                                                         const <link linkend="char">char</link> **mime_type);</programlisting>
<para>
Get information on query result syntaxes.
</para>
<para>
All returned strings are shared and must be copied if needed to be
used dynamically.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>world</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-world"><type>librdf_world</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>counter</parameter>&nbsp;:</term>
<listitem><simpara> index into the list of query result syntaxes
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>name</parameter>&nbsp;:</term>
<listitem><simpara> pointer to store the name of the query result syntax (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>label</parameter>&nbsp;:</term>
<listitem><simpara> pointer to store query result syntax readable label (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>uri_string</parameter>&nbsp;:</term>
<listitem><simpara> pointer to store query result syntax URI string (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>mime_type</parameter>&nbsp;:</term>
<listitem><simpara> pointer to store query result syntax mime type string (or NULL)
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non 0 on failure of if counter is out of range
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="librdf-query-results-formatter" role="typedef">
<title>librdf_query_results_formatter</title>
<indexterm zone="librdf-query-results-formatter"><primary>librdf_query_results_formatter</primary></indexterm><programlisting>typedef struct librdf_query_results_formatter_s librdf_query_results_formatter;
</programlisting>
<para>
Redland query results formatter class.</para>
<para>

</para></refsect2>
<refsect2 id="librdf-query-results-formatter-write" role="function">
<title>librdf_query_results_formatter_write ()</title>
<indexterm zone="librdf-query-results-formatter-write"><primary>librdf_query_results_formatter_write</primary></indexterm><programlisting><link linkend="int">int</link>                 librdf_query_results_formatter_write
                                                        (<link linkend="raptor-iostream">raptor_iostream</link> *iostr,
                                                         <link linkend="librdf-query-results-formatter">librdf_query_results_formatter</link> *formatter,
                                                         <link linkend="librdf-query-results">librdf_query_results</link> *results,
                                                         <link linkend="librdf-uri">librdf_uri</link> *base_uri);</programlisting>
<para>
Write the query results using the given formatter to an iostream
</para>
<para>
See <link linkend="librdf-query-results-formats-enumerate"><function>librdf_query_results_formats_enumerate()</function></link> to get the
list of syntax URIs and their description.</para>
<para>

</para><variablelist role="params">
<varlistentry><term><parameter>iostr</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="raptor-iostream"><type>raptor_iostream</type></link> to write the query to
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>formatter</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results-formatter"><type>librdf_query_results_formatter</type></link> object
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>results</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-query-results"><type>librdf_query_results</type></link> query results format
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>base_uri</parameter>&nbsp;:</term>
<listitem><simpara> <link linkend="librdf-uri"><type>librdf_uri</type></link> base URI of the output format
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&nbsp;:</term><listitem><simpara> non-0 on failure
</simpara></listitem></varlistentry>
</variablelist></refsect2>

</refsect1>




</refentry>
