~ubuntu-branches/ubuntu/utopic/glib2.0/utopic

« back to all changes in this revision

Viewing changes to docs/reference/gobject/html/gobject-Boxed-Types.html

Tags: upstream-2.12.12
ImportĀ upstreamĀ versionĀ 2.12.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
2
<html>
 
3
<head>
 
4
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
 
5
<title>GBoxed</title>
 
6
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
 
7
<link rel="start" href="index.html" title="GObject Reference Manual">
 
8
<link rel="up" href="rn01.html" title="API Reference">
 
9
<link rel="prev" href="gobject-Enumeration-and-Flag-Types.html" title="Enums and Flags">
 
10
<link rel="next" href="gobject-Generic-values.html" title="Generic Values">
 
11
<meta name="generator" content="GTK-Doc V1.7 (XML mode)">
 
12
<link rel="stylesheet" href="style.css" type="text/css">
 
13
<link rel="preface" href="pr01.html" title="Introduction">
 
14
<link rel="part" href="pt01.html" title="Part&#160;I.&#160;Concepts">
 
15
<link rel="chapter" href="ch01.html" title="Background">
 
16
<link rel="chapter" href="ch02.html" title="The Glib Dynamic Type System">
 
17
<link rel="chapter" href="chapter-gobject.html" title="The GObject base class">
 
18
<link rel="chapter" href="chapter-signal.html" title="The GObject messaging system">
 
19
<link rel="reference" href="rn01.html" title="API Reference">
 
20
<link rel="reference" href="rn02.html" title="Tools Reference">
 
21
<link rel="part" href="pt02.html" title="Part&#160;IV.&#160;Tutorial">
 
22
<link rel="chapter" href="howto-gobject.html" title="How To define and implement a new GObject?">
 
23
<link rel="chapter" href="howto-interface.html" title="How To define and implement Interfaces?">
 
24
<link rel="chapter" href="howto-signals.html" title="Howto create and use signals">
 
25
<link rel="part" href="pt03.html" title="Part&#160;V.&#160;Related Tools">
 
26
<link rel="chapter" href="tools-gob.html" title="GObject builder">
 
27
<link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of Gobjects">
 
28
<link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems">
 
29
<link rel="chapter" href="tools-gtkdoc.html" title="Writing API docs">
 
30
<link rel="index" href="ix01.html" title="Index">
 
31
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
 
32
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
 
33
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
 
34
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
 
35
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
 
36
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
 
37
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
 
38
</head>
 
39
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
 
40
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
 
41
<tr valign="middle">
 
42
<td><a accesskey="p" href="gobject-Enumeration-and-Flag-Types.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
 
43
<td><a accesskey="u" href="rn01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
 
44
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
 
45
<th width="100%" align="center">GObject Reference Manual</th>
 
46
<td><a accesskey="n" href="gobject-Generic-values.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
 
47
</tr>
 
48
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3086271" class="shortcut">Top</a>
 
49
                  &#160;|&#160;
 
50
                  <a href="#id3086499" class="shortcut">Description</a></nobr></td></tr>
 
51
</table>
 
52
<div class="refentry" lang="en">
 
53
<a name="gobject-Boxed-Types"></a><div class="titlepage"></div>
 
54
<div class="refnamediv"><table width="100%"><tr>
 
55
<td valign="top">
 
56
<h2>
 
57
<a name="id3086271"></a><span class="refentrytitle">GBoxed</span>
 
58
</h2>
 
59
<p>GBoxed &#8212; A mechanism to wrap opaque C structures registered by the type system</p>
 
60
</td>
 
61
<td valign="top" align="right"></td>
 
62
</tr></table></div>
 
63
<div class="refsynopsisdiv">
 
64
<h2>Synopsis</h2>
 
65
<pre class="synopsis">
 
66
 
 
67
#include &lt;glib-object.h&gt;
 
68
 
 
69
 
 
70
<a
 
71
href="../glib/glib-Basic-Types.html#gpointer"
 
72
>gpointer</a>            (<a href="gobject-Boxed-Types.html#GBoxedCopyFunc">*GBoxedCopyFunc</a>)                   (<a
 
73
href="../glib/glib-Basic-Types.html#gpointer"
 
74
>gpointer</a> boxed);
 
75
void                (<a href="gobject-Boxed-Types.html#GBoxedFreeFunc">*GBoxedFreeFunc</a>)                   (<a
 
76
href="../glib/glib-Basic-Types.html#gpointer"
 
77
>gpointer</a> boxed);
 
