46
48
<th width="100%" align="center">GObject Reference Manual</th>
47
49
<td><a accesskey="n" href="gobject-Standard-Parameter-and-Value-Types.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
49
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2886696" class="shortcut">Top</a>
51
<a href="#id2887156" class="shortcut">Description</a></nobr></td></tr>
51
<tr><td colspan="5" class="shortcuts">
52
<a href="#gobject-Generic-values.synopsis" class="shortcut">Top</a>
54
<a href="#gobject-Generic-values.description" class="shortcut">Description</a>
53
57
<div class="refentry" lang="en">
54
58
<a name="gobject-Generic-values"></a><div class="titlepage"></div>
55
59
<div class="refnamediv"><table width="100%"><tr>
58
<a name="id2886696"></a><span class="refentrytitle">Generic Values</span>
60
<p>Generic Values — A polymorphic type that can hold values of any other type</p>
61
<h2><span class="refentrytitle"><a name="gobject-Generic-values.top_of_page"></a>Generic values</span></h2>
62
<p>Generic values — A polymorphic type that can hold values of any
62
65
<td valign="top" align="right"></td>
63
66
</tr></table></div>
64
67
<div class="refsynopsisdiv">
68
<a name="gobject-Generic-values.synopsis"></a><h2>Synopsis</h2>
66
69
<pre class="synopsis">
68
71
#include <glib-object.h>
71
#define <a class="link" href="gobject-Generic-values.html#G-VALUE-HOLDS:CAPS">G_VALUE_HOLDS</a> (value,type)
72
#define <a class="link" href="gobject-Generic-values.html#G-VALUE-TYPE:CAPS">G_VALUE_TYPE</a> (value)
73
#define <a class="link" href="gobject-Generic-values.html#G-VALUE-TYPE-NAME:CAPS">G_VALUE_TYPE_NAME</a> (value)
74
#define <a class="link" href="gobject-Generic-values.html#G-TYPE-IS-VALUE:CAPS">G_TYPE_IS_VALUE</a> (type)
75
#define <a class="link" href="gobject-Generic-values.html#G-TYPE-IS-VALUE-ABSTRACT:CAPS">G_TYPE_IS_VALUE_ABSTRACT</a> (type)
76
#define <a class="link" href="gobject-Generic-values.html#G-IS-VALUE:CAPS">G_IS_VALUE</a> (value)
77
<a class="link" href="gobject-Generic-values.html#GValue">GValue</a>;
78
#define <a class="link" href="gobject-Generic-values.html#G-TYPE-VALUE:CAPS">G_TYPE_VALUE</a>
79
#define <a class="link" href="gobject-Generic-values.html#G-TYPE-VALUE-ARRAY:CAPS">G_TYPE_VALUE_ARRAY</a>
80
<a class="link" href="gobject-Generic-values.html#GValue">GValue</a>* <a class="link" href="gobject-Generic-values.html#g-value-init">g_value_init</a> (<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value,
81
<a class="link" href="gobject-Type-Information.html#GType">GType</a> g_type);
82
void <a class="link" href="gobject-Generic-values.html#g-value-copy">g_value_copy</a> (const <a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *src_value,
83
<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *dest_value);
84
<a class="link" href="gobject-Generic-values.html#GValue">GValue</a>* <a class="link" href="gobject-Generic-values.html#g-value-reset">g_value_reset</a> (<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value);
85
void <a class="link" href="gobject-Generic-values.html#g-value-unset">g_value_unset</a> (<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value);
86
void <a class="link" href="gobject-Generic-values.html#g-value-set-instance">g_value_set_instance</a> (<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value,
73
#define <a class="link" href="gobject-Generic-values.html#G-VALUE-HOLDS--CAPS" title="G_VALUE_HOLDS()">G_VALUE_HOLDS</a> (value,type)
74
#define <a class="link" href="gobject-Generic-values.html#G-VALUE-TYPE--CAPS" title="G_VALUE_TYPE()">G_VALUE_TYPE</a> (value)
75
#define <a class="link" href="gobject-Generic-values.html#G-VALUE-TYPE-NAME--CAPS" title="G_VALUE_TYPE_NAME()">G_VALUE_TYPE_NAME</a> (value)
76
#define <a class="link" href="gobject-Generic-values.html#G-TYPE-IS-VALUE--CAPS" title="G_TYPE_IS_VALUE()">G_TYPE_IS_VALUE</a> (type)
77
#define <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> (type)
78
#define <a class="link" href="gobject-Generic-values.html#G-IS-VALUE--CAPS" title="G_IS_VALUE()">G_IS_VALUE</a> (value)
79
<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a>;
80
#define <a class="link" href="gobject-Generic-values.html#G-TYPE-VALUE--CAPS" title="G_TYPE_VALUE">G_TYPE_VALUE</a>
81
#define <a class="link" href="gobject-Generic-values.html#G-TYPE-VALUE-ARRAY--CAPS" title="G_TYPE_VALUE_ARRAY">G_TYPE_VALUE_ARRAY</a>
82
<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a>* <a class="link" href="gobject-Generic-values.html#g-value-init" title="g_value_init ()">g_value_init</a> (<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value,
83
<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> g_type);
84
void <a class="link" href="gobject-Generic-values.html#g-value-copy" title="g_value_copy ()">g_value_copy</a> (const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *src_value,
85
<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *dest_value);
86
<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a>* <a class="link" href="gobject-Generic-values.html#g-value-reset" title="g_value_reset ()">g_value_reset</a> (<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value);
87
void <a class="link" href="gobject-Generic-values.html#g-value-unset" title="g_value_unset ()">g_value_unset</a> (<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value);
88
void <a class="link" href="gobject-Generic-values.html#g-value-set-instance" title="g_value_set_instance ()">g_value_set_instance</a> (<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value,
88
90
href="./../glib/glib/glib-Basic-Types.html#gpointer"
89
91
>gpointer</a> instance);
91
93
href="./../glib/glib/glib-Basic-Types.html#gboolean"
92
>gboolean</a> <a class="link" href="gobject-Generic-values.html#g-value-fits-pointer">g_value_fits_pointer</a> (const <a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value);
94
>gboolean</a> <a class="link" href="gobject-Generic-values.html#g-value-fits-pointer" title="g_value_fits_pointer ()">g_value_fits_pointer</a> (const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value);
94
96
href="./../glib/glib/glib-Basic-Types.html#gpointer"
95
>gpointer</a> <a class="link" href="gobject-Generic-values.html#g-value-peek-pointer">g_value_peek_pointer</a> (const <a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value);
97
href="./../glib/glib/glib-Basic-Types.html#gboolean"
98
>gboolean</a> <a class="link" href="gobject-Generic-values.html#g-value-type-compatible">g_value_type_compatible</a> (<a class="link" href="gobject-Type-Information.html#GType">GType</a> src_type,
99
<a class="link" href="gobject-Type-Information.html#GType">GType</a> dest_type);
101
href="./../glib/glib/glib-Basic-Types.html#gboolean"
102
>gboolean</a> <a class="link" href="gobject-Generic-values.html#g-value-type-transformable">g_value_type_transformable</a> (<a class="link" href="gobject-Type-Information.html#GType">GType</a> src_type,
103
<a class="link" href="gobject-Type-Information.html#GType">GType</a> dest_type);
105
href="./../glib/glib/glib-Basic-Types.html#gboolean"
106
>gboolean</a> <a class="link" href="gobject-Generic-values.html#g-value-transform">g_value_transform</a> (const <a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *src_value,
107
<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *dest_value);
108
void (<a class="link" href="gobject-Generic-values.html#GValueTransform">*GValueTransform</a>) (const <a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *src_value,
109
<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *dest_value);
110
void <a class="link" href="gobject-Generic-values.html#g-value-register-transform-func">g_value_register_transform_func</a> (<a class="link" href="gobject-Type-Information.html#GType">GType</a> src_type,
111
<a class="link" href="gobject-Type-Information.html#GType">GType</a> dest_type,
112
<a class="link" href="gobject-Generic-values.html#GValueTransform">GValueTransform</a> transform_func);
97
>gpointer</a> <a class="link" href="gobject-Generic-values.html#g-value-peek-pointer" title="g_value_peek_pointer ()">g_value_peek_pointer</a> (const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value);
99
href="./../glib/glib/glib-Basic-Types.html#gboolean"
100
>gboolean</a> <a class="link" href="gobject-Generic-values.html#g-value-type-compatible" title="g_value_type_compatible ()">g_value_type_compatible</a> (<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> src_type,
101
<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> dest_type);
103
href="./../glib/glib/glib-Basic-Types.html#gboolean"
104
>gboolean</a> <a class="link" href="gobject-Generic-values.html#g-value-type-transformable" title="g_value_type_transformable ()">g_value_type_transformable</a> (<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> src_type,
105
<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> dest_type);
107
href="./../glib/glib/glib-Basic-Types.html#gboolean"
108
>gboolean</a> <a class="link" href="gobject-Generic-values.html#g-value-transform" title="g_value_transform ()">g_value_transform</a> (const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *src_value,
109
<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *dest_value);
110
void (<a class="link" href="gobject-Generic-values.html#GValueTransform" title="GValueTransform ()">*GValueTransform</a>) (const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *src_value,
111
<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *dest_value);
112
void <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> (<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> src_type,
113
<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> dest_type,
114
<a class="link" href="gobject-Generic-values.html#GValueTransform" title="GValueTransform ()">GValueTransform</a> transform_func);
114
116
href="./../glib/glib/glib-Basic-Types.html#gchar"
115
>gchar</a>* <a class="link" href="gobject-Generic-values.html#g-strdup-value-contents">g_strdup_value_contents</a> (const <a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value);
117
>gchar</a>* <a class="link" href="gobject-Generic-values.html#g-strdup-value-contents" title="g_strdup_value_contents ()">g_strdup_value_contents</a> (const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value);
119
120
<div class="refsect1" lang="en">
120
<a name="id2887156"></a><h2>Description</h2>
121
<a name="gobject-Generic-values.description"></a><h2>Description</h2>
122
The <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure is basically a variable container that consists
123
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
123
124
of a type identifier and a specific value of that type.
124
The type identifier within a <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure always determines the
125
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
125
126
type of the associated value.
126
To create a undefined <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure, simply create a zero-filled
127
<a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure. To initialize the <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a>, use the <a class="link" href="gobject-Generic-values.html#g-value-init"><code class="function">g_value_init()</code></a>
128
function. A <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> cannot be used until it is initialized.
127
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
128
<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>
129
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.
129
130
The basic type operations (such as freeing and copying) are determined
130
by the <a class="link" href="gobject-Type-Information.html#GTypeValueTable"><span class="type">GTypeValueTable</span></a> associated with the type ID stored in the <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a>.
131
Other <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> operations (such as converting values between types) are
131
by the <a class="link" href="gobject-Type-Information.html#GTypeValueTable" title="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>.
132
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
132
133
provided by this interface.
136
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
141
<div class="informalexample"><pre class="programlisting">
142
#include <glib-object.h>
145
int2string (const GValue *src_value,
148
if (g_value_get_int (src_value) == 42)
149
g_value_set_static_string (dest_value, "An important number");
151
g_value_set_static_string (dest_value, "What's that?");
158
/* GValues must start zero-filled */
161
const gchar *message;
165
/* The GValue starts empty */
166
g_assert (!G_VALUE_HOLDS_STRING (&a));
168
/* Put a string in it */
169
g_value_init (&a, G_TYPE_STRING);
170
g_assert (G_VALUE_HOLDS_STRING (&a));
171
g_value_set_static_string (&a, "Hello, world!");
172
g_printf ("%s\n", g_value_get_string (&a));
174
/* Reset it to its pristine state */
175
g_value_unset (&a);
177
/* It can then be reused for another type */
178
g_value_init (&a, G_TYPE_INT);
179
g_value_set_int (&a, 42);
181
/* Attempt to transform it into a GValue of type STRING */
182
g_value_init (&b, G_TYPE_STRING);
184
/* An INT is transformable to a STRING */
185
g_assert (g_value_type_transformable (G_TYPE_INT, G_TYPE_STRING));
187
g_value_transform (&a, &b);
188
g_printf ("%s\n", g_value_get_string (&b));
190
/* Attempt to transform it again using a custom transform function */
191
g_value_register_transform_func (G_TYPE_INT, G_TYPE_STRING, int2string);
192
g_value_transform (&a, &b);
193
g_printf ("%s\n", g_value_get_string (&b));
135
200
<div class="refsect1" lang="en">
136
<a name="id2887262"></a><h2>Details</h2>
201
<a name="gobject-Generic-values.details"></a><h2>Details</h2>
137
202
<div class="refsect2" lang="en">
138
<a name="id2887272"></a><h3>
139
<a name="G-VALUE-HOLDS:CAPS"></a>G_VALUE_HOLDS()</h3>
140
<a class="indexterm" name="id2887285"></a><pre class="programlisting">#define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type)))
203
<a name="G-VALUE-HOLDS--CAPS"></a><h3>G_VALUE_HOLDS()</h3>
204
<pre class="programlisting">#define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type)))
144
href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"
145
><code class="literal">TRUE</code></a> if <em class="parameter"><code>value</code></em> holds (or contains) a value of <em class="parameter"><code>type</code></em>.
207
Checks if <em class="parameter"><code>value</code></em> holds (or contains) a value of <em class="parameter"><code>type</code></em>.
146
208
This macro will also check for <em class="parameter"><code>value</code></em> != <a
147
href="./../glib/glib/glib-Standard-Macros.html#NULL:CAPS"
209
href="./../glib/glib/glib-Standard-Macros.html#NULL--CAPS"
148
210
><code class="literal">NULL</code></a> and issue a
149
warning if the check fails.
211
warning if the check fails.</p>
151
214
<div class="variablelist"><table border="0">
152
215
<col align="left" valign="top">
155
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
156
<td>A <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure.
218
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
219
<td> A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.
160
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
161
<td>A <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> value.
223
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
224
<td> A <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> value.
170
231
<div class="refsect2" lang="en">
171
<a name="id2887388"></a><h3>
172
<a name="G-VALUE-TYPE:CAPS"></a>G_VALUE_TYPE()</h3>
173
<a class="indexterm" name="id2887401"></a><pre class="programlisting">#define G_VALUE_TYPE(value) (((GValue*) (value))->g_type)
176
Returns the type identifier of <em class="parameter"><code>value</code></em>.
178
<div class="variablelist"><table border="0">
179
<col align="left" valign="top">
181
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
182
<td>A <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure.
190
<div class="refsect2" lang="en">
191
<a name="id2887450"></a><h3>
192
<a name="G-VALUE-TYPE-NAME:CAPS"></a>G_VALUE_TYPE_NAME()</h3>
193
<a class="indexterm" name="id2887464"></a><pre class="programlisting">#define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value)))
196
Returns the type name of <em class="parameter"><code>value</code></em>.
198
<div class="variablelist"><table border="0">
199
<col align="left" valign="top">
201
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
202
<td>A <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure.
210
<div class="refsect2" lang="en">
211
<a name="id2887512"></a><h3>
212
<a name="G-TYPE-IS-VALUE:CAPS"></a>G_TYPE_IS_VALUE()</h3>
213
<a class="indexterm" name="id2887525"></a><pre class="programlisting">#define G_TYPE_IS_VALUE(type) (g_type_check_is_value_type (type))
216
Return whether the passed in type ID can be used for <a class="link" href="gobject-Generic-values.html#g-value-init"><code class="function">g_value_init()</code></a>.
232
<a name="G-VALUE-TYPE--CAPS"></a><h3>G_VALUE_TYPE()</h3>
233
<pre class="programlisting">#define G_VALUE_TYPE(value) (((GValue*) (value))->g_type)
236
Get the type identifier of <em class="parameter"><code>value</code></em>.</p>
239
<div class="variablelist"><table border="0">
240
<col align="left" valign="top">
242
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
243
<td> A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.
249
<div class="refsect2" lang="en">
250
<a name="G-VALUE-TYPE-NAME--CAPS"></a><h3>G_VALUE_TYPE_NAME()</h3>
251
<pre class="programlisting">#define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value)))
254
Gets the the type name of <em class="parameter"><code>value</code></em>.</p>
257
<div class="variablelist"><table border="0">
258
<col align="left" valign="top">
260
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
261
<td> A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.
267
<div class="refsect2" lang="en">
268
<a name="G-TYPE-IS-VALUE--CAPS"></a><h3>G_TYPE_IS_VALUE()</h3>
269
<pre class="programlisting">#define G_TYPE_IS_VALUE(type) (g_type_check_is_value_type (type))
272
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>.
217
273
That is, this macro checks whether this type provides an implementation
218
of the <a class="link" href="gobject-Type-Information.html#GTypeValueTable"><span class="type">GTypeValueTable</span></a> functions required for a type to create a <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> of.
220
<div class="variablelist"><table border="0">
221
<col align="left" valign="top">
224
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
225
<td> A <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> value.
229
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
230
<td>Whether <em class="parameter"><code>type</code></em> is suitable as a <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> type.
239
<div class="refsect2" lang="en">
240
<a name="id2887622"></a><h3>
241
<a name="G-TYPE-IS-VALUE-ABSTRACT:CAPS"></a>G_TYPE_IS_VALUE_ABSTRACT()</h3>
242
<a class="indexterm" name="id2887635"></a><pre class="programlisting">#define G_TYPE_IS_VALUE_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_VALUE_ABSTRACT))
246
href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"
247
><code class="literal">TRUE</code></a> if <em class="parameter"><code>type</code></em> is an abstract value type. An abstract value type
248
introduces a value table, but can't be used for <a class="link" href="gobject-Generic-values.html#g-value-init"><code class="function">g_value_init()</code></a> and is normally
249
used as an abstract base type for derived value types.
251
<div class="variablelist"><table border="0">
252
<col align="left" valign="top">
254
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
255
<td>A <a class="link" href="gobject-Type-Information.html#GType"><span class="type">GType</span></a> value.
263
<div class="refsect2" lang="en">
264
<a name="id2887707"></a><h3>
265
<a name="G-IS-VALUE:CAPS"></a>G_IS_VALUE()</h3>
266
<a class="indexterm" name="id2887720"></a><pre class="programlisting">#define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value))
270
href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"
271
><code class="literal">TRUE</code></a> if <em class="parameter"><code>value</code></em> is a valid and initialized <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure.
273
<div class="variablelist"><table border="0">
274
<col align="left" valign="top">
276
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
277
<td>A <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure.
285
<div class="refsect2" lang="en">
286
<a name="id2887786"></a><h3>
287
<a name="GValue"></a>GValue</h3>
288
<a class="indexterm" name="id2887798"></a><pre class="programlisting">typedef struct {
274
of the <a class="link" href="gobject-Type-Information.html#GTypeValueTable" title="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>
277
<div class="variablelist"><table border="0">
278
<col align="left" valign="top">
280
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
281
<td> A <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> value.
287
<div class="refsect2" lang="en">
288
<a name="G-TYPE-IS-VALUE-ABSTRACT--CAPS"></a><h3>G_TYPE_IS_VALUE_ABSTRACT()</h3>
289
<pre class="programlisting">#define G_TYPE_IS_VALUE_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_VALUE_ABSTRACT))
292
Checks if <em class="parameter"><code>type</code></em> is an abstract value type. An abstract value type introduces
293
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
294
an abstract base type for derived value types.</p>
297
<div class="variablelist"><table border="0">
298
<col align="left" valign="top">
300
<td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td>
301
<td> A <a class="link" href="gobject-Type-Information.html#GType" title="GType"><span class="type">GType</span></a> value.
307
<div class="refsect2" lang="en">
308
<a name="G-IS-VALUE--CAPS"></a><h3>G_IS_VALUE()</h3>
309
<pre class="programlisting">#define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value))
312
Checks if <em class="parameter"><code>value</code></em> is a valid and initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.</p>
315
<div class="variablelist"><table border="0">
316
<col align="left" valign="top">
318
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
319
<td> A <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.
325
<div class="refsect2" lang="en">
326
<a name="GValue"></a><h3>GValue</h3>
327
<pre class="programlisting">typedef struct {
292
331
An opaque structure used to hold different types of values.
293
332
The data within the structure has protected scope: it is accessible only
294
to functions within a <a class="link" href="gobject-Type-Information.html#GTypeValueTable"><span class="type">GTypeValueTable</span></a> structure, or implementations of
333
to functions within a <a class="link" href="gobject-Type-Information.html#GTypeValueTable" title="GTypeValueTable"><span class="type">GTypeValueTable</span></a> structure, or implementations of
295
334
the g_value_*() API. That is, code portions which implement new fundamental
297
<a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> users can not make any assumptions about how data is stored
336
<a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> users can not make any assumptions about how data is stored
298
337
within the 2 element <em class="parameter"><code>data</code></em> union, and the <em class="parameter"><code>g_type</code></em> member should
299
only be accessed through the <a class="link" href="gobject-Generic-values.html#G-VALUE-TYPE:CAPS"><code class="function">G_VALUE_TYPE()</code></a> macro.
303
<div class="refsect2" lang="en">
304
<a name="id2887859"></a><h3>
305
<a name="G-TYPE-VALUE:CAPS"></a>G_TYPE_VALUE</h3>
306
<a class="indexterm" name="id2887872"></a><pre class="programlisting">#define G_TYPE_VALUE (g_value_get_type ())
309
Returns the type ID of the "GValue" type which is a boxed type,
310
used to pass around pointers to GValues.
314
<div class="refsect2" lang="en">
315
<a name="id2887889"></a><h3>
316
<a name="G-TYPE-VALUE-ARRAY:CAPS"></a>G_TYPE_VALUE_ARRAY</h3>
317
<a class="indexterm" name="id2887903"></a><pre class="programlisting">#define G_TYPE_VALUE_ARRAY (g_value_array_get_type ())
320
Returns the type ID of the "GValueArray" type which is a boxed type,
321
used to pass around pointers to GValueArrays.
325
<div class="refsect2" lang="en">
326
<a name="id2887921"></a><h3>
327
<a name="g-value-init"></a>g_value_init ()</h3>
328
<a class="indexterm" name="id2887933"></a><pre class="programlisting"><a class="link" href="gobject-Generic-values.html#GValue">GValue</a>* g_value_init (<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value,
329
<a class="link" href="gobject-Type-Information.html#GType">GType</a> g_type);</pre>
331
Initializes <em class="parameter"><code>value</code></em> with the default value of <em class="parameter"><code>type</code></em>.
333
<div class="variablelist"><table border="0">
334
<col align="left" valign="top">
337
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
338
<td>A zero-filled (uninitialized) <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure.
342
<td><p><span class="term"><em class="parameter"><code>g_type</code></em> :</span></p></td>
343
<td>Type the <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> should hold values of.
347
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
348
<td>the <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure that has been passed in
357
<div class="refsect2" lang="en">
358
<a name="id2888049"></a><h3>
359
<a name="g-value-copy"></a>g_value_copy ()</h3>
360
<a class="indexterm" name="id2888062"></a><pre class="programlisting">void g_value_copy (const <a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *src_value,
361
<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *dest_value);</pre>
363
Copies the value of <em class="parameter"><code>src_value</code></em> into <em class="parameter"><code>dest_value</code></em>.
365
<div class="variablelist"><table border="0">
366
<col align="left" valign="top">
369
<td><p><span class="term"><em class="parameter"><code>src_value</code></em> :</span></p></td>
370
<td>An initialized <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure.
374
<td><p><span class="term"><em class="parameter"><code>dest_value</code></em> :</span></p></td>
375
<td>An initialized <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure of the same type as <em class="parameter"><code>src_value</code></em>.
384
<div class="refsect2" lang="en">
385
<a name="id2888165"></a><h3>
386
<a name="g-value-reset"></a>g_value_reset ()</h3>
387
<a class="indexterm" name="id2888178"></a><pre class="programlisting"><a class="link" href="gobject-Generic-values.html#GValue">GValue</a>* g_value_reset (<a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value);</pre>
338
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>
343
<div class="refsect2" lang="en">
344
<a name="G-TYPE-VALUE--CAPS"></a><h3>G_TYPE_VALUE</h3>
345
<pre class="programlisting">#define G_TYPE_VALUE (g_value_get_type ())
348
The type ID of the "GValue" type which is a boxed type,
349
used to pass around pointers to GValues.</p>
354
<div class="refsect2" lang="en">
355
<a name="G-TYPE-VALUE-ARRAY--CAPS"></a><h3>G_TYPE_VALUE_ARRAY</h3>
356
<pre class="programlisting">#define G_TYPE_VALUE_ARRAY (g_value_array_get_type ())
359
The type ID of the "GValueArray" type which is a boxed type,
360
used to pass around pointers to GValueArrays.</p>
365
<div class="refsect2" lang="en">
366
<a name="g-value-init"></a><h3>g_value_init ()</h3>
367
<pre class="programlisting"><a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a>* g_value_init (<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value,
368
<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> g_type);</pre>
370
Initializes <em class="parameter"><code>value</code></em> with the default value of <em class="parameter"><code>type</code></em>.</p>
373
<div class="variablelist"><table border="0">
374
<col align="left" valign="top">
377
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
378
<td> A zero-filled (uninitialized) <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.
382
<td><p><span class="term"><em class="parameter"><code>g_type</code></em> :</span></p></td>
383
<td> Type the <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> should hold values of.
387
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
388
<td> the <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure that has been passed in
395
<div class="refsect2" lang="en">
396
<a name="g-value-copy"></a><h3>g_value_copy ()</h3>
397
<pre class="programlisting">void g_value_copy (const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *src_value,
398
<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *dest_value);</pre>
400
Copies the value of <em class="parameter"><code>src_value</code></em> into <em class="parameter"><code>dest_value</code></em>.</p>
403
<div class="variablelist"><table border="0">
404
<col align="left" valign="top">
407
<td><p><span class="term"><em class="parameter"><code>src_value</code></em> :</span></p></td>
408
<td> An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.
412
<td><p><span class="term"><em class="parameter"><code>dest_value</code></em> :</span></p></td>
413
<td> 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>.
420
<div class="refsect2" lang="en">
421
<a name="g-value-reset"></a><h3>g_value_reset ()</h3>
422
<pre class="programlisting"><a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a>* g_value_reset (<a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value);</pre>
389
424
Clears the current value in <em class="parameter"><code>value</code></em> and resets it to the default value
390
(as if the value had just been initialized).
425
(as if the value had just been initialized).</p>
392
428
<div class="variablelist"><table border="0">
393
429
<col align="left" valign="top">
396
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
397
<td>An initialized <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure.
432
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
433
<td> An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.
401
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
402
<td>the <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure that has been passed in
437
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
438
<td> the <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure that has been passed in
495
522
<div class="refsect2" lang="en">
496
<a name="id2888553"></a><h3>
497
<a name="g-value-peek-pointer"></a>g_value_peek_pointer ()</h3>
498
<a class="indexterm" name="id2888567"></a><pre class="programlisting"><a
523
<a name="g-value-peek-pointer"></a><h3>g_value_peek_pointer ()</h3>
524
<pre class="programlisting"><a
499
525
href="./../glib/glib/glib-Basic-Types.html#gpointer"
500
>gpointer</a> g_value_peek_pointer (const <a class="link" href="gobject-Generic-values.html#GValue">GValue</a> *value);</pre>
526
>gpointer</a> g_value_peek_pointer (const <a class="link" href="gobject-Generic-values.html#GValue" title="GValue">GValue</a> *value);</pre>
502
528
Return the value contents as pointer. This function asserts that
503
<a class="link" href="gobject-Generic-values.html#g-value-fits-pointer"><code class="function">g_value_fits_pointer()</code></a> returned <a
504
href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"
529
<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
530
href="./../glib/glib/glib-Standard-Macros.html#TRUE--CAPS"
505
531
><code class="literal">TRUE</code></a> for the passed in value.
506
This is an internal function introduced mainly for C marshallers.
532
This is an internal function introduced mainly for C marshallers.</p>
508
535
<div class="variablelist"><table border="0">
509
536
<col align="left" valign="top">
512
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
513
<td>An initialized <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> structure.
539
<td><p><span class="term"><em class="parameter"><code>value</code></em> :</span></p></td>
540
<td> An initialized <a class="link" href="gobject-Generic-values.html#GValue" title="GValue"><span class="type">GValue</span></a> structure.
517
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
520
href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"
544
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
546
href="./../glib/glib/glib-Standard-Macros.html#TRUE--CAPS"
521
547
><code class="literal">TRUE</code></a> if <em class="parameter"><code>value</code></em> will fit inside a pointer value.
530
<div class="refsect2" lang="en">
531
<a name="id2888671"></a><h3>
532
<a name="g-value-type-compatible"></a>g_value_type_compatible ()</h3>
533
<a class="indexterm" name="id2888684"></a><pre class="programlisting"><a
534
href="./../glib/glib/glib-Basic-Types.html#gboolean"
535
>gboolean</a> g_value_type_compatible (<a class="link" href="gobject-Type-Information.html#GType">GType</a> src_type,
536
<a class="link" href="gobject-Type-Information.html#GType">GType</a> dest_type);</pre>
538
Returns whether a <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> of type <em class="parameter"><code>src_type</code></em> can be copied into
539
a <a class="link" href="gobject-Generic-values.html#GValue"><span class="type">GValue</span></a> of type <em class="parameter"><code>dest_type</code></em>.
541
<div class="variablelist"><table border="0">
542
<col align="left" valign="top">
545
<td><p><span class="term"><em class="parameter"><code>src_type</code></em> :</span></p></td>
546
<td>source type to be copied.
550
<td><p><span class="term"><em class="parameter"><code>dest_type</code></em> :</span></p></td>
551
<td>destination type for copying.
555
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
558
href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"
559
><code class="literal">TRUE</code></a> if <a class="link" href="gobject-Generic-values.html#g-value-copy"><code class="function">g_value_copy()</code></a> is possible with <em class="parameter"><code>src_type</code></em> and <em class="parameter"><code>dest_type</code></em>.
568
<div class="refsect2" lang="en">
569
<a name="id2888824"></a><h3>
570
<a name="g-value-type-transformable"></a>g_value_type_transformable ()</h3>
571
<a class="indexterm" name="id2888838"></a><pre class="programlisting"><a
572
href="./../glib/glib/glib-Basic-Types.html#gboolean"
573
>gboolean</a> g_value_type_transformable (<a class="link" href="gobject-Type-Information.html#GType">GType</a> src_type,
574
<a class="link" href="gobject-Type-Information.html#GType">GType</a> dest_type);</pre>
576
Check whether <a class="link" href="gobject-Generic-values.html#g-value-transform"><code class="function">g_value_transform()</code></a> is able to transform values
577
of type <em class="parameter"><code>src_type</code></em> into values of type <em class="parameter"><code>dest_type</code></em>.
579
<div class="variablelist"><table border="0">
580
<col align="left" valign="top">
583
<td><p><span class="term"><em class="parameter"><code>src_type</code></em> :</span></p></td>
588
<td><p><span class="term"><em class="parameter"><code>dest_type</code></em> :</span></p></td>
593
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
596
href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"
554
<div class="refsect2" lang="en">
555
<a name="g-value-type-compatible"></a><h3>g_value_type_compatible ()</h3>
556
<pre class="programlisting"><a
557
href="./../glib/glib/glib-Basic-Types.html#gboolean"
558
>gboolean</a> g_value_type_compatible (<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> src_type,
559
<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> dest_type);</pre>
561
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> can be copied into
562
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>.</p>
565
<div class="variablelist"><table border="0">
566
<col align="left" valign="top">
569
<td><p><span class="term"><em class="parameter"><code>src_type</code></em> :</span></p></td>
570
<td> source type to be copied.
574
<td><p><span class="term"><em class="parameter"><code>dest_type</code></em> :</span></p></td>
575
<td> destination type for copying.
579
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
581
href="./../glib/glib/glib-Standard-Macros.html#TRUE--CAPS"
582
><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> and <em class="parameter"><code>dest_type</code></em>.
589
<div class="refsect2" lang="en">
590
<a name="g-value-type-transformable"></a><h3>g_value_type_transformable ()</h3>
591
<pre class="programlisting"><a
592
href="./../glib/glib/glib-Basic-Types.html#gboolean"
593
>gboolean</a> g_value_type_transformable (<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> src_type,
594
<a class="link" href="gobject-Type-Information.html#GType" title="GType">GType</a> dest_type);</pre>
596
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
597
of type <em class="parameter"><code>src_type</code></em> into values of type <em class="parameter"><code>dest_type</code></em>.</p>
600
<div class="variablelist"><table border="0">
601
<col align="left" valign="top">
604
<td><p><span class="term"><em class="parameter"><code>src_type</code></em> :</span></p></td>
609
<td><p><span class="term"><em class="parameter"><code>dest_type</code></em> :</span></p></td>
614
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
616
href="./../glib/glib/glib-Standard-Macros.html#TRUE--CAPS"
597
617
><code class="literal">TRUE</code></a> if the transformation is possible, <a
598
href="./../glib/glib/glib-Standard-Macros.html#FALSE:CAPS"
618
href="./../glib/glib/glib-Standard-Macros.html#FALSE--CAPS"
599
619
><code class="literal">FALSE</code></a> otherwise.