glib-Relations-and-Tuples.html   [plain text]


<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Relations and Tuples</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib-data-types.html" title="GLib Data Types"><link rel="previous" href="glib-Datasets.html" title="Datasets"><link rel="next" href="glib-Caches.html" title="Caches"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="refentry" href="glib-building.html" title="Compiling the GLib package"><link rel="refentry" href="glib-cross-compiling.html" title="Cross-compiling the GLib package"><link rel="refentry" href="glib-compiling.html" title="Compiling GLib Applications"><link rel="refentry" href="glib-running.html" title="Running GLib Applications"><link rel="refentry" href="glib-changes.html" title="Changes to GLib"><link rel="refentry" href="glib-resources.html" title="Mailing lists and bug reports"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="refentry" href="glib-Basic-Types.html" title="Basic Types"><link rel="refentry" href="glib-Limits-of-Basic-Types.html" title="Limits of Basic Types"><link rel="refentry" href="glib-Standard-Macros.html" title="Standard Macros"><link rel="refentry" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros"><link rel="refentry" href="glib-Byte-Order-Macros.html" title="Byte Order Macros"><link rel="refentry" href="glib-Numerical-Definitions.html" title="Numerical Definitions"><link rel="refentry" href="glib-Miscellaneous-Macros.html" title="Miscellaneous Macros"><link rel="refentry" href="glib-Atomic-Operations.html" title="Atomic Operations"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="refentry" href="glib-The-Main-Event-Loop.html" title="The Main Event Loop"><link rel="refentry" href="glib-Threads.html" title="
Threads"><link rel="refentry" href="glib-Thread-Pools.html" title="Thread Pools"><link rel="refentry" href="glib-Asynchronous-Queues.html" title="Asynchronous Queues"><link rel="refentry" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules"><link rel="refentry" href="glib-Memory-Allocation.html" title="Memory Allocation"><link rel="refentry" href="glib-IO-Channels.html" title="IO Channels"><link rel="refentry" href="glib-Error-Reporting.html" title="Error Reporting"><link rel="refentry" href="glib-Warnings-and-Assertions.html" title="Message Output and Debugging Functions"><link rel="refentry" href="glib-Message-Logging.html" title="Message Logging"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="refentry" href="glib-String-Utility-Functions.html" title="String Utility Functions"><link rel="refentry" href="glib-Character-Set-Conversion.html" title="Character Set Conversion"><link rel="refentry" href="glib-Unicode-Manipulation.html" title="Unicode Manipulation"><link rel="refentry" href="glib-I18N.html" title="Internationalization"><link rel="refentry" href="glib-Date-and-Time-Functions.html" title="Date and Time Functions"><link rel="refentry" href="glib-Random-Numbers.html" title="Random Numbers"><link rel="refentry" href="glib-Hook-Functions.html" title="Hook Functions"><link rel="refentry" href="glib-Miscellaneous-Utility-Functions.html" title="Miscellaneous Utility Functions"><link rel="refentry" href="glib-Lexical-Scanner.html" title="Lexical Scanner"><link rel="refentry" href="glib-Automatic-String-Completion.html" title="Automatic String Completion"><link rel="refentry" href="glib-Timers.html" title="Timers"><link rel="refentry" href="glib-Spawning-Processes.html" title="Spawning Processes"><link rel="refentry" href="glib-File-Utilities.html" title="File Utilities"><link rel="refentry" href="glib-Shell-related-Utilities.html" title="Shell-related Utilities"><link rel="refentry" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching"><link rel="refentry" href="glib-Simple-XML-Subset-Parser.html" title="Simple XML Subset Parser"><link rel="refentry" href="glib-Windows-Compatability-Functions.html" title="Windows Compatibility Functions"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="refentry" href="glib-Memory-Chunks.html" title="Memory Chunks"><link rel="refentry" href="glib-Doubly-Linked-Lists.html" title="Doubly-Linked Lists"><link rel="refentry" href="glib-Singly-Linked-Lists.html" title="Singly-Linked Lists"><link rel="refentry" href="glib-Double-ended-Queues.html" title="Double-ended Queues"><link rel="refentry" href="glib-Trash-Stacks.html" title="Trash Stacks"><link rel="refentry" href="glib-Hash-Tables.html" title="Hash Tables"><link rel="refentry" href="glib-Strings.html" title="Strings"><link rel="refentry" href="glib-String-Chunks.html" title="String Chunks"><link rel="refentry" href="glib-Arrays.html" title="Arrays"><link rel="refentry" href="glib-Pointer-Arrays.html" title="Pointer Arrays"><link rel="refentry" href="glib-Byte-Arrays.html" title="Byte Arrays"><link rel="refentry" href="glib-Balanced-Binary-Trees.html" title="Balanced Binary Trees"><link rel="refentry" href="glib-N-ary-Trees.html" title="N-ary Trees"><link rel="refentry" href="glib-Quarks.html" title="Quarks"><link rel="refentry" href="glib-Keyed-Data-Lists.html" title="Keyed Data Lists"><link rel="refentry" href="glib-Datasets.html" title="Datasets"><link rel="refentry" href="glib-Relations-and-Tuples.html" title="Relations and Tuples"><link rel="refentry" href="glib-Caches.html" title="Caches"><link rel="refentry" href="glib-Memory-Allocators.html" title="Memory Allocators"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="refentry" href="glib-gettextize.html" title="glib-gettextize"><link rel="index" href="ix01.html" title="Index"><link rel="section" href="glib-Relations-and-Tuples.html#id3334100" title="Description"><link rel="section" href="glib-Relations-and-Tuples.html#id3334339" title="Details"><meta name="generator" content="GTK-Doc V1.2 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-Datasets.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-Caches.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-Relations-and-Tuples"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">Relations and Tuples</span></h2><p>Relations and Tuples &#8212; tables of data which can be indexed on any number of fields.</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">

