Imported Upstream version 2.50.2
[platform/upstream/glib.git] / docs / reference / gobject / html / gobject-Generic-values.html
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=UTF-8">
5 <title>Generic values: GObject Reference Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="index.html" title="GObject Reference Manual">
8 <link rel="up" href="rn01.html" title="API Reference">
9 <link rel="prev" href="gobject-Boxed-Types.html" title="Boxed Types">
10 <link rel="next" href="gobject-Standard-Parameter-and-Value-Types.html" title="Parameters and Values">
11 <meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
16 <td width="100%" align="left" class="shortcuts">
17 <a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
18                   <a href="#gobject-Generic-values.description" class="shortcut">Description</a></span>
19 </td>
20 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
21 <td><a accesskey="u" href="rn01.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
22 <td><a accesskey="p" href="gobject-Boxed-Types.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
23 <td><a accesskey="n" href="gobject-Standard-Parameter-and-Value-Types.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
24 </tr></table>
25 <div class="refentry">
26 <a name="gobject-Generic-values"></a><div class="titlepage"></div>
27 <div class="refnamediv"><table width="100%"><tr>
28 <td valign="top">
29 <h2><span class="refentrytitle"><a name="gobject-Generic-values.top_of_page"></a>Generic values</span></h2>
30 <p>Generic values — A polymorphic type that can hold values of any
31     other type</p>
32 </td>
33 <td class="gallery_image" valign="top" align="right"></td>
34 </tr></table></div>
35 <div class="refsect1">
36 <a name="gobject-Generic-values.functions"></a><h2>Functions</h2>
37 <div class="informaltable"><table class="informaltable" width="100%" border="0">
38 <colgroup>
39 <col width="150px" class="functions_return">
40 <col class="functions_name">
41 </colgroup>
42 <tbody>
43 <tr>
44 <td class="define_keyword">#define</td>
45 <td class="function_name">
46 <a class="link" href="gobject-Generic-values.html#G-VALUE-HOLDS:CAPS" title="G_VALUE_HOLDS()">G_VALUE_HOLDS</a><span class="c_punctuation">()</span>
47 </td>
48 </tr>
49 <tr>
50 <td class="define_keyword">#define</td>
51 <td class="function_name">
52 <a class="link" href="gobject-Generic-values.html#G-VALUE-TYPE:CAPS" title="G_VALUE_TYPE()">G_VALUE_TYPE</a><span class="c_punctuation">()</span>
53 </td>
54 </tr>
55 <tr>
56 <td class="define_keyword">#define</td>
57 <td class="function_name">
58 <a class="link" href="gobject-Generic-values.html#G-VALUE-TYPE-NAME:CAPS" title="G_VALUE_TYPE_NAME()">G_VALUE_TYPE_NAME</a><span class="c_punctuation">()</span>
59 </td>
60 </tr>
61 <tr>
62 <td class="define_keyword">#define</td>
63 <td class="function_name">
64 <a class="link" href="gobject-Generic-values.html#G-TYPE-IS-VALUE:CAPS" title="G_TYPE_IS_VALUE()">G_TYPE_IS_VALUE</a><span class="c_punctuation">()</span>
65 </td>
66 </tr>
67 <tr>
68 <td class="define_keyword">#define</td>
69 <td class="function_name">
70 <a class="link" href="gobject-Generic-values.html#G-TYPE-IS-VALUE-ABSTRACT:CAPS" title="G_TYPE_IS_VALUE_ABSTRACT()">G_TYPE_IS_VALUE_ABSTRACT</a><span class="c_punctuation">()</span>
71 </td>
72 </tr>
73 <tr>
74 <td class="define_keyword">#define</td>
75 <td class="function_name">
76 <a class="link" href="gobject-Generic-values.html#G-IS-VALUE:CAPS" title="G_IS_VALUE()">G_IS_VALUE</a><span class="c_punctuation">()</span>
77 </td>
78 </tr>
79 <tr>
80 <td class="function_type">
81 <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="returnvalue">GValue</span></a> *
82 </td>
83 <td class="function_name">
84 <a class="link" href="gobject-Generic-values.html#g-value-init" title="g_value_init ()">g_value_init</a> <span class="c_punctuation">()</span>
85 </td>
86 </tr>
87 <tr>
88 <td class="function_type">
89 <span class="returnvalue">void</span>
90 </td>
91 <td class="function_name">
92 <a class="link" href="gobject-Generic-values.html#g-value-copy" title="g_value_copy ()">g_value_copy</a> <span class="c_punctuation">()</span>
93 </td>
94 </tr>
95 <tr>
96 <td class="function_type">
97 <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="returnvalue">GValue</span></a> *
98 </td>
99 <td class="function_name">
100 <a class="link" href="gobject-Generic-values.html#g-value-reset" title="g_value_reset ()">g_value_reset</a> <span class="c_punctuation">()</span>
101 </td>
102 </tr>
103 <tr>
104 <td class="function_type">
105 <span class="returnvalue">void</span>
106 </td>
107 <td class="function_name">
108 <a class="link" href="gobject-Generic-values.html#g-value-unset" title="g_value_unset ()">g_value_unset</a> <span class="c_punctuation">()</span>
109 </td>
110 </tr>
111 <tr>
112 <td class="function_type">
113 <span class="returnvalue">void</span>
114 </td>
115 <td class="function_name">
116 <a class="link" href="gobject-Generic-values.html#g-value-init-from-instance" title="g_value_init_from_instance ()">g_value_init_from_instance</a> <span class="c_punctuation">()</span>
117 </td>
118 </tr>
119 <tr>
120 <td class="function_type">
121 <span class="returnvalue">void</span>
122 </td>
123 <td class="function_name">
124 <a class="link" href="gobject-Generic-values.html#g-value-set-instance" title="g_value_set_instance ()">g_value_set_instance</a> <span class="c_punctuation">()</span>
125 </td>
126 </tr>
127 <tr>
128 <td class="function_type">
129 <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
130 </td>
131 <td class="function_name">
132 <a class="link" href="gobject-Generic-values.html#g-value-fits-pointer" title="g_value_fits_pointer ()">g_value_fits_pointer</a> <span class="c_punctuation">()</span>
133 </td>
134 </tr>
135 <tr>
136 <td class="function_type">
137 <a href="../glib-Basic-Types.html#gpointer"><span class="returnvalue">gpointer</span></a>
138 </td>
139 <td class="function_name">
140 <a class="link" href="gobject-Generic-values.html#g-value-peek-pointer" title="g_value_peek_pointer ()">g_value_peek_pointer</a> <span class="c_punctuation">()</span>
141 </td>
142 </tr>
143 <tr>
144 <td class="function_type">
145 <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
146 </td>
147 <td class="function_name">
148 <a class="link" href="gobject-Generic-values.html#g-value-type-compatible" title="g_value_type_compatible ()">g_value_type_compatible</a> <span class="c_punctuation">()</span>
149 </td>
150 </tr>
151 <tr>
152 <td class="function_type">
153 <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
154 </td>
155 <td class="function_name">
156 <a class="link" href="gobject-Generic-values.html#g-value-type-transformable" title="g_value_type_transformable ()">g_value_type_transformable</a> <span class="c_punctuation">()</span>
157 </td>
158 </tr>
159 <tr>
160 <td class="function_type">
161 <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
162 </td>
163 <td class="function_name">
164 <a class="link" href="gobject-Generic-values.html#g-value-transform" title="g_value_transform ()">g_value_transform</a> <span class="c_punctuation">()</span>
165 </td>
166 </tr>
167 <tr>
168 <td class="function_type">
169 <span class="returnvalue">void</span>
170 </td>
171 <td class="function_name">
172 <span class="c_punctuation">(</span><a class="link" href="gobject-Generic-values.html#GValueTransform" title="GValueTransform ()">*GValueTransform</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span>
173 </td>
174 </tr>
175 <tr>
176 <td class="function_type">
177 <span class="returnvalue">void</span>
178 </td>
179 <td class="function_name">
180 <a class="link" href="gobject-Generic-values.html#g-value-register-transform-func" title="g_value_register_transform_func ()">g_value_register_transform_func</a> <span class="c_punctuation">()</span>
181 </td>
182 </tr>
183 <tr>
184 <td class="function_type">
185 <a href="../glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> *
186 </td>
187 <td class="function_name">
188 <a class="link" href="gobject-Generic-values.html#g-strdup-value-contents" title="g_strdup_value_contents ()">g_strdup_value_contents</a> <span class="c_punctuation">()</span>
189 </td>
190 </tr>
191 </tbody>
192 </table></div>
193 </div>
194 <div class="refsect1">
195 <a name="gobject-Generic-values.other"></a><h2>Types and Values</h2>
196 <div class="informaltable"><table class="informaltable" width="100%" border="0">
197 <colgroup>
198 <col width="150px" class="name">
199 <col class="description">
200 </colgroup>
201 <tbody>
202 <tr>
203 <td class="define_keyword">#define</td>
204 <td class="function_name"><a class="link" href="gobject-Generic-values.html#G-VALUE-INIT:CAPS" title="G_VALUE_INIT">G_VALUE_INIT</a></td>
205 </tr>
206 <tr>
207 <td class="datatype_keyword"> </td>
208 <td class="function_name"><a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a></td>
209 </tr>
210 <tr>
211 <td class="define_keyword">#define</td>
212 <td class="function_name"><a class="link" href="gobject-Generic-values.html#G-TYPE-VALUE:CAPS" title="G_TYPE_VALUE">G_TYPE_VALUE</a></td>
213 </tr>
214 <tr>
215 <td class="define_keyword">#define</td>
216 <td class="function_name"><a class="link" href="gobject-Generic-values.html#G-TYPE-VALUE-ARRAY:CAPS" title="G_TYPE_VALUE_ARRAY">G_TYPE_VALUE_ARRAY</a></td>
217 </tr>
218 </tbody>
219 </table></div>
220 </div>
221 <div class="refsect1">
222 <a name="gobject-Generic-values.includes"></a><h2>Includes</h2>
223 <pre class="synopsis">#include &lt;glib-object.h&gt;
224 </pre>
225 </div>
226 <div class="refsect1">
227 <a name="gobject-Generic-values.description"></a><h2>Description</h2>
228 <p>The <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure is basically a variable container that consists
229 of a type identifier and a specific value of that type.
230 The type identifier within a <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure always determines the
231 type of the associated value.
232 To create a undefined <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure, simply create a zero-filled
233 <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure. To initialize the <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>, use the <a class="link" href="gobject-Generic-values.html#g-value-init" title="g_value_init ()"><code class="function">g_value_init()</code></a>
234 function. A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> cannot be used until it is initialized.
235 The basic type operations (such as freeing and copying) are determined
236 by the <a class="link" href="gobject-Type-Information.html#GTypeValueTable" title="struct GTypeValueTable"><span class="type">GTypeValueTable</span></a> associated with the type ID stored in the <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>.
237 Other <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> operations (such as converting values between types) are
238 provided by this interface.</p>
239 <p>The code in the example program below demonstrates <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>'s
240 features.</p>
241 <div class="informalexample">
242   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
243     <tbody>
244       <tr>
245         <td class="listing_lines" align="right"><pre>1
246 2
247 3
248 4
249 5
250 6
251 7
252 8
253 9
254 10
255 11
256 12
257 13
258 14
259 15
260 16
261 17
262 18
263 19
264 20
265 21
266 22
267 23
268 24
269 25
270 26
271 27
272 28
273 29
274 30
275 31
276 32
277 33
278 34
279 35
280 36
281 37
282 38
283 39
284 40
285 41
286 42
287 43
288 44
289 45
290 46
291 47
292 48
293 49
294 50
295 51
296 52</pre></td>
297         <td class="listing_code"><pre class="programlisting"><span class="gtkdoc ppc">#include &lt;glib-object.h&gt;</span>
298
299 <span class="gtkdoc kwb">static void</span>
300 <span class="function">int2string</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwb">const</span> GValue <span class="gtkdoc opt">*</span>src_value<span class="gtkdoc opt">,</span>
301             GValue       <span class="gtkdoc opt">*</span>dest_value<span class="gtkdoc opt">)</span>
302 <span class="gtkdoc opt">{</span>
303   <span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#g-value-get-int">g_value_get_int</a></span> <span class="gtkdoc opt">(</span>src_value<span class="gtkdoc opt">) ==</span> <span class="number">42</span><span class="gtkdoc opt">)</span>
304     <span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#g-value-set-static-string">g_value_set_static_string</a></span> <span class="gtkdoc opt">(</span>dest_value<span class="gtkdoc opt">,</span> <span class="string">&quot;An important number&quot;</span><span class="gtkdoc opt">);</span>
305   <span class="keyword">else</span>
306     <span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#g-value-set-static-string">g_value_set_static_string</a></span> <span class="gtkdoc opt">(</span>dest_value<span class="gtkdoc opt">,</span> <span class="string">&quot;What&apos;s that?&quot;</span><span class="gtkdoc opt">);</span>
307 <span class="gtkdoc opt">}</span>
308
309 <span class="gtkdoc kwb">int</span>
310 <span class="function">main</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwb">int</span>   argc<span class="gtkdoc opt">,</span>
311       <span class="gtkdoc kwb">char</span> <span class="gtkdoc opt">*</span>argv<span class="gtkdoc opt">[])</span>
312 <span class="gtkdoc opt">{</span>
313   <span class="gtkdoc slc">// GValues must be initialized</span>
314   GValue a <span class="gtkdoc opt">=</span> G_VALUE_INIT<span class="gtkdoc opt">;</span>
315   GValue b <span class="gtkdoc opt">=</span> G_VALUE_INIT<span class="gtkdoc opt">;</span>
316   <span class="gtkdoc kwb">const</span> gchar <span class="gtkdoc opt">*</span>message<span class="gtkdoc opt">;</span>
317
318   <span class="gtkdoc slc">// The GValue starts empty</span>
319   <span class="function"><a href="../glib-Testing.html#g-assert">g_assert</a></span> <span class="gtkdoc opt">(!</span><span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#G-VALUE-HOLDS-STRING:CAPS">G_VALUE_HOLDS_STRING</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">));</span>
320
321   <span class="gtkdoc slc">// Put a string in it</span>
322   <span class="function"><a href="gobject-Generic-values.html#g-value-init">g_value_init</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">,</span> G_TYPE_STRING<span class="gtkdoc opt">);</span>
323   <span class="function"><a href="../glib-Testing.html#g-assert">g_assert</a></span> <span class="gtkdoc opt">(</span><span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#G-VALUE-HOLDS-STRING:CAPS">G_VALUE_HOLDS_STRING</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">));</span>
324   <span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#g-value-set-static-string">g_value_set_static_string</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">,</span> <span class="string">&quot;Hello, world!&quot;</span><span class="gtkdoc opt">);</span>
325   <span class="function"><a href="../glib-String-Utility-Functions.html#g-printf">g_printf</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;%s</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span> <span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#g-value-get-string">g_value_get_string</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">));</span>
326
327   <span class="gtkdoc slc">// Reset it to its pristine state</span>
328   <span class="function"><a href="gobject-Generic-values.html#g-value-unset">g_value_unset</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">);</span>
329
330   <span class="gtkdoc slc">// It can then be reused for another type</span>
331   <span class="function"><a href="gobject-Generic-values.html#g-value-init">g_value_init</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">,</span> G_TYPE_INT<span class="gtkdoc opt">);</span>
332   <span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#g-value-set-int">g_value_set_int</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">,</span> <span class="number">42</span><span class="gtkdoc opt">);</span>
333
334   <span class="gtkdoc slc">// Attempt to transform it into a GValue of type STRING</span>
335   <span class="function"><a href="gobject-Generic-values.html#g-value-init">g_value_init</a></span> <span class="gtkdoc opt">(&amp;</span>b<span class="gtkdoc opt">,</span> G_TYPE_STRING<span class="gtkdoc opt">);</span>
336
337   <span class="gtkdoc slc">// An INT is transformable to a STRING</span>
338   <span class="function"><a href="../glib-Testing.html#g-assert">g_assert</a></span> <span class="gtkdoc opt">(</span><span class="function"><a href="gobject-Generic-values.html#g-value-type-transformable">g_value_type_transformable</a></span> <span class="gtkdoc opt">(</span>G_TYPE_INT<span class="gtkdoc opt">,</span> G_TYPE_STRING<span class="gtkdoc opt">));</span>
339
340   <span class="function"><a href="gobject-Generic-values.html#g-value-transform">g_value_transform</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">, &amp;</span>b<span class="gtkdoc opt">);</span>
341   <span class="function"><a href="../glib-String-Utility-Functions.html#g-printf">g_printf</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;%s</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span> <span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#g-value-get-string">g_value_get_string</a></span> <span class="gtkdoc opt">(&amp;</span>b<span class="gtkdoc opt">));</span>
342
343   <span class="gtkdoc slc">// Attempt to transform it again using a custom transform function</span>
344   <span class="function"><a href="gobject-Generic-values.html#g-value-register-transform-func">g_value_register_transform_func</a></span> <span class="gtkdoc opt">(</span>G_TYPE_INT<span class="gtkdoc opt">,</span> G_TYPE_STRING<span class="gtkdoc opt">,</span> int2string<span class="gtkdoc opt">);</span>
345   <span class="function"><a href="gobject-Generic-values.html#g-value-transform">g_value_transform</a></span> <span class="gtkdoc opt">(&amp;</span>a<span class="gtkdoc opt">, &amp;</span>b<span class="gtkdoc opt">);</span>
346   <span class="function"><a href="../glib-String-Utility-Functions.html#g-printf">g_printf</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;%s</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span> <span class="function"><a href="gobject-Standard-Parameter-and-Value-Types.html#g-value-get-string">g_value_get_string</a></span> <span class="gtkdoc opt">(&amp;</span>b<span class="gtkdoc opt">));</span>
347   <span class="keyword">return</span> <span class="number">0</span><span class="gtkdoc opt">;</span>
348 <span class="gtkdoc opt">}</span></pre></td>
349       </tr>
350     </tbody>
351   </table>
352 </div>
353
354 <p></p>
355 </div>
356 <div class="refsect1">
357 <a name="gobject-Generic-values.functions_details"></a><h2>Functions</h2>
358 <div class="refsect2">
359 <a name="G-VALUE-HOLDS:CAPS"></a><h3>G_VALUE_HOLDS()</h3>
360 <pre class="programlisting">#define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type)))
361 </pre>
362 <p>Checks if <em class="parameter"><code>value</code></em>
363  holds (or contains) a value of <em class="parameter"><code>type</code></em>
364 .
365 This macro will also check for <em class="parameter"><code>value</code></em>
366  != <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> and issue a
367 warning if the check fails.</p>
368 <div class="refsect3">
369 <a name="G-VALUE-HOLDS.parameters"></a><h4>Parameters</h4>
370 <div class="informaltable"><table class="informaltable" width="100%" border="0">
371 <colgroup>
372 <col width="150px" class="parameters_name">
373 <col class="parameters_description">
374 <col width="200px" class="parameters_annotations">
375 </colgroup>
376 <tbody>
377 <tr>
378 <td class="parameter_name"><p>value</p></td>
379 <td class="parameter_description"><p>A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
380 <td class="parameter_annotations"> </td>
381 </tr>
382 <tr>
383 <td class="parameter_name"><p>type</p></td>
384 <td class="parameter_description"><p>A <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> value.</p></td>
385 <td class="parameter_annotations"> </td>
386 </tr>
387 </tbody>
388 </table></div>
389 </div>
390 <div class="refsect3">
391 <a name="G-VALUE-HOLDS.returns"></a><h4>Returns</h4>
392 <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>value</code></em>
393 holds the <em class="parameter"><code>type</code></em>
394 .</p>
395 </div>
396 </div>
397 <hr>
398 <div class="refsect2">
399 <a name="G-VALUE-TYPE:CAPS"></a><h3>G_VALUE_TYPE()</h3>
400 <pre class="programlisting">#define G_VALUE_TYPE(value)                (((GValue*) (value))-&gt;g_type)
401 </pre>
402 <p>Get the type identifier of <em class="parameter"><code>value</code></em>
403 .</p>
404 <div class="refsect3">
405 <a name="G-VALUE-TYPE.parameters"></a><h4>Parameters</h4>
406 <div class="informaltable"><table class="informaltable" width="100%" border="0">
407 <colgroup>
408 <col width="150px" class="parameters_name">
409 <col class="parameters_description">
410 <col width="200px" class="parameters_annotations">
411 </colgroup>
412 <tbody><tr>
413 <td class="parameter_name"><p>value</p></td>
414 <td class="parameter_description"><p>A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
415 <td class="parameter_annotations"> </td>
416 </tr></tbody>
417 </table></div>
418 </div>
419 <div class="refsect3">
420 <a name="G-VALUE-TYPE.returns"></a><h4>Returns</h4>
421 <p> the <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a>.</p>
422 </div>
423 </div>
424 <hr>
425 <div class="refsect2">
426 <a name="G-VALUE-TYPE-NAME:CAPS"></a><h3>G_VALUE_TYPE_NAME()</h3>
427 <pre class="programlisting">#define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value)))
428 </pre>
429 <p>Gets the type name of <em class="parameter"><code>value</code></em>
430 .</p>
431 <div class="refsect3">
432 <a name="G-VALUE-TYPE-NAME.parameters"></a><h4>Parameters</h4>
433 <div class="informaltable"><table class="informaltable" width="100%" border="0">
434 <colgroup>
435 <col width="150px" class="parameters_name">
436 <col class="parameters_description">
437 <col width="200px" class="parameters_annotations">
438 </colgroup>
439 <tbody><tr>
440 <td class="parameter_name"><p>value</p></td>
441 <td class="parameter_description"><p>A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
442 <td class="parameter_annotations"> </td>
443 </tr></tbody>
444 </table></div>
445 </div>
446 <div class="refsect3">
447 <a name="G-VALUE-TYPE-NAME.returns"></a><h4>Returns</h4>
448 <p> the type name.</p>
449 </div>
450 </div>
451 <hr>
452 <div class="refsect2">
453 <a name="G-TYPE-IS-VALUE:CAPS"></a><h3>G_TYPE_IS_VALUE()</h3>
454 <pre class="programlisting">#define G_TYPE_IS_VALUE(type)              (g_type_check_is_value_type (type))
455 </pre>
456 <p>Checks whether the passed in type ID can be used for <a class="link" href="gobject-Generic-values.html#g-value-init" title="g_value_init ()"><code class="function">g_value_init()</code></a>.
457 That is, this macro checks whether this type provides an implementation
458 of the <a class="link" href="gobject-Type-Information.html#GTypeValueTable" title="struct GTypeValueTable"><span class="type">GTypeValueTable</span></a> functions required for a type to create a <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> of.</p>
459 <div class="refsect3">
460 <a name="G-TYPE-IS-VALUE.parameters"></a><h4>Parameters</h4>
461 <div class="informaltable"><table class="informaltable" width="100%" border="0">
462 <colgroup>
463 <col width="150px" class="parameters_name">
464 <col class="parameters_description">
465 <col width="200px" class="parameters_annotations">
466 </colgroup>
467 <tbody><tr>
468 <td class="parameter_name"><p>type</p></td>
469 <td class="parameter_description"><p>A <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> value.</p></td>
470 <td class="parameter_annotations"> </td>
471 </tr></tbody>
472 </table></div>
473 </div>
474 <div class="refsect3">
475 <a name="G-TYPE-IS-VALUE.returns"></a><h4>Returns</h4>
476 <p> Whether <em class="parameter"><code>type</code></em>
477 is suitable as a <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> type.</p>
478 </div>
479 </div>
480 <hr>
481 <div class="refsect2">
482 <a name="G-TYPE-IS-VALUE-ABSTRACT:CAPS"></a><h3>G_TYPE_IS_VALUE_ABSTRACT()</h3>
483 <pre class="programlisting">#define G_TYPE_IS_VALUE_ABSTRACT(type)          (g_type_test_flags ((type), G_TYPE_FLAG_VALUE_ABSTRACT))
484 </pre>
485 <p>Checks if <em class="parameter"><code>type</code></em>
486  is an abstract value type.  An abstract value type introduces
487 a value table, but can't be used for <a class="link" href="gobject-Generic-values.html#g-value-init" title="g_value_init ()"><code class="function">g_value_init()</code></a> and is normally used as
488 an abstract base type for derived value types.</p>
489 <div class="refsect3">
490 <a name="G-TYPE-IS-VALUE-ABSTRACT.parameters"></a><h4>Parameters</h4>
491 <div class="informaltable"><table class="informaltable" width="100%" border="0">
492 <colgroup>
493 <col width="150px" class="parameters_name">
494 <col class="parameters_description">
495 <col width="200px" class="parameters_annotations">
496 </colgroup>
497 <tbody><tr>
498 <td class="parameter_name"><p>type</p></td>
499 <td class="parameter_description"><p>A <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> value</p></td>
500 <td class="parameter_annotations"> </td>
501 </tr></tbody>
502 </table></div>
503 </div>
504 <div class="refsect3">
505 <a name="G-TYPE-IS-VALUE-ABSTRACT.returns"></a><h4>Returns</h4>
506 <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success</p>
507 </div>
508 </div>
509 <hr>
510 <div class="refsect2">
511 <a name="G-IS-VALUE:CAPS"></a><h3>G_IS_VALUE()</h3>
512 <pre class="programlisting">#define G_IS_VALUE(value)          (G_TYPE_CHECK_VALUE (value))
513 </pre>
514 <p>Checks if <em class="parameter"><code>value</code></em>
515  is a valid and initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p>
516 <div class="refsect3">
517 <a name="G-IS-VALUE.parameters"></a><h4>Parameters</h4>
518 <div class="informaltable"><table class="informaltable" width="100%" border="0">
519 <colgroup>
520 <col width="150px" class="parameters_name">
521 <col class="parameters_description">
522 <col width="200px" class="parameters_annotations">
523 </colgroup>
524 <tbody><tr>
525 <td class="parameter_name"><p>value</p></td>
526 <td class="parameter_description"><p>A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
527 <td class="parameter_annotations"> </td>
528 </tr></tbody>
529 </table></div>
530 </div>
531 <div class="refsect3">
532 <a name="G-IS-VALUE.returns"></a><h4>Returns</h4>
533 <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success.</p>
534 </div>
535 </div>
536 <hr>
537 <div class="refsect2">
538 <a name="g-value-init"></a><h3>g_value_init ()</h3>
539 <pre class="programlisting"><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="returnvalue">GValue</span></a> *
540 g_value_init (<em class="parameter"><code><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *value</code></em>,
541               <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> g_type</code></em>);</pre>
542 <p>Initializes <em class="parameter"><code>value</code></em>
543  with the default value of <em class="parameter"><code>type</code></em>
544 .</p>
545 <div class="refsect3">
546 <a name="g-value-init.parameters"></a><h4>Parameters</h4>
547 <div class="informaltable"><table class="informaltable" width="100%" border="0">
548 <colgroup>
549 <col width="150px" class="parameters_name">
550 <col class="parameters_description">
551 <col width="200px" class="parameters_annotations">
552 </colgroup>
553 <tbody>
554 <tr>
555 <td class="parameter_name"><p>value</p></td>
556 <td class="parameter_description"><p>A zero-filled (uninitialized) <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
557 <td class="parameter_annotations"> </td>
558 </tr>
559 <tr>
560 <td class="parameter_name"><p>g_type</p></td>
561 <td class="parameter_description"><p>Type the <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> should hold values of.</p></td>
562 <td class="parameter_annotations"> </td>
563 </tr>
564 </tbody>
565 </table></div>
566 </div>
567 <div class="refsect3">
568 <a name="g-value-init.returns"></a><h4>Returns</h4>
569 <p> the <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure that has been passed in. </p>
570 <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
571 </div>
572 </div>
573 <hr>
574 <div class="refsect2">
575 <a name="g-value-copy"></a><h3>g_value_copy ()</h3>
576 <pre class="programlisting"><span class="returnvalue">void</span>
577 g_value_copy (<em class="parameter"><code>const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *src_value</code></em>,
578               <em class="parameter"><code><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *dest_value</code></em>);</pre>
579 <p>Copies the value of <em class="parameter"><code>src_value</code></em>
580  into <em class="parameter"><code>dest_value</code></em>
581 .</p>
582 <div class="refsect3">
583 <a name="g-value-copy.parameters"></a><h4>Parameters</h4>
584 <div class="informaltable"><table class="informaltable" width="100%" border="0">
585 <colgroup>
586 <col width="150px" class="parameters_name">
587 <col class="parameters_description">
588 <col width="200px" class="parameters_annotations">
589 </colgroup>
590 <tbody>
591 <tr>
592 <td class="parameter_name"><p>src_value</p></td>
593 <td class="parameter_description"><p>An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
594 <td class="parameter_annotations"> </td>
595 </tr>
596 <tr>
597 <td class="parameter_name"><p>dest_value</p></td>
598 <td class="parameter_description"><p>An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure of the same type as <em class="parameter"><code>src_value</code></em>
599 .</p></td>
600 <td class="parameter_annotations"> </td>
601 </tr>
602 </tbody>
603 </table></div>
604 </div>
605 </div>
606 <hr>
607 <div class="refsect2">
608 <a name="g-value-reset"></a><h3>g_value_reset ()</h3>
609 <pre class="programlisting"><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="returnvalue">GValue</span></a> *
610 g_value_reset (<em class="parameter"><code><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *value</code></em>);</pre>
611 <p>Clears the current value in <em class="parameter"><code>value</code></em>
612  and resets it to the default value
613 (as if the value had just been initialized).</p>
614 <div class="refsect3">
615 <a name="g-value-reset.parameters"></a><h4>Parameters</h4>
616 <div class="informaltable"><table class="informaltable" width="100%" border="0">
617 <colgroup>
618 <col width="150px" class="parameters_name">
619 <col class="parameters_description">
620 <col width="200px" class="parameters_annotations">
621 </colgroup>
622 <tbody><tr>
623 <td class="parameter_name"><p>value</p></td>
624 <td class="parameter_description"><p>An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
625 <td class="parameter_annotations"> </td>
626 </tr></tbody>
627 </table></div>
628 </div>
629 <div class="refsect3">
630 <a name="g-value-reset.returns"></a><h4>Returns</h4>
631 <p> the <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure that has been passed in</p>
632 </div>
633 </div>
634 <hr>
635 <div class="refsect2">
636 <a name="g-value-unset"></a><h3>g_value_unset ()</h3>
637 <pre class="programlisting"><span class="returnvalue">void</span>
638 g_value_unset (<em class="parameter"><code><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *value</code></em>);</pre>
639 <p>Clears the current value in <em class="parameter"><code>value</code></em>
640  (if any) and "unsets" the type,
641 this releases all resources associated with this GValue. An unset
642 value is the same as an uninitialized (zero-filled) <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>
643 structure.</p>
644 <div class="refsect3">
645 <a name="g-value-unset.parameters"></a><h4>Parameters</h4>
646 <div class="informaltable"><table class="informaltable" width="100%" border="0">
647 <colgroup>
648 <col width="150px" class="parameters_name">
649 <col class="parameters_description">
650 <col width="200px" class="parameters_annotations">
651 </colgroup>
652 <tbody><tr>
653 <td class="parameter_name"><p>value</p></td>
654 <td class="parameter_description"><p>An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
655 <td class="parameter_annotations"> </td>
656 </tr></tbody>
657 </table></div>
658 </div>
659 </div>
660 <hr>
661 <div class="refsect2">
662 <a name="g-value-init-from-instance"></a><h3>g_value_init_from_instance ()</h3>
663 <pre class="programlisting"><span class="returnvalue">void</span>
664 g_value_init_from_instance (<em class="parameter"><code><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *value</code></em>,
665                             <em class="parameter"><code><a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> instance</code></em>);</pre>
666 <p>Initializes and sets <em class="parameter"><code>value</code></em>
667  from an instantiatable type via the
668 value_table's <code class="function">collect_value()</code> function.</p>
669 <p>Note: The <em class="parameter"><code>value</code></em>
670  will be initialised with the exact type of
671 <em class="parameter"><code>instance</code></em>
672 .  If you wish to set the <em class="parameter"><code>value</code></em>
673 's type to a different GType
674 (such as a parent class GType), you need to manually call
675 <a class="link" href="gobject-Generic-values.html#g-value-init" title="g_value_init ()"><code class="function">g_value_init()</code></a> and <a class="link" href="gobject-Generic-values.html#g-value-set-instance" title="g_value_set_instance ()"><code class="function">g_value_set_instance()</code></a>.</p>
676 <div class="refsect3">
677 <a name="g-value-init-from-instance.parameters"></a><h4>Parameters</h4>
678 <div class="informaltable"><table class="informaltable" width="100%" border="0">
679 <colgroup>
680 <col width="150px" class="parameters_name">
681 <col class="parameters_description">
682 <col width="200px" class="parameters_annotations">
683 </colgroup>
684 <tbody>
685 <tr>
686 <td class="parameter_name"><p>value</p></td>
687 <td class="parameter_description"><p>An uninitialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
688 <td class="parameter_annotations"> </td>
689 </tr>
690 <tr>
691 <td class="parameter_name"><p>instance</p></td>
692 <td class="parameter_description"><p> the instance. </p></td>
693 <td class="parameter_annotations"><span class="annotation">[<acronym title="Override the parsed C type with given type."><span class="acronym">type</span></acronym> GObject.TypeInstance]</span></td>
694 </tr>
695 </tbody>
696 </table></div>
697 </div>
698 <p class="since">Since: <a class="link" href="api-index-2-42.html#api-index-2.42">2.42</a></p>
699 </div>
700 <hr>
701 <div class="refsect2">
702 <a name="g-value-set-instance"></a><h3>g_value_set_instance ()</h3>
703 <pre class="programlisting"><span class="returnvalue">void</span>
704 g_value_set_instance (<em class="parameter"><code><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *value</code></em>,
705                       <em class="parameter"><code><a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> instance</code></em>);</pre>
706 <p>Sets <em class="parameter"><code>value</code></em>
707  from an instantiatable type via the
708 value_table's <code class="function">collect_value()</code> function.</p>
709 <div class="refsect3">
710 <a name="g-value-set-instance.parameters"></a><h4>Parameters</h4>
711 <div class="informaltable"><table class="informaltable" width="100%" border="0">
712 <colgroup>
713 <col width="150px" class="parameters_name">
714 <col class="parameters_description">
715 <col width="200px" class="parameters_annotations">
716 </colgroup>
717 <tbody>
718 <tr>
719 <td class="parameter_name"><p>value</p></td>
720 <td class="parameter_description"><p>An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
721 <td class="parameter_annotations"> </td>
722 </tr>
723 <tr>
724 <td class="parameter_name"><p>instance</p></td>
725 <td class="parameter_description"><p> the instance. </p></td>
726 <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>
727 </tr>
728 </tbody>
729 </table></div>
730 </div>
731 </div>
732 <hr>
733 <div class="refsect2">
734 <a name="g-value-fits-pointer"></a><h3>g_value_fits_pointer ()</h3>
735 <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
736 g_value_fits_pointer (<em class="parameter"><code>const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *value</code></em>);</pre>
737 <p>Determines if <em class="parameter"><code>value</code></em>
738  will fit inside the size of a pointer value.
739 This is an internal function introduced mainly for C marshallers.</p>
740 <div class="refsect3">
741 <a name="g-value-fits-pointer.parameters"></a><h4>Parameters</h4>
742 <div class="informaltable"><table class="informaltable" width="100%" border="0">
743 <colgroup>
744 <col width="150px" class="parameters_name">
745 <col class="parameters_description">
746 <col width="200px" class="parameters_annotations">
747 </colgroup>
748 <tbody><tr>
749 <td class="parameter_name"><p>value</p></td>
750 <td class="parameter_description"><p>An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p></td>
751 <td class="parameter_annotations"> </td>
752 </tr></tbody>
753 </table></div>
754 </div>
755 <div class="refsect3">
756 <a name="g-value-fits-pointer.returns"></a><h4>Returns</h4>
757 <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <em class="parameter"><code>value</code></em>
758 will fit inside a pointer value.</p>
759 </div>
760 </div>
761 <hr>
762 <div class="refsect2">
763 <a name="g-value-peek-pointer"></a><h3>g_value_peek_pointer ()</h3>
764 <pre class="programlisting"><a href="../glib-Basic-Types.html#gpointer"><span class="returnvalue">gpointer</span></a>
765 g_value_peek_pointer (<em class="parameter"><code>const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *value</code></em>);</pre>
766 <p>Returns the value contents as pointer. This function asserts that
767 <a class="link" href="gobject-Generic-values.html#g-value-fits-pointer" title="g_value_fits_pointer ()"><code class="function">g_value_fits_pointer()</code></a> returned <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> for the passed in value.
768 This is an internal function introduced mainly for C marshallers.</p>
769 <div class="refsect3">
770 <a name="g-value-peek-pointer.parameters"></a><h4>Parameters</h4>
771 <div class="informaltable"><table class="informaltable" width="100%" border="0">
772 <colgroup>
773 <col width="150px" class="parameters_name">
774 <col class="parameters_description">
775 <col width="200px" class="parameters_annotations">
776 </colgroup>
777 <tbody><tr>
778 <td class="parameter_name"><p>value</p></td>
779 <td class="parameter_description"><p>An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure</p></td>
780 <td class="parameter_annotations"> </td>
781 </tr></tbody>
782 </table></div>
783 </div>
784 <div class="refsect3">
785 <a name="g-value-peek-pointer.returns"></a><h4>Returns</h4>
786 <p> the value contents as pointer. </p>
787 <p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
788 </div>
789 </div>
790 <hr>
791 <div class="refsect2">
792 <a name="g-value-type-compatible"></a><h3>g_value_type_compatible ()</h3>
793 <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
794 g_value_type_compatible (<em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> src_type</code></em>,
795                          <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> dest_type</code></em>);</pre>
796 <p>Returns whether a <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> of type <em class="parameter"><code>src_type</code></em>
797  can be copied into
798 a <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> of type <em class="parameter"><code>dest_type</code></em>
799 .</p>
800 <div class="refsect3">
801 <a name="g-value-type-compatible.parameters"></a><h4>Parameters</h4>
802 <div class="informaltable"><table class="informaltable" width="100%" border="0">
803 <colgroup>
804 <col width="150px" class="parameters_name">
805 <col class="parameters_description">
806 <col width="200px" class="parameters_annotations">
807 </colgroup>
808 <tbody>
809 <tr>
810 <td class="parameter_name"><p>src_type</p></td>
811 <td class="parameter_description"><p>source type to be copied.</p></td>
812 <td class="parameter_annotations"> </td>
813 </tr>
814 <tr>
815 <td class="parameter_name"><p>dest_type</p></td>
816 <td class="parameter_description"><p>destination type for copying.</p></td>
817 <td class="parameter_annotations"> </td>
818 </tr>
819 </tbody>
820 </table></div>
821 </div>
822 <div class="refsect3">
823 <a name="g-value-type-compatible.returns"></a><h4>Returns</h4>
824 <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if <a class="link" href="gobject-Generic-values.html#g-value-copy" title="g_value_copy ()"><code class="function">g_value_copy()</code></a> is possible with <em class="parameter"><code>src_type</code></em>
825 and <em class="parameter"><code>dest_type</code></em>
826 .</p>
827 </div>
828 </div>
829 <hr>
830 <div class="refsect2">
831 <a name="g-value-type-transformable"></a><h3>g_value_type_transformable ()</h3>
832 <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
833 g_value_type_transformable (<em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> src_type</code></em>,
834                             <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> dest_type</code></em>);</pre>
835 <p>Check whether <a class="link" href="gobject-Generic-values.html#g-value-transform" title="g_value_transform ()"><code class="function">g_value_transform()</code></a> is able to transform values
836 of type <em class="parameter"><code>src_type</code></em>
837  into values of type <em class="parameter"><code>dest_type</code></em>
838 . Note that for
839 the types to be transformable, they must be compatible or a
840 transformation function must be registered.</p>
841 <div class="refsect3">
842 <a name="g-value-type-transformable.parameters"></a><h4>Parameters</h4>
843 <div class="informaltable"><table class="informaltable" width="100%" border="0">
844 <colgroup>
845 <col width="150px" class="parameters_name">
846 <col class="parameters_description">
847 <col width="200px" class="parameters_annotations">
848 </colgroup>
849 <tbody>
850 <tr>
851 <td class="parameter_name"><p>src_type</p></td>
852 <td class="parameter_description"><p>Source type.</p></td>
853 <td class="parameter_annotations"> </td>
854 </tr>
855 <tr>
856 <td class="parameter_name"><p>dest_type</p></td>
857 <td class="parameter_description"><p>Target type.</p></td>
858 <td class="parameter_annotations"> </td>
859 </tr>
860 </tbody>
861 </table></div>
862 </div>
863 <div class="refsect3">
864 <a name="g-value-type-transformable.returns"></a><h4>Returns</h4>
865 <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the transformation is possible, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</p>
866 </div>
867 </div>
868 <hr>
869 <div class="refsect2">
870 <a name="g-value-transform"></a><h3>g_value_transform ()</h3>
871 <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>
872 g_value_transform (<em class="parameter"><code>const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *src_value</code></em>,
873                    <em class="parameter"><code><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *dest_value</code></em>);</pre>
874 <p>Tries to cast the contents of <em class="parameter"><code>src_value</code></em>
875  into a type appropriate
876 to store in <em class="parameter"><code>dest_value</code></em>
877 , e.g. to transform a <a class="link" href="gobject-Type-Information.html#G-TYPE-INT:CAPS" title="G_TYPE_INT"><code class="literal">G_TYPE_INT</code></a> value
878 into a <a class="link" href="gobject-Type-Information.html#G-TYPE-FLOAT:CAPS" title="G_TYPE_FLOAT"><code class="literal">G_TYPE_FLOAT</code></a> value. Performing transformations between
879 value types might incur precision lossage. Especially
880 transformations into strings might reveal seemingly arbitrary
881 results and shouldn't be relied upon for production code (such
882 as rcfile value or object property serialization).</p>
883 <div class="refsect3">
884 <a name="g-value-transform.parameters"></a><h4>Parameters</h4>
885 <div class="informaltable"><table class="informaltable" width="100%" border="0">
886 <colgroup>
887 <col width="150px" class="parameters_name">
888 <col class="parameters_description">
889 <col width="200px" class="parameters_annotations">
890 </colgroup>
891 <tbody>
892 <tr>
893 <td class="parameter_name"><p>src_value</p></td>
894 <td class="parameter_description"><p>Source value.</p></td>
895 <td class="parameter_annotations"> </td>
896 </tr>
897 <tr>
898 <td class="parameter_name"><p>dest_value</p></td>
899 <td class="parameter_description"><p>Target value.</p></td>
900 <td class="parameter_annotations"> </td>
901 </tr>
902 </tbody>
903 </table></div>
904 </div>
905 <div class="refsect3">
906 <a name="g-value-transform.returns"></a><h4>Returns</h4>
907 <p> Whether a transformation rule was found and could be applied.
908 Upon failing transformations, <em class="parameter"><code>dest_value</code></em>
909 is left untouched.</p>
910 </div>
911 </div>
912 <hr>
913 <div class="refsect2">
914 <a name="GValueTransform"></a><h3>GValueTransform ()</h3>
915 <pre class="programlisting"><span class="returnvalue">void</span>
916 <span class="c_punctuation">(</span>*GValueTransform<span class="c_punctuation">)</span> (<em class="parameter"><code>const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *src_value</code></em>,
917                     <em class="parameter"><code><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *dest_value</code></em>);</pre>
918 <p>The type of value transformation functions which can be registered with
919 <a class="link" href="gobject-Generic-values.html#g-value-register-transform-func" title="g_value_register_transform_func ()"><code class="function">g_value_register_transform_func()</code></a>.</p>
920 <div class="refsect3">
921 <a name="GValueTransform.parameters"></a><h4>Parameters</h4>
922 <div class="informaltable"><table class="informaltable" width="100%" border="0">
923 <colgroup>
924 <col width="150px" class="parameters_name">
925 <col class="parameters_description">
926 <col width="200px" class="parameters_annotations">
927 </colgroup>
928 <tbody>
929 <tr>
930 <td class="parameter_name"><p>src_value</p></td>
931 <td class="parameter_description"><p>Source value.</p></td>
932 <td class="parameter_annotations"> </td>
933 </tr>
934 <tr>
935 <td class="parameter_name"><p>dest_value</p></td>
936 <td class="parameter_description"><p>Target value.</p></td>
937 <td class="parameter_annotations"> </td>
938 </tr>
939 </tbody>
940 </table></div>
941 </div>
942 </div>
943 <hr>
944 <div class="refsect2">
945 <a name="g-value-register-transform-func"></a><h3>g_value_register_transform_func ()</h3>
946 <pre class="programlisting"><span class="returnvalue">void</span>
947 g_value_register_transform_func (<em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> src_type</code></em>,
948                                  <em class="parameter"><code><a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> dest_type</code></em>,
949                                  <em class="parameter"><code><a class="link" href="gobject-Generic-values.html#GValueTransform" title="GValueTransform ()"><span class="type">GValueTransform</span></a> transform_func</code></em>);</pre>
950 <p>Registers a value transformation function for use in <a class="link" href="gobject-Generic-values.html#g-value-transform" title="g_value_transform ()"><code class="function">g_value_transform()</code></a>.
951 A previously registered transformation function for <em class="parameter"><code>src_type</code></em>
952  and <em class="parameter"><code>dest_type</code></em>
953
954 will be replaced.</p>
955 <p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p>
956 <div class="refsect3">
957 <a name="g-value-register-transform-func.parameters"></a><h4>Parameters</h4>
958 <div class="informaltable"><table class="informaltable" width="100%" border="0">
959 <colgroup>
960 <col width="150px" class="parameters_name">
961 <col class="parameters_description">
962 <col width="200px" class="parameters_annotations">
963 </colgroup>
964 <tbody>
965 <tr>
966 <td class="parameter_name"><p>src_type</p></td>
967 <td class="parameter_description"><p>Source type.</p></td>
968 <td class="parameter_annotations"> </td>
969 </tr>
970 <tr>
971 <td class="parameter_name"><p>dest_type</p></td>
972 <td class="parameter_description"><p>Target type.</p></td>
973 <td class="parameter_annotations"> </td>
974 </tr>
975 <tr>
976 <td class="parameter_name"><p>transform_func</p></td>
977 <td class="parameter_description"><p>a function which transforms values of type <em class="parameter"><code>src_type</code></em>
978 into value of type <em class="parameter"><code>dest_type</code></em>
979 </p></td>
980 <td class="parameter_annotations"> </td>
981 </tr>
982 </tbody>
983 </table></div>
984 </div>
985 </div>
986 <hr>
987 <div class="refsect2">
988 <a name="g-strdup-value-contents"></a><h3>g_strdup_value_contents ()</h3>
989 <pre class="programlisting"><a href="../glib-Basic-Types.html#gchar"><span class="returnvalue">gchar</span></a> *
990 g_strdup_value_contents (<em class="parameter"><code>const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> *value</code></em>);</pre>
991 <p>Return a newly allocated string, which describes the contents of a
992 <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>.  The main purpose of this function is to describe <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>
993 contents for debugging output, the way in which the contents are
994 described may change between different GLib versions.</p>
995 <div class="refsect3">
996 <a name="g-strdup-value-contents.parameters"></a><h4>Parameters</h4>
997 <div class="informaltable"><table class="informaltable" width="100%" border="0">
998 <colgroup>
999 <col width="150px" class="parameters_name">
1000 <col class="parameters_description">
1001 <col width="200px" class="parameters_annotations">
1002 </colgroup>
1003 <tbody><tr>
1004 <td class="parameter_name"><p>value</p></td>
1005 <td class="parameter_description"><p><a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> which contents are to be described.</p></td>
1006 <td class="parameter_annotations"> </td>
1007 </tr></tbody>
1008 </table></div>
1009 </div>
1010 <div class="refsect3">
1011 <a name="g-strdup-value-contents.returns"></a><h4>Returns</h4>
1012 <p> Newly allocated string.</p>
1013 </div>
1014 </div>
1015 </div>
1016 <div class="refsect1">
1017 <a name="gobject-Generic-values.other_details"></a><h2>Types and Values</h2>
1018 <div class="refsect2">
1019 <a name="G-VALUE-INIT:CAPS"></a><h3>G_VALUE_INIT</h3>
1020 <pre class="programlisting">#define G_VALUE_INIT  { 0, { { 0 } } }
1021 </pre>
1022 <p>A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> must be initialized before it can be used. This macro can
1023 be used as initializer instead of an explicit <code class="literal">{ 0 }</code> when declaring
1024 a variable, but it cannot be assigned to a variable.</p>
1025 <div class="informalexample">
1026   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
1027     <tbody>
1028       <tr>
1029         <td class="listing_lines" align="right"><pre>1</pre></td>
1030         <td class="listing_code"><pre class="programlisting">GValue value <span class="gtkdoc opt">=</span> G_VALUE_INIT<span class="gtkdoc opt">;</span></pre></td>
1031       </tr>
1032     </tbody>
1033   </table>
1034 </div>
1035
1036 <p></p>
1037 <p class="since">Since: <a class="link" href="api-index-2-30.html#api-index-2.30">2.30</a></p>
1038 </div>
1039 <hr>
1040 <div class="refsect2">
1041 <a name="GValue"></a><h3>GValue</h3>
1042 <pre class="programlisting">typedef struct {
1043 } GValue;
1044 </pre>
1045 <p>An opaque structure used to hold different types of values.
1046 The data within the structure has protected scope: it is accessible only
1047 to functions within a <a class="link" href="gobject-Type-Information.html#GTypeValueTable" title="struct GTypeValueTable"><span class="type">GTypeValueTable</span></a> structure, or implementations of
1048 the g_value_*() API. That is, code portions which implement new fundamental
1049 types.
1050 <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> users cannot make any assumptions about how data is stored
1051 within the 2 element <em class="parameter"><code>data</code></em>
1052  union, and the <em class="parameter"><code>g_type</code></em>
1053  member should
1054 only be accessed through the <a class="link" href="gobject-Generic-values.html#G-VALUE-TYPE:CAPS" title="G_VALUE_TYPE()"><code class="function">G_VALUE_TYPE()</code></a> macro.</p>
1055 </div>
1056 <hr>
1057 <div class="refsect2">
1058 <a name="G-TYPE-VALUE:CAPS"></a><h3>G_TYPE_VALUE</h3>
1059 <pre class="programlisting">#define G_TYPE_VALUE (g_value_get_type ())
1060 </pre>
1061 <p>The type ID of the "GValue" type which is a boxed type,
1062 used to pass around pointers to GValues.</p>
1063 </div>
1064 <hr>
1065 <div class="refsect2">
1066 <a name="G-TYPE-VALUE-ARRAY:CAPS"></a><h3>G_TYPE_VALUE_ARRAY</h3>
1067 <pre class="programlisting">#define G_TYPE_VALUE_ARRAY (g_value_array_get_type ())
1068 </pre>
1069 <div class="warning">
1070 <p><code class="literal">G_TYPE_VALUE_ARRAY</code> has been deprecated since version 2.32 and should not be used in newly-written code.</p>
1071 <p>Use <a href="../glib-Arrays.html#GArray"><span class="type">GArray</span></a> instead of <a class="link" href="gobject-Value-arrays.html#GValueArray" title="struct GValueArray"><span class="type">GValueArray</span></a></p>
1072 </div>
1073 <p>The type ID of the "GValueArray" type which is a boxed type,
1074 used to pass around pointers to GValueArrays.</p>
1075 </div>
1076 </div>
1077 <div class="refsect1">
1078 <a name="gobject-Generic-values.see-also"></a><h2>See Also</h2>
1079 <p>The fundamental types which all support <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a>
1080     operations and thus can be used as a type initializer for
1081     <a class="link" href="gobject-Generic-values.html#g-value-init" title="g_value_init ()"><code class="function">g_value_init()</code></a> are defined by a separate interface.  See the
1082     <a class="link" href="gobject-Standard-Parameter-and-Value-Types.html" title="Parameters and Values">standard values API</a>
1083     for details</p>
1084 </div>
1085 </div>
1086 <div class="footer">
1087 <hr>Generated by GTK-Doc V1.25.1</div>
1088 </body>
1089 </html>