78
<a
 
79
href="../glib/glib-Basic-Types.html#gpointer"
 
80
>gpointer</a>            <a href="gobject-Boxed-Types.html#g-boxed-copy">g_boxed_copy</a>                        (<a href="gobject-Type-Information.html#GType">GType</a> boxed_type,
 
81
                                                         <a
 
82
href="../glib/glib-Basic-Types.html#gconstpointer"
 
83
>gconstpointer</a> src_boxed);
 
84
void                <a href="gobject-Boxed-Types.html#g-boxed-free">g_boxed_free</a>                        (<a href="gobject-Type-Information.html#GType">GType</a> boxed_type,
 
85
                                                         <a
 
86
href="../glib/glib-Basic-Types.html#gpointer"
 
87
>gpointer</a> boxed);
 
88
<a href="gobject-Type-Information.html#GType">GType</a>               <a href="gobject-Boxed-Types.html#g-boxed-type-register-static">g_boxed_type_register_static</a>        (const <a
 
89
href="../glib/glib-Basic-Types.html#gchar"
 
90
>gchar</a> *name,
 
91
                                                         <a href="gobject-Boxed-Types.html#GBoxedCopyFunc">GBoxedCopyFunc</a> boxed_copy,
 
92
                                                         <a href="gobject-Boxed-Types.html#GBoxedFreeFunc">GBoxedFreeFunc</a> boxed_free);
 
93
<a href="gobject-Type-Information.html#GType">GType</a>               <a href="gobject-Boxed-Types.html#g-pointer-type-register-static">g_pointer_type_register_static</a>      (const <a
 
94
href="../glib/glib-Basic-Types.html#gchar"
 
95
>gchar</a> *name);
 
96
 
 
97
#define             <a href="gobject-Boxed-Types.html#G-TYPE-HASH-TABLE:CAPS">G_TYPE_HASH_TABLE</a>
 
98
#define             <a href="gobject-Boxed-Types.html#G-TYPE-DATE:CAPS">G_TYPE_DATE</a>
 
99
#define             <a href="gobject-Boxed-Types.html#G-TYPE-GSTRING:CAPS">G_TYPE_GSTRING</a>
 
100
#define             <a href="gobject-Boxed-Types.html#G-TYPE-STRV:CAPS">G_TYPE_STRV</a>
 
101
typedef             <a href="gobject-Boxed-Types.html#GStrv">GStrv</a>;
 
102
 
 
103
 
 
104
</pre>
 
105
</div>
 
106
<div class="refsect1" lang="en">
 
107
<a name="id3086499"></a><h2>Description</h2>
 
108
<p>
 
109
GBoxed is a generic wrapper mechanism for arbitrary C structures. The only
 
110
thing the type system needs to know about the structures is how to copy and
 
111
free them, beyond that they are treated as opaque chunks of memory.
 
112
</p>
 
113
<p>
 
114
Boxed types are useful for simple value-holder structures like rectangles or
 
115
points. They can also be used for wrapping structures defined in non-GObject
 
116
based libraries.
 
117
</p>
 
118
</div>
 
119
<div class="refsect1" lang="en">
 
120
<a name="id3086524"></a><h2>Details</h2>
 
121
<div class="refsect2" lang="en">
 
122
<a name="id3086534"></a><h3>
 
123
<a name="GBoxedCopyFunc"></a>GBoxedCopyFunc ()</h3>
 
124
<a class="indexterm" name="id3086547"></a><pre class="programlisting"><a
 
125
href="../glib/glib-Basic-Types.html#gpointer"
 
126
>gpointer</a>            (*GBoxedCopyFunc)                   (<a
 
127
href="../glib/glib-Basic-Types.html#gpointer"
 
128
>gpointer</a> boxed);</pre>
 
129
<p>
 
130
This function is provided by the user and should produce a copy of the passed
 
131
in boxed structure.
 
132
</p>
 
133
<div class="variablelist"><table border="0">
 
134
<col align="left" valign="top">
 
135
<tbody>
 
136
<tr>
 
137
<td><span class="term"><em class="parameter"><code>boxed</code></em>&#160;:</span></td>
 
138
<td>  The boxed structure to be copied.
 
139
</td>
 
140
</tr>
 
141
<tr>
 
142
<td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
 
143
<td>The newly created copy of the boxed structure.
 
144
 
 
145
 
 
146
</td>
 
147
</tr>
 