#include &lt;glib.h&gt;


struct      <a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a>;
<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a>*  <a href="glib-Relations-and-Tuples.html#g-relation-new">g_relation_new</a>                  (<a href="glib-Basic-Types.html#gint">gint</a> fields);
void        <a href="glib-Relations-and-Tuples.html#g-relation-index">g_relation_index</a>                (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field,
                                             <a href="glib-Hash-Tables.html#GHashFunc">GHashFunc</a> hash_func,
                                             <a href="glib-Hash-Tables.html#GEqualFunc">GEqualFunc</a> key_equal_func);
void        <a href="glib-Relations-and-Tuples.html#g-relation-insert">g_relation_insert</a>               (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             ...);
<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Relations-and-Tuples.html#g-relation-exists">g_relation_exists</a>               (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             ...);
<a href="glib-Basic-Types.html#gint">gint</a>        <a href="glib-Relations-and-Tuples.html#g-relation-count">g_relation_count</a>                (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field);
<a href="glib-Relations-and-Tuples.html#GTuples">GTuples</a>*    <a href="glib-Relations-and-Tuples.html#g-relation-select">g_relation_select</a>               (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field);
<a href="glib-Basic-Types.html#gint">gint</a>        <a href="glib-Relations-and-Tuples.html#g-relation-delete">g_relation_delete</a>               (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field);
void        <a href="glib-Relations-and-Tuples.html#g-relation-destroy">g_relation_destroy</a>              (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation);

void        <a href="glib-Relations-and-Tuples.html#g-relation-print">g_relation_print</a>                (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation);

struct      <a href="glib-Relations-and-Tuples.html#GTuples">GTuples</a>;
void        <a href="glib-Relations-and-Tuples.html#g-tuples-destroy">g_tuples_destroy</a>                (<a href="glib-Relations-and-Tuples.html#GTuples">GTuples</a> *tuples);
<a href="glib-Basic-Types.html#gpointer">gpointer</a>    <a href="glib-Relations-and-Tuples.html#g-tuples-index">g_tuples_index</a>                  (<a href="glib-Relations-and-Tuples.html#GTuples">GTuples</a> *tuples,
                                             <a href="glib-Basic-Types.html#gint">gint</a> index_,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field);
