~ubuntu-branches/ubuntu/vivid/glib2.0/vivid-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GLib Reference Manual: Quarks</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.78.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="prev" href="glib-N-ary-Trees.html" title="N-ary Trees">
<link rel="next" href="glib-Keyed-Data-Lists.html" title="Keyed Data Lists">
<meta name="generator" content="GTK-Doc V1.21 (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" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
                  <a href="#glib-Quarks.description" class="shortcut">Description</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="glib-data-types.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="glib-N-ary-Trees.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="glib-Keyed-Data-Lists.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="glib-Quarks"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Quarks.top_of_page"></a>Quarks</span></h2>
<p>Quarks — a 2-way association between a string and a
    unique integer identifier</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="glib-Quarks.functions"></a><h2>Functions</h2>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="define_keyword">#define</td>
<td class="function_name">
<a class="link" href="glib-Quarks.html#G-DEFINE-QUARK:CAPS" title="G_DEFINE_QUARK()">G_DEFINE_QUARK</a><span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="returnvalue">GQuark</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Quarks.html#g-quark-from-string" title="g_quark_from_string ()">g_quark_from_string</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="returnvalue">GQuark</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Quarks.html#g-quark-from-static-string" title="g_quark_from_static_string ()">g_quark_from_static_string</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Quarks.html#g-quark-to-string" title="g_quark_to_string ()">g_quark_to_string</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="returnvalue">GQuark</span></a>
</td>
<td class="function_name">
<a class="link" href="glib-Quarks.html#g-quark-try-string" title="g_quark_try_string ()">g_quark_try_string</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Quarks.html#g-intern-string" title="g_intern_string ()">g_intern_string</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
</td>
<td class="function_name">
<a class="link" href="glib-Quarks.html#g-intern-static-string" title="g_intern_static_string ()">g_intern_static_string</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Quarks.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody><tr>
<td class="typedef_keyword">typedef</td>
<td class="function_name"><a class="link" href="glib-Quarks.html#GQuark" title="GQuark">GQuark</a></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect1">
<a name="glib-Quarks.includes"></a><h2>Includes</h2>
<pre class="synopsis">#include &lt;glib.h&gt;
</pre>
</div>
<div class="refsect1">
<a name="glib-Quarks.description"></a><h2>Description</h2>
<p>Quarks are associations between strings and integer identifiers.
Given either the string or the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> identifier it is possible to
retrieve the other.</p>
<p>Quarks are used for both <a class="link" href="glib-Datasets.html" title="Datasets">datasets</a> and
<a class="link" href="glib-Keyed-Data-Lists.html" title="Keyed Data Lists">keyed data lists</a>.</p>
<p>To create a new quark from a string, use <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>.</p>
<p>To find the string corresponding to a given <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>, use
<a class="link" href="glib-Quarks.html#g-quark-to-string" title="g_quark_to_string ()"><code class="function">g_quark_to_string()</code></a>.</p>
<p>To find the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> corresponding to a given string, use
<a class="link" href="glib-Quarks.html#g-quark-try-string" title="g_quark_try_string ()"><code class="function">g_quark_try_string()</code></a>.</p>
<p>Another use for the string pool maintained for the quark functions
is string interning, using <a class="link" href="glib-Quarks.html#g-intern-string" title="g_intern_string ()"><code class="function">g_intern_string()</code></a> or
<a class="link" href="glib-Quarks.html#g-intern-static-string" title="g_intern_static_string ()"><code class="function">g_intern_static_string()</code></a>. An interned string is a canonical
representation for a string. One important advantage of interned
strings is that they can be compared for equality by a simple
pointer comparison, rather than using <code class="function">strcmp()</code>.</p>
</div>
<div class="refsect1">
<a name="glib-Quarks.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="G-DEFINE-QUARK:CAPS"></a><h3>G_DEFINE_QUARK()</h3>
<pre class="programlisting">#define             G_DEFINE_QUARK(QN, q_n)</pre>
<p>A convenience macro which defines a function returning the
<a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> for the name <em class="parameter"><code>QN</code></em>
. The function will be named
<em class="parameter"><code><code class="function">q_n_quark()</code></code></em>
.</p>
<p>Note that the quark name will be stringified automatically
in the macro, so you shouldn't use double quotes.</p>
<div class="refsect3">
<a name="id-1.6.15.7.2.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>QN</p></td>
<td class="parameter_description"><p>the name to return a <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> for</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>q_n</p></td>
<td class="parameter_description"><p>prefix for the function name</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since 2.34</p>
</div>
<hr>
<div class="refsect2">
<a name="g-quark-from-string"></a><h3>g_quark_from_string ()</h3>
<pre class="programlisting"><a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="returnvalue">GQuark</span></a>
g_quark_from_string (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *string</code></em>);</pre>
<p>Gets the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> identifying the given string. If the string does
not currently have an associated <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>, a new <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> is created,
using a copy of the string.</p>
<div class="refsect3">
<a name="id-1.6.15.7.3.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>string</p></td>
<td class="parameter_description"><p> a string. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.6.15.7.3.6"></a><h4>Returns</h4>
<p> the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> identifying the string, or 0 if <em class="parameter"><code>string</code></em>
is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a></p>
<p></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-quark-from-static-string"></a><h3>g_quark_from_static_string ()</h3>
<pre class="programlisting"><a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="returnvalue">GQuark</span></a>
g_quark_from_static_string (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *string</code></em>);</pre>
<p>Gets the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> identifying the given (static) string. If the
string does not currently have an associated <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>, a new <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>
is created, linked to the given string.</p>
<p>Note that this function is identical 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> except
that if a new <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> is created the string itself is used rather
than a copy. This saves memory, but can only be used if the string
will continue to exist until the program terminates. It can be used
with statically allocated strings in the main program, but not with
statically allocated memory in dynamically loaded modules, if you
expect to ever unload the module again (e.g. do not use this
function in GTK+ theme engines).</p>
<div class="refsect3">
<a name="id-1.6.15.7.4.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>string</p></td>
<td class="parameter_description"><p> a string. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.6.15.7.4.7"></a><h4>Returns</h4>
<p> the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> identifying the string, or 0 if <em class="parameter"><code>string</code></em>
is <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a></p>
<p></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-quark-to-string"></a><h3>g_quark_to_string ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_quark_to_string (<em class="parameter"><code><a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> quark</code></em>);</pre>
<p>Gets the string associated with the given <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>.</p>
<div class="refsect3">
<a name="id-1.6.15.7.5.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>quark</p></td>
<td class="parameter_description"><p>a <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>.</p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.6.15.7.5.6"></a><h4>Returns</h4>
<p> the string associated with the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a></p>
<p></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-quark-try-string"></a><h3>g_quark_try_string ()</h3>
<pre class="programlisting"><a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="returnvalue">GQuark</span></a>
g_quark_try_string (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *string</code></em>);</pre>
<p>Gets the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> associated with the given string, or 0 if string is
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> or it has no associated <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a>.</p>
<p>If you want the GQuark to be created if it doesn't already exist,
use <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>.</p>
<div class="refsect3">
<a name="id-1.6.15.7.6.6"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>string</p></td>
<td class="parameter_description"><p> a string. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.6.15.7.6.7"></a><h4>Returns</h4>
<p> the <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> associated with the string, or 0 if <em class="parameter"><code>string</code></em>
is
<a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> or there is no <a class="link" href="glib-Quarks.html#GQuark" title="GQuark"><span class="type">GQuark</span></a> associated with it</p>
<p></p>
</div>
</div>
<hr>
<div class="refsect2">
<a name="g-intern-string"></a><h3>g_intern_string ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_intern_string (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *string</code></em>);</pre>
<p>Returns a canonical representation for <em class="parameter"><code>string</code></em>
. Interned strings
can be compared for equality by comparing the pointers, instead of
using <code class="function">strcmp()</code>.</p>
<div class="refsect3">
<a name="id-1.6.15.7.7.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>string</p></td>
<td class="parameter_description"><p> a string. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.6.15.7.7.6"></a><h4>Returns</h4>
<p> a canonical representation for the string</p>
<p></p>
</div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-intern-static-string"></a><h3>g_intern_static_string ()</h3>
<pre class="programlisting">const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="returnvalue">gchar</span></a> *
g_intern_static_string (<em class="parameter"><code>const <a class="link" href="glib-Basic-Types.html#gchar" title="gchar"><span class="type">gchar</span></a> *string</code></em>);</pre>
<p>Returns a canonical representation for <em class="parameter"><code>string</code></em>
. Interned strings
can be compared for equality by comparing the pointers, instead of
using <code class="function">strcmp()</code>. <a class="link" href="glib-Quarks.html#g-intern-static-string" title="g_intern_static_string ()"><code class="function">g_intern_static_string()</code></a> does not copy the string,
therefore <em class="parameter"><code>string</code></em>
 must not be freed or modified.</p>
<div class="refsect3">
<a name="id-1.6.15.7.8.5"></a><h4>Parameters</h4>
<div class="informaltable"><table width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>string</p></td>
<td class="parameter_description"><p> a static string. </p></td>
<td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="id-1.6.15.7.8.6"></a><h4>Returns</h4>
<p> a canonical representation for the string</p>
<p></p>
</div>
<p class="since">Since 2.10</p>
</div>
</div>
<div class="refsect1">
<a name="glib-Quarks.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="GQuark"></a><h3>GQuark</h3>
<pre class="programlisting">typedef guint32 GQuark;
</pre>
<p>A GQuark is a non-zero integer which uniquely identifies a
particular string. A GQuark value of zero is associated to <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.21</div>
</body>
</html>