36
37
<th width="100%" align="center">GLib Reference Manual</th>
37
38
<td><a accesskey="n" href="glib-Relations-and-Tuples.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
39
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3414777" class="shortcut">Top</a>
41
<a href="#id3415088" class="shortcut">Description</a></nobr></td></tr>
40
<tr><td colspan="5" class="shortcuts">
41
<a href="#glib-Datasets.synopsis" class="shortcut">Top</a>
43
<a href="#glib-Datasets.description" class="shortcut">Description</a>
43
46
<div class="refentry" lang="en">
44
47
<a name="glib-Datasets"></a><div class="titlepage"></div>
45
48
<div class="refnamediv"><table width="100%"><tr>
48
<a name="id3414777"></a><span class="refentrytitle">Datasets</span>
50
<p>Datasets — associate groups of data elements with particular memory locations</p>
50
<h2><span class="refentrytitle"><a name="glib-Datasets.top_of_page"></a>Datasets</span></h2>
51
<p>Datasets — associate groups of data elements with particular memory locations</p>
52
53
<td valign="top" align="right"></td>
53
54
</tr></table></div>
54
55
<div class="refsynopsisdiv">
56
<a name="glib-Datasets.synopsis"></a><h2>Synopsis</h2>
56
57
<pre class="synopsis">
58
59
#include <glib.h>
61
#define <a class="link" href="glib-Datasets.html#g-dataset-id-set-data">g_dataset_id_set_data</a> (l, k, d)
62
void <a class="link" href="glib-Datasets.html#g-dataset-id-set-data-full">g_dataset_id_set_data_full</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> dataset_location,
63
<a class="link" href="glib-Quarks.html#GQuark">GQuark</a> key_id,
64
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
65
<a class="link" href="glib-Datasets.html#GDestroyNotify">GDestroyNotify</a> destroy_func);
66
void (<a class="link" href="glib-Datasets.html#GDestroyNotify">*GDestroyNotify</a>) (<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);
67
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> <a class="link" href="glib-Datasets.html#g-dataset-id-get-data">g_dataset_id_get_data</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> dataset_location,
68
<a class="link" href="glib-Quarks.html#GQuark">GQuark</a> key_id);
69
#define <a class="link" href="glib-Datasets.html#g-dataset-id-remove-data">g_dataset_id_remove_data</a> (l, k)
70
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> <a class="link" href="glib-Datasets.html#g-dataset-id-remove-no-notify">g_dataset_id_remove_no_notify</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> dataset_location,
71
<a class="link" href="glib-Quarks.html#GQuark">GQuark</a> key_id);
73
#define <a class="link" href="glib-Datasets.html#g-dataset-set-data">g_dataset_set_data</a> (l, k, d)
74
#define <a class="link" href="glib-Datasets.html#g-dataset-set-data-full">g_dataset_set_data_full</a> (l, k, d, f)
75
#define <a class="link" href="glib-Datasets.html#g-dataset-get-data">g_dataset_get_data</a> (l, k)
76
#define <a class="link" href="glib-Datasets.html#g-dataset-remove-data">g_dataset_remove_data</a> (l, k)
77
#define <a class="link" href="glib-Datasets.html#g-dataset-remove-no-notify">g_dataset_remove_no_notify</a> (l, k)
79
void <a class="link" href="glib-Datasets.html#g-dataset-foreach">g_dataset_foreach</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> dataset_location,
80
<a class="link" href="glib-Datasets.html#GDataForeachFunc">GDataForeachFunc</a> func,
81
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
82
void (<a class="link" href="glib-Datasets.html#GDataForeachFunc">*GDataForeachFunc</a>) (<a class="link" href="glib-Quarks.html#GQuark">GQuark</a> key_id,
83
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
84
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);
85
void <a class="link" href="glib-Datasets.html#g-dataset-destroy">g_dataset_destroy</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> dataset_location);
61
#define <a class="link" href="glib-Datasets.html#g-dataset-id-set-data" title="g_dataset_id_set_data()">g_dataset_id_set_data</a> (l, k, d)
62
void <a class="link" href="glib-Datasets.html#g-dataset-id-set-data-full" title="g_dataset_id_set_data_full ()">g_dataset_id_set_data_full</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer">gconstpointer</a> dataset_location,
63
<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> key_id,
64
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> data,
65
<a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()">GDestroyNotify</a> destroy_func);
66
void (<a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()">*GDestroyNotify</a>) (<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> data);
67
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> <a class="link" href="glib-Datasets.html#g-dataset-id-get-data" title="g_dataset_id_get_data ()">g_dataset_id_get_data</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer">gconstpointer</a> dataset_location,
68
<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> key_id);
69
#define <a class="link" href="glib-Datasets.html#g-dataset-id-remove-data" title="g_dataset_id_remove_data()">g_dataset_id_remove_data</a> (l, k)
70
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> <a class="link" href="glib-Datasets.html#g-dataset-id-remove-no-notify" title="g_dataset_id_remove_no_notify ()">g_dataset_id_remove_no_notify</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer">gconstpointer</a> dataset_location,
71
<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> key_id);
73
#define <a class="link" href="glib-Datasets.html#g-dataset-set-data" title="g_dataset_set_data()">g_dataset_set_data</a> (l, k, d)
74
#define <a class="link" href="glib-Datasets.html#g-dataset-set-data-full" title="g_dataset_set_data_full()">g_dataset_set_data_full</a> (l, k, d, f)
75
#define <a class="link" href="glib-Datasets.html#g-dataset-get-data" title="g_dataset_get_data()">g_dataset_get_data</a> (l, k)
76
#define <a class="link" href="glib-Datasets.html#g-dataset-remove-data" title="g_dataset_remove_data()">g_dataset_remove_data</a> (l, k)
77
#define <a class="link" href="glib-Datasets.html#g-dataset-remove-no-notify" title="g_dataset_remove_no_notify()">g_dataset_remove_no_notify</a> (l, k)
79
void <a class="link" href="glib-Datasets.html#g-dataset-foreach" title="g_dataset_foreach ()">g_dataset_foreach</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer">gconstpointer</a> dataset_location,
80
<a class="link" href="glib-Datasets.html#GDataForeachFunc" title="GDataForeachFunc ()">GDataForeachFunc</a> func,
81
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data);
82
void (<a class="link" href="glib-Datasets.html#GDataForeachFunc" title="GDataForeachFunc ()">*GDataForeachFunc</a>) (<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> key_id,
83
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> data,
84
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data);
85
void <a class="link" href="glib-Datasets.html#g-dataset-destroy" title="g_dataset_destroy ()">g_dataset_destroy</a> (<a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer">gconstpointer</a> dataset_location);
88
88
<div class="refsect1" lang="en">
89
<a name="id3415088"></a><h2>Description</h2>
89
<a name="glib-Datasets.description"></a><h2>Description</h2>
91
91
Datasets associate groups of data elements with particular memory locations.
92
92
These are useful if you need to associate data with a structure returned
98
98
There are two forms of most of the dataset functions.
99
99
The first form uses strings to identify the data elements associated with
100
a location. The second form uses <a class="link" href="glib-Quarks.html#GQuark"><span class="type">GQuark</span></a> identifiers, which are created
101
with a call to <a class="link" href="glib-Quarks.html#g-quark-from-string"><code class="function">g_quark_from_string()</code></a> or <a class="link" href="glib-Quarks.html#g-quark-from-static-string"><code class="function">g_quark_from_static_string()</code></a>.
100
a location. The second form uses <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> identifiers, which are created
101
with a call to <a class="link" href="glib-Quarks.html#g-quark-from-string" title="g_quark_from_string ()"><code class="function">g_quark_from_string()</code></a> or <a class="link" href="glib-Quarks.html#g-quark-from-static-string" title="g_quark_from_static_string ()"><code class="function">g_quark_from_static_string()</code></a>.
102
102
The second form is quicker, since it does not require looking up the string
103
in the hash table of <a class="link" href="glib-Quarks.html#GQuark"><span class="type">GQuark</span></a> identifiers.
103
in the hash table of <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> identifiers.
106
106
There is no function to create a dataset. It is automatically created as
107
107
soon as you add elements to it.
110
To add data elements to a dataset use <a class="link" href="glib-Datasets.html#g-dataset-id-set-data"><code class="function">g_dataset_id_set_data()</code></a>,
111
<a class="link" href="glib-Datasets.html#g-dataset-id-set-data-full"><code class="function">g_dataset_id_set_data_full()</code></a>, <a class="link" href="glib-Datasets.html#g-dataset-set-data"><code class="function">g_dataset_set_data()</code></a>
112
and <a class="link" href="glib-Datasets.html#g-dataset-set-data-full"><code class="function">g_dataset_set_data_full()</code></a>.
115
To get data elements from a dataset use <a class="link" href="glib-Datasets.html#g-dataset-id-get-data"><code class="function">g_dataset_id_get_data()</code></a> and
116
<a class="link" href="glib-Datasets.html#g-dataset-get-data"><code class="function">g_dataset_get_data()</code></a>.
119
To iterate over all data elements in a dataset use <a class="link" href="glib-Datasets.html#g-dataset-foreach"><code class="function">g_dataset_foreach()</code></a> (not thread-safe).
122
To remove data elements from a dataset use <a class="link" href="glib-Datasets.html#g-dataset-id-remove-data"><code class="function">g_dataset_id_remove_data()</code></a> and
123
<a class="link" href="glib-Datasets.html#g-dataset-remove-data"><code class="function">g_dataset_remove_data()</code></a>.
126
To destroy a dataset, use <a class="link" href="glib-Datasets.html#g-dataset-destroy"><code class="function">g_dataset_destroy()</code></a>.
110
To add data elements to a dataset use <a class="link" href="glib-Datasets.html#g-dataset-id-set-data" title="g_dataset_id_set_data()"><code class="function">g_dataset_id_set_data()</code></a>,
111
<a class="link" href="glib-Datasets.html#g-dataset-id-set-data-full" title="g_dataset_id_set_data_full ()"><code class="function">g_dataset_id_set_data_full()</code></a>, <a class="link" href="glib-Datasets.html#g-dataset-set-data" title="g_dataset_set_data()"><code class="function">g_dataset_set_data()</code></a>
112
and <a class="link" href="glib-Datasets.html#g-dataset-set-data-full" title="g_dataset_set_data_full()"><code class="function">g_dataset_set_data_full()</code></a>.
115
To get data elements from a dataset use <a class="link" href="glib-Datasets.html#g-dataset-id-get-data" title="g_dataset_id_get_data ()"><code class="function">g_dataset_id_get_data()</code></a> and
116
<a class="link" href="glib-Datasets.html#g-dataset-get-data" title="g_dataset_get_data()"><code class="function">g_dataset_get_data()</code></a>.
119
To iterate over all data elements in a dataset use <a class="link" href="glib-Datasets.html#g-dataset-foreach" title="g_dataset_foreach ()"><code class="function">g_dataset_foreach()</code></a> (not thread-safe).
122
To remove data elements from a dataset use <a class="link" href="glib-Datasets.html#g-dataset-id-remove-data" title="g_dataset_id_remove_data()"><code class="function">g_dataset_id_remove_data()</code></a> and
123
<a class="link" href="glib-Datasets.html#g-dataset-remove-data" title="g_dataset_remove_data()"><code class="function">g_dataset_remove_data()</code></a>.
126
To destroy a dataset, use <a class="link" href="glib-Datasets.html#g-dataset-destroy" title="g_dataset_destroy ()"><code class="function">g_dataset_destroy()</code></a>.
129
129
<div class="refsect1" lang="en">
130
<a name="id3415293"></a><h2>Details</h2>
130
<a name="glib-Datasets.details"></a><h2>Details</h2>
131
131
<div class="refsect2" lang="en">
132
<a name="id3415303"></a><h3>
133
<a name="g-dataset-id-set-data"></a>g_dataset_id_set_data()</h3>
134
<a class="indexterm" name="id3415316"></a><pre class="programlisting">#define g_dataset_id_set_data(l, k, d)</pre>
132
<a name="g-dataset-id-set-data"></a><h3>g_dataset_id_set_data()</h3>
133
<pre class="programlisting">#define g_dataset_id_set_data(l, k, d)</pre>
136
Sets the data element associated with the given <a class="link" href="glib-Quarks.html#GQuark"><span class="type">GQuark</span></a> id.
135
Sets the data element associated with the given <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> id.
137
136
Any previous data with the same key is removed, and its destroy function
164
161
<div class="refsect2" lang="en">
165
<a name="id3415396"></a><h3>
166
<a name="g-dataset-id-set-data-full"></a>g_dataset_id_set_data_full ()</h3>
167
<a class="indexterm" name="id3415410"></a><pre class="programlisting">void g_dataset_id_set_data_full (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> dataset_location,
168
<a class="link" href="glib-Quarks.html#GQuark">GQuark</a> key_id,
169
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
170
<a class="link" href="glib-Datasets.html#GDestroyNotify">GDestroyNotify</a> destroy_func);</pre>
162
<a name="g-dataset-id-set-data-full"></a><h3>g_dataset_id_set_data_full ()</h3>
163
<pre class="programlisting">void g_dataset_id_set_data_full (<a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer">gconstpointer</a> dataset_location,
164
<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> key_id,
165
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> data,
166
<a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()">GDestroyNotify</a> destroy_func);</pre>
172
Sets the data element associated with the given <a class="link" href="glib-Quarks.html#GQuark"><span class="type">GQuark</span></a> id, and also the
168
Sets the data element associated with the given <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> id, and also the
173
169
function to call when the data element is destroyed.
174
170
Any previous data with the same key is removed, and its
175
171
destroy function is called.
217
210
<div class="variablelist"><table border="0">
218
211
<col align="left" valign="top">
220
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
213
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
221
214
<td>the data element.
229
220
<div class="refsect2" lang="en">
230
<a name="id3415608"></a><h3>
231
<a name="g-dataset-id-get-data"></a>g_dataset_id_get_data ()</h3>
232
<a class="indexterm" name="id3415621"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_dataset_id_get_data (<a class="link" href="glib-Basic-Types.html#gconstpointer">gconstpointer</a> dataset_location,
233
<a class="link" href="glib-Quarks.html#GQuark">GQuark</a> key_id);</pre>
221
<a name="g-dataset-id-get-data"></a><h3>g_dataset_id_get_data ()</h3>
222
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> g_dataset_id_get_data (<a class="link" href="glib-Basic-Types.html#gconstpointer" title="gconstpointer">gconstpointer</a> dataset_location,
223
<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> key_id);</pre>
235
Gets the data element corresponding to a <a class="link" href="glib-Quarks.html#GQuark"><span class="type">GQuark</span></a>.
225
Gets the data element corresponding to a <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>.
237
227
<div class="variablelist"><table border="0">
238
228
<col align="left" valign="top">
241
<td><p><span class="term"><em class="parameter"><code>dataset_location</code></em> :</span></p></td>
231
<td><p><span class="term"><em class="parameter"><code>dataset_location</code></em> :</span></p></td>
242
232
<td>the location identifying the dataset.
246
<td><p><span class="term"><em class="parameter"><code>key_id</code></em> :</span></p></td>
247
<td>the <a class="link" href="glib-Quarks.html#GQuark"><span class="type">GQuark</span></a> id to identify the data element.
236
<td><p><span class="term"><em class="parameter"><code>key_id</code></em> :</span></p></td>
237
<td>the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> id to identify the data element.
251
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
252
<td>the data element corresponding to the <a class="link" href="glib-Quarks.html#GQuark"><span class="type">GQuark</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if it is
241
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
242
<td>the data element corresponding to the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>, or <a class="link" href="glib-Standard-Macros.html#NULL--CAPS" title="NULL"><code class="literal">NULL</code></a> if it is
513
477
<div class="refsect2" lang="en">
514
<a name="id3416422"></a><h3>
515
<a name="GDataForeachFunc"></a>GDataForeachFunc ()</h3>
516
<a class="indexterm" name="id3416434"></a><pre class="programlisting">void (*GDataForeachFunc) (<a class="link" href="glib-Quarks.html#GQuark">GQuark</a> key_id,
517
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,
518
<a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre>
478
<a name="GDataForeachFunc"></a><h3>GDataForeachFunc ()</h3>
479
<pre class="programlisting">void (*GDataForeachFunc) (<a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a> key_id,
480
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> data,
481
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer">gpointer</a> user_data);</pre>
520
Specifies the type of function passed to <a class="link" href="glib-Datasets.html#g-dataset-foreach"><code class="function">g_dataset_foreach()</code></a>.
521
It is called with each <a class="link" href="glib-Quarks.html#GQuark"><span class="type">GQuark</span></a> id and associated data element,
522
together with the <em class="parameter"><code>user_data</code></em> parameter supplied to <a class="link" href="glib-Datasets.html#g-dataset-foreach"><code class="function">g_dataset_foreach()</code></a>.
483
Specifies the type of function passed to <a class="link" href="glib-Datasets.html#g-dataset-foreach" title="g_dataset_foreach ()"><code class="function">g_dataset_foreach()</code></a>.
484
It is called with each <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> id and associated data element,
485
together with the <em class="parameter"><code>user_data</code></em> parameter supplied to <a class="link" href="glib-Datasets.html#g-dataset-foreach" title="g_dataset_foreach ()"><code class="function">g_dataset_foreach()</code></a>.
524
487
<div class="variablelist"><table border="0">
525
488
<col align="left" valign="top">
528
<td><p><span class="term"><em class="parameter"><code>key_id</code></em> :</span></p></td>
529
<td>the <a class="link" href="glib-Quarks.html#GQuark"><span class="type">GQuark</span></a> id to identifying the data element.
491
<td><p><span class="term"><em class="parameter"><code>key_id</code></em> :</span></p></td>
492
<td>the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> id to identifying the data element.
533
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
496
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
534
497
<td>the data element.
538
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
539
<td>user data passed to <a class="link" href="glib-Datasets.html#g-dataset-foreach"><code class="function">g_dataset_foreach()</code></a>.
501
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
502
<td>user data passed to <a class="link" href="glib-Datasets.html#g-dataset-foreach" title="g_dataset_foreach ()"><code class="function">g_dataset_foreach()</code></a>.