</pre></div><div class="refsect1" lang="en"><a name="id3334100"></a><h2>Description</h2><p>
A <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> is a table of data which can be indexed on any number of fields,
rather like simple database tables. A <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> contains a number of
records, called tuples. Each record contains a number of fields.
Records are not ordered, so it is not possible to find the record at a
particular index.
</p><p>
Note that <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> tables are currently limited to 2 fields.
</p><p>
To create a GRelation, use <a href="glib-Relations-and-Tuples.html#g-relation-new"><tt class="function">g_relation_new()</tt></a>.
</p><p>
To specify which fields should be indexed, use <a href="glib-Relations-and-Tuples.html#g-relation-index"><tt class="function">g_relation_index()</tt></a>.
Note that this must be called before any tuples are added to the <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</p><p>
To add records to a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> use <a href="glib-Relations-and-Tuples.html#g-relation-insert"><tt class="function">g_relation_insert()</tt></a>.
</p><p>
To determine if a given record appears in a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>, use
<a href="glib-Relations-and-Tuples.html#g-relation-exists"><tt class="function">g_relation_exists()</tt></a>. Note that fields are compared directly, so pointers
must point to the exact same position (i.e. different copies of the same
string will not match.)
</p><p>
To count the number of records which have a particular value in a given
field, use <a href="glib-Relations-and-Tuples.html#g-relation-count"><tt class="function">g_relation_count()</tt></a>.
</p><p>
To get all the records which have a particular value in a given field,
use <a href="glib-Relations-and-Tuples.html#g-relation-select"><tt class="function">g_relation_select()</tt></a>. To access fields of the resulting records,
use <a href="glib-Relations-and-Tuples.html#g-tuples-index"><tt class="function">g_tuples_index()</tt></a>. To free the resulting records use <a href="glib-Relations-and-Tuples.html#g-tuples-destroy"><tt class="function">g_tuples_destroy()</tt></a>.
</p><p>
To delete all records which have a particular value in a given field,
use <a href="glib-Relations-and-Tuples.html#g-relation-delete"><tt class="function">g_relation_delete()</tt></a>.
</p><p>
To destroy the <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>, use <a href="glib-Relations-and-Tuples.html#g-relation-destroy"><tt class="function">g_relation_destroy()</tt></a>.
</p><p>
To help debug <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> objects, use <a href="glib-Relations-and-Tuples.html#g-relation-print"><tt class="function">g_relation_print()</tt></a>.
</p></div><div class="refsect1" lang="en"><a name="id3334339"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3334345"></a><h3><a name="GRelation"></a>struct GRelation</h3><a class="indexterm" name="id3334356"></a><pre class="programlisting">struct GRelation;</pre><p>
The <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> struct is an opaque data structure to represent a
<a href="glib-Relations-and-Tuples.html" title="Relations and Tuples">Relation</a>.
It should only be accessed via the following functions.
</p></div><hr><div class="refsect2" lang="en"><a name="id3334389"></a><h3><a name="g-relation-new"></a>g_relation_new ()</h3><a class="indexterm" name="id3334399"></a><pre class="programlisting"><a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a>*  g_relation_new                  (<a href="glib-Basic-Types.html#gint">gint</a> fields);</pre><p>
Creates a new <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> with the given number of fields.
Note that currently the number of fields must be 2.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>fields</tt></i> :</span></td><td>the number of fields.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>a new <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3334473"></a><h3><a name="g-relation-index"></a>g_relation_index ()</h3><a class="indexterm" name="id3334484"></a><pre class="programlisting">void        g_relation_index                (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field,
                                             <a href="glib-Hash-Tables.html#GHashFunc">GHashFunc</a> hash_func,
                                             <a href="glib-Hash-Tables.html#GEqualFunc">GEqualFunc</a> key_equal_func);</pre><p>
Creates an index on the given field.
Note that this must be called before any records are added to the <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>relation</tt></i> :</span></td><td>a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>field</tt></i> :</span></td><td>the field to index, counting from 0.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>hash_func</tt></i> :</span></td><td>a function to produce a hash value from the field data.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>key_equal_func</tt></i> :</span></td><td>a function to compare two values of the given field.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3334614"></a><h3><a name="g-relation-insert"></a>g_relation_insert ()</h3><a class="indexterm" name="id3334625"></a><pre class="programlisting">void        g_relation_insert               (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             ...);</pre><p>
Inserts a record into a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>relation</tt></i> :</span></td><td>a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>...</tt></i> :</span></td><td>the fields of the record to add. This must match the number of
fields in the <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3334710"></a><h3><a name="g-relation-exists"></a>g_relation_exists ()</h3><a class="indexterm" name="id3334722"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gboolean">gboolean</a>    g_relation_exists               (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             ...);</pre><p>
Returns <tt class="literal">TRUE</tt> if a record with the given values exists in a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
Note that the values are compared directly, so that, for example, two
copies of the same string will not match.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>relation</tt></i> :</span></td><td>a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>...</tt></i> :</span></td><td>the fields of the record to compare. The number must match the
number of fields in the <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td><tt class="literal">TRUE</tt> if a record matches.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3334830"></a><h3><a name="g-relation-count"></a>g_relation_count ()</h3><a class="indexterm" name="id3334841"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a>        g_relation_count                (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field);</pre><p>
Returns the number of tuples in a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> that have the given value
in the given field.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>relation</tt></i> :</span></td><td>a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>key</tt></i> :</span></td><td>the value to compare with.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>field</tt></i> :</span></td><td>the field of each record to match.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the number of matches.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3334958"></a><h3><a name="g-relation-select"></a>g_relation_select ()</h3><a class="indexterm" name="id3334970"></a><pre class="programlisting"><a href="glib-Relations-and-Tuples.html#GTuples">GTuples</a>*    g_relation_select               (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field);</pre><p>
Returns all of the tuples which have the given key in the given field.
Use <a href="glib-Relations-and-Tuples.html#g-tuples-index"><tt class="function">g_tuples_index()</tt></a> to access the returned records.
The returned records should be freed with <a href="glib-Relations-and-Tuples.html#g-tuples-destroy"><tt class="function">g_tuples_destroy()</tt></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>relation</tt></i> :</span></td><td>a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>key</tt></i> :</span></td><td>the value to compare with.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>field</tt></i> :</span></td><td>the field of each record to match.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the records (tuples) that matched.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3335101"></a><h3><a name="g-relation-delete"></a>g_relation_delete ()</h3><a class="indexterm" name="id3335112"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a>        g_relation_delete               (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation,
                                             <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> key,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field);</pre><p>