148
</tbody>
 
149
</table></div>
 
150
</div>
 
151
<hr>
 
152
<div class="refsect2" lang="en">
 
153
<a name="id3086606"></a><h3>
 
154
<a name="GBoxedFreeFunc"></a>GBoxedFreeFunc ()</h3>
 
155
<a class="indexterm" name="id3086619"></a><pre class="programlisting">void                (*GBoxedFreeFunc)                   (<a
 
156
href="../glib/glib-Basic-Types.html#gpointer"
 
157
>gpointer</a> boxed);</pre>
 
158
<p>
 
159
This function is provided by the user and should free the boxed
 
160
structure passed.
 
161
</p>
 
162
<div class="variablelist"><table border="0">
 
163
<col align="left" valign="top">
 
164
<tbody><tr>
 
165
<td><span class="term"><em class="parameter"><code>boxed</code></em>&#160;:</span></td>
 
166
<td>The boxed structure to be freed.
 
167
 
 
168
 
 
169
</td>
 
170
</tr></tbody>
 
171
</table></div>
 
172
</div>
 
173
<hr>
 
174
<div class="refsect2" lang="en">
 
175
<a name="id3086668"></a><h3>
 
176
<a name="g-boxed-copy"></a>g_boxed_copy ()</h3>
 
177
<a class="indexterm" name="id3086680"></a><pre class="programlisting"><a
 
178
href="../glib/glib-Basic-Types.html#gpointer"
 
179
>gpointer</a>            g_boxed_copy                        (<a href="gobject-Type-Information.html#GType">GType</a> boxed_type,
 
180
                                                         <a
 
181
href="../glib/glib-Basic-Types.html#gconstpointer"
 
182
>gconstpointer</a> src_boxed);</pre>
 
183
<p>
 
184
Provide a copy of a boxed structure <em class="parameter"><code>src_boxed</code></em> which is of type <em class="parameter"><code>boxed_type</code></em>.
 
185
</p>
 
186
<div class="variablelist"><table border="0">
 
187
<col align="left" valign="top">
 
188
<tbody>
 
189
<tr>
 
190
<td><span class="term"><em class="parameter"><code>boxed_type</code></em>&#160;:</span></td>
 
191
<td>The type of <em class="parameter"><code>src_boxed</code></em>.
 
192
</td>
 
193
</tr>
 
194
<tr>
 
195
<td><span class="term"><em class="parameter"><code>src_boxed</code></em>&#160;:</span></td>
 
196
<td> The boxed structure to be copied.
 
197
</td>
 
198
</tr>
 
199
<tr>
 
200
<td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
 
201
<td>   The newly created copy of the boxed structure.
 
202
 
 
203
 
 
204
</td>
 
205
</tr>
 
206
</tbody>
 
207
</table></div>
 
208
</div>
 
209
<hr>
 
210
<div class="refsect2" lang="en">
 
211
<a name="id3086779"></a><h3>
 
212
<a name="g-boxed-free"></a>g_boxed_free ()</h3>
 
213
<a class="indexterm" name="id3086792"></a><pre class="programlisting">void                g_boxed_free                        (<a href="gobject-Type-Information.html#GType">GType</a> boxed_type,
 
214
                                                         <a
 
215
href="../glib/glib-Basic-Types.html#gpointer"
 
216
>gpointer</a> boxed);</pre>
 
217
<p>
 
218
Free the boxed structure <em class="parameter"><code>boxed</code></em> which is of type <em class="parameter"><code>boxed_type</code></em>.
 
219
</p>
 
220
<div class="variablelist"><table border="0">
 
221
<col align="left" valign="top">
 
222
<tbody>
 
223
<tr>
 
224
<td><span class="term"><em class="parameter"><code>boxed_type</code></em>&#160;:</span></td>
 
225
<td>The type of <em class="parameter"><code>boxed</code></em>.
 
226
</td>
 
227
</tr>
 
228
<tr>
 
229
<td><span class="term"><em class="parameter"><code>boxed</code></em>&#160;:</span></td>
 
230
<td>     The boxed structure to be freed.
 
231
 
 
232
 
 
233
</td>
 
234
</tr>
 
235
</tbody>
 
236
</table></div>
 
237
</div>
 
238
<hr>
 
239
<div class="refsect2" lang="en">
 
240
<a name="id3086878"></a><h3>
 
241
<a name="g-boxed-type-register-static"></a>g_boxed_type_register_static ()</h3>
 