Deletes any records from a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> that have the given key value in
the given field.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>relation</tt></i> :</span></td><td>a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>key</tt></i> :</span></td><td>the value to compare with.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>field</tt></i> :</span></td><td>the field of each record to match.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the number of records deleted.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3335228"></a><h3><a name="g-relation-destroy"></a>g_relation_destroy ()</h3><a class="indexterm" name="id3335239"></a><pre class="programlisting">void        g_relation_destroy              (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation);</pre><p>
Destroys the <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>, freeing all memory allocated.
However, it does not free memory allocated for the
tuple data, so you should free that first if appropriate.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>relation</tt></i> :</span></td><td>a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3335304"></a><h3><a name="g-relation-print"></a>g_relation_print ()</h3><a class="indexterm" name="id3335315"></a><pre class="programlisting">void        g_relation_print                (<a href="glib-Relations-and-Tuples.html#GRelation">GRelation</a> *relation);</pre><p>
Outputs information about all records in a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>, as well as the indexes.
It is for debugging.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>relation</tt></i> :</span></td><td>a <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3335378"></a><h3><a name="GTuples"></a>struct GTuples</h3><a class="indexterm" name="id3335389"></a><pre class="programlisting">struct GTuples {

  guint len;
};
</pre><p>
The <a href="glib-Relations-and-Tuples.html#GTuples"><span class="type">GTuples</span></a> struct is used to return records (or tuples) from the
<a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a> by <a href="glib-Relations-and-Tuples.html#g-relation-select"><tt class="function">g_relation_select()</tt></a>.
It only contains one public member - the number of records that matched.
To access the matched records, you must use <a href="glib-Relations-and-Tuples.html#g-tuples-index"><tt class="function">g_tuples_index()</tt></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><a href="glib-Basic-Types.html#guint">guint</a> <i class="structfield"><tt>len</tt></i></span></td><td>the number of records that matched.

</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3335468"></a><h3><a name="g-tuples-destroy"></a>g_tuples_destroy ()</h3><a class="indexterm" name="id3335478"></a><pre class="programlisting">void        g_tuples_destroy                (<a href="glib-Relations-and-Tuples.html#GTuples">GTuples</a> *tuples);</pre><p>
Frees the records which were returned by <a href="glib-Relations-and-Tuples.html#g-relation-select"><tt class="function">g_relation_select()</tt></a>.
This should always be called after <a href="glib-Relations-and-Tuples.html#g-relation-select"><tt class="function">g_relation_select()</tt></a> when you are
finished with the records.
The records are not removed from the <a href="glib-Relations-and-Tuples.html#GRelation"><span class="type">GRelation</span></a>.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>tuples</tt></i> :</span></td><td>the tuple data to free.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3335556"></a><h3><a name="g-tuples-index"></a>g_tuples_index ()</h3><a class="indexterm" name="id3335567"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a>    g_tuples_index                  (<a href="glib-Relations-and-Tuples.html#GTuples">GTuples</a> *tuples,
                                             <a href="glib-Basic-Types.html#gint">gint</a> index_,
                                             <a href="glib-Basic-Types.html#gint">gint</a> field);</pre><p>
Gets a field from the records returned by <a href="glib-Relations-and-Tuples.html#g-relation-select"><tt class="function">g_relation_select()</tt></a>.
It returns the given field of the record at the given index.
The returned value should not be changed.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>tuples</tt></i> :</span></td><td>the tuple data, returned by <a href="glib-Relations-and-Tuples.html#g-relation-select"><tt class="function">g_relation_select()</tt></a>.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>index_</tt></i> :</span></td><td>the index of the record.
</td></tr><tr><td><span class="term"><i class="parameter"><tt>field</tt></i> :</span></td><td>the field to return.
</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td>the field of the record.


</td></tr></tbody></table></div></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-Datasets.html"><b>&lt;&lt; Datasets</b></a></td><td align="right"><a accesskey="n" href="glib-Caches.html"><b>Caches &gt;&gt;</b></a></td></tr></table></body></html>