242
<a class="indexterm" name="id3086892"></a><pre class="programlisting"><a href="gobject-Type-Information.html#GType">GType</a>               g_boxed_type_register_static        (const <a
 
243
href="../glib/glib-Basic-Types.html#gchar"
 
244
>gchar</a> *name,
 
245
                                                         <a href="gobject-Boxed-Types.html#GBoxedCopyFunc">GBoxedCopyFunc</a> boxed_copy,
 
246
                                                         <a href="gobject-Boxed-Types.html#GBoxedFreeFunc">GBoxedFreeFunc</a> boxed_free);</pre>
 
247
<p>
 
248
This function creates a new <a href="gobject-Type-Information.html#G-TYPE-BOXED:CAPS"><code class="literal">G_TYPE_BOXED</code></a> derived type id for a new
 
249
boxed type with name <em class="parameter"><code>name</code></em>. Boxed type handling functions have to be
 
250
provided to copy and free opaque boxed structures of this type.
 
251
</p>
 
252
<div class="variablelist"><table border="0">
 
253
<col align="left" valign="top">
 
254
<tbody>
 
255
<tr>
 
256
<td><span class="term"><em class="parameter"><code>name</code></em>&#160;:</span></td>
 
257
<td>Name of the new boxed type.
 
258
</td>
 
259
</tr>
 
260
<tr>
 
261
<td><span class="term"><em class="parameter"><code>boxed_copy</code></em>&#160;:</span></td>
 
262
<td>Boxed structure copy function.
 
263
</td>
 
264
</tr>
 
265
<tr>
 
266
<td><span class="term"><em class="parameter"><code>boxed_free</code></em>&#160;:</span></td>
 
267
<td>Boxed structure free function.
 
268
</td>
 
269
</tr>
 
270
<tr>
 
271
<td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
 
272
<td>New <a href="gobject-Type-Information.html#G-TYPE-BOXED:CAPS"><code class="literal">G_TYPE_BOXED</code></a> derived type id for <em class="parameter"><code>name</code></em>.
 
273
 
 
274
 
 
275
</td>
 
276
</tr>
 
277
</tbody>
 
278
</table></div>
 
279
</div>
 
280
<hr>
 
281
<div class="refsect2" lang="en">
 
282
<a name="id3087031"></a><h3>
 
283
<a name="g-pointer-type-register-static"></a>g_pointer_type_register_static ()</h3>
 
284
<a class="indexterm" name="id3087045"></a><pre class="programlisting"><a href="gobject-Type-Information.html#GType">GType</a>               g_pointer_type_register_static      (const <a
 
285
href="../glib/glib-Basic-Types.html#gchar"
 
286
>gchar</a> *name);</pre>
 
287
<p>
 
288
Creates a new <a href="gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> derived type id for a new
 
289
pointer type with name <em class="parameter"><code>name</code></em>. 
 
290
</p>
 
291
<div class="variablelist"><table border="0">
 
292
<col align="left" valign="top">
 
293
<tbody>
 
294
<tr>
 
295
<td><span class="term"><em class="parameter"><code>name</code></em>&#160;:</span></td>
 
296
<td>the name of the new pointer type.
 
297
</td>
 
298
</tr>
 
299
<tr>
 
300
<td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td>
 
301
<td>a new <a href="gobject-Type-Information.html#G-TYPE-POINTER:CAPS"><code class="literal">G_TYPE_POINTER</code></a> derived type id for <em class="parameter"><code>name</code></em>.
 
302
 
 
303
 
 
304
</td>
 
305
</tr>
 
306
</tbody>
 
307
</table></div>
 
308
</div>
 
309
<hr>
 
310
<div class="refsect2" lang="en">
 
311
<a name="id3087137"></a><h3>
 
312
<a name="G-TYPE-HASH-TABLE:CAPS"></a>G_TYPE_HASH_TABLE</h3>
 
313
<a class="indexterm" name="id3087153"></a><pre class="programlisting">#define   G_TYPE_HASH_TABLE       (g_hash_table_get_type ())
 
314
</pre>
 
315
<p>
 
316
The <a href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> for a boxed type holding a <a
 
317
href="../glib/glib-Hash-Tables.html#GHashTable"
 
318
><span class="type">GHashTable</span></a> reference.
 
319
</p>
 
320
<p class="since">Since 2.10
 
321
 
 
322
 
 
323
</p>
 
324
</div>
 
325
<hr>
 
326
<div class="refsect2" lang="en">
 
327
<a name="id3087193"></a><h3>
 
328
<a name="G-TYPE-DATE:CAPS"></a>G_TYPE_DATE</h3>
 
329
<a class="indexterm" name="id3087206"></a><pre class="programlisting">#define   G_TYPE_DATE             (g_date_get_type ())
 
330
</pre>
 
331
<p>
 
332
The <a href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> for <a
 
333
href="../glib/glib-Date-and-Time-Functions.html#GDate"
 
334
><span class="type">GDate</span></a>.
 
335
</p>
 
336
</div>
 
337
<hr>
 
338
<div class="refsect2" lang="en">
 
339
<a name="id3087238"></a><h3>
 
340
<a name="G-TYPE-GSTRING:CAPS"></a>G_TYPE_GSTRING</h3>
 
341
<a class="indexterm" name="id3087251"></a><pre class="programlisting">#define   G_TYPE_GSTRING          (g_gstring_get_type ())
 
342
</pre>
 
343
<p>
 
344
The <a href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> for <a
 
345
href="../glib/glib-Strings.html#GString"
 
346
><span class="type">GString</span></a>.
 
347
</p>
 
348
</div>
 
349
<hr>
 
350
<div class="refsect2" lang="en">
 
351
<a name="id3087284"></a><h3>
 
352
<a name="G-TYPE-STRV:CAPS"></a>G_TYPE_STRV</h3>
 
353
<a class="indexterm" name="id3087299"></a><pre class="programlisting">#define   G_TYPE_STRV             (g_strv_get_type ())
 
354
</pre>
 
355
<p>
 
356
The <a href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> for a boxed type holding a <a
 
357
href="../glib/glib-Standard-Macros.html#NULL:CAPS"
 
358
><code class="literal">NULL</code></a>-terminated array of strings.
 
359
</p>
 
360
<p>
 
361
The code fragments in the following example show the use of a property of
 
362
type <a href="gobject-Boxed-Types.html#G-TYPE-STRV:CAPS"><span class="type">G_TYPE_STRV</span></a> with <a href="gobject-The-Base-Object-Type.html#g-object-class-install-property"><code class="function">g_object_class_install_property()</code></a>, <a href="gobject-The-Base-Object-Type.html#g-object-set"><code class="function">g_object_set()</code></a>
 
363
and <a href="gobject-The-Base-Object-Type.html#g-object-get"><code class="function">g_object_get()</code></a>.
 
364
</p>
 
365
<div class="informalexample"><pre class="programlisting">
 
366
g_object_class_install_property (object_class,
 
367
                                 PROP_AUTHORS,
 
368
                                 g_param_spec_boxed ("authors",
 
369
                                                     _("Authors"),
 
370
                                                     _("List of authors"),
 
371
                                                     G_TYPE_STRV,
 
372
                                                     G_PARAM_READWRITE));
 
373
 
 
374
 
 
375
gchar *authors[] = { "Owen", "Tim", NULL };
 
376
g_object_set (obj, "authors", authors, NULL);
 
377
 
 
378
 
 
379
gchar *writers[];
 
380
g_object_get (obj, "authors", &amp;writers, NULL);
 
381
/* do something with writers */
 
382
g_strfreev (writers);
 
383
</pre></div>
 
384
<p class="since">Since 2.4
 
385
 
 
386
 
 
387
</p>
 
388
</div>
 
389
<hr>
 
390
<div class="refsect2" lang="en">
 
391
<a name="id3087392"></a><h3>
 
392
<a name="GStrv"></a>GStrv</h3>
 
393
<a class="indexterm" name="id3086148"></a><pre class="programlisting">typedef gchar** GStrv;
 
394
</pre>
 
395
<p>
 
396
A C representable type name for <a href="gobject-Boxed-Types.html#G-TYPE-STRV:CAPS"><span class="type">G_TYPE_STRV</span></a>.
 
397
</p>
 
398
</div>
 
399
</div>
 
400
<div class="refsect1" lang="en">
 
401
<a name="id3086173"></a><h2>See Also</h2>
 
402
<p>
 
403
<a href="gobject-Standard-Parameter-and-Value-Types.html#GParamSpecBoxed"><span class="type">GParamSpecBoxed</span></a>, <a href="gobject-Standard-Parameter-and-Value-Types.html#g-param-spec-boxed"><code class="function">g_param_spec_boxed()</code></a>
 
404
</p>
 
405
</div>
 
406
</div>
 
407
</body>
 
408
</html>