1/* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 *
17 * gvaluetypes.h: GLib default values
18 */
19#ifndef __G_VALUETYPES_H__
20#define __G_VALUETYPES_H__
21
22#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
23#error "Only <glib-object.h> can be included directly."
24#endif
25
26#include <gobject/gvalue.h>
27
28G_BEGIN_DECLS
29
30/* --- type macros --- */
31/**
32 * G_VALUE_HOLDS_CHAR:
33 * @value: a valid #GValue structure
34 *
35 * Checks whether the given #GValue can hold values of type %G_TYPE_CHAR.
36 *
37 * Returns: %TRUE on success.
38 */
39#define G_VALUE_HOLDS_CHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR))
40/**
41 * G_VALUE_HOLDS_UCHAR:
42 * @value: a valid #GValue structure
43 *
44 * Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR.
45 *
46 * Returns: %TRUE on success.
47 */
48#define G_VALUE_HOLDS_UCHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR))
49/**
50 * G_VALUE_HOLDS_BOOLEAN:
51 * @value: a valid #GValue structure
52 *
53 * Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN.
54 *
55 * Returns: %TRUE on success.
56 */
57#define G_VALUE_HOLDS_BOOLEAN(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN))
58/**
59 * G_VALUE_HOLDS_INT:
60 * @value: a valid #GValue structure
61 *
62 * Checks whether the given #GValue can hold values of type %G_TYPE_INT.
63 *
64 * Returns: %TRUE on success.
65 */
66#define G_VALUE_HOLDS_INT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT))
67/**
68 * G_VALUE_HOLDS_UINT:
69 * @value: a valid #GValue structure
70 *
71 * Checks whether the given #GValue can hold values of type %G_TYPE_UINT.
72 *
73 * Returns: %TRUE on success.
74 */
75#define G_VALUE_HOLDS_UINT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT))
76/**
77 * G_VALUE_HOLDS_LONG:
78 * @value: a valid #GValue structure
79 *
80 * Checks whether the given #GValue can hold values of type %G_TYPE_LONG.
81 *
82 * Returns: %TRUE on success.
83 */
84#define G_VALUE_HOLDS_LONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG))
85/**
86 * G_VALUE_HOLDS_ULONG:
87 * @value: a valid #GValue structure
88 *
89 * Checks whether the given #GValue can hold values of type %G_TYPE_ULONG.
90 *
91 * Returns: %TRUE on success.
92 */
93#define G_VALUE_HOLDS_ULONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG))
94/**
95 * G_VALUE_HOLDS_INT64:
96 * @value: a valid #GValue structure
97 *
98 * Checks whether the given #GValue can hold values of type %G_TYPE_INT64.
99 *
100 * Returns: %TRUE on success.
101 */
102#define G_VALUE_HOLDS_INT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64))
103/**
104 * G_VALUE_HOLDS_UINT64:
105 * @value: a valid #GValue structure
106 *
107 * Checks whether the given #GValue can hold values of type %G_TYPE_UINT64.
108 *
109 * Returns: %TRUE on success.
110 */
111#define G_VALUE_HOLDS_UINT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64))
112/**
113 * G_VALUE_HOLDS_FLOAT:
114 * @value: a valid #GValue structure
115 *
116 * Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT.
117 *
118 * Returns: %TRUE on success.
119 */
120#define G_VALUE_HOLDS_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
121/**
122 * G_VALUE_HOLDS_DOUBLE:
123 * @value: a valid #GValue structure
124 *
125 * Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE.
126 *
127 * Returns: %TRUE on success.
128 */
129#define G_VALUE_HOLDS_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
130/**
131 * G_VALUE_HOLDS_STRING:
132 * @value: a valid #GValue structure
133 *
134 * Checks whether the given #GValue can hold values of type %G_TYPE_STRING.
135 *
136 * Returns: %TRUE on success.
137 */
138#define G_VALUE_HOLDS_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
139/**
140 * G_VALUE_IS_INTERNED_STRING:
141 * @value: a valid #GValue structure
142 *
143 * Checks whether @value contains a string which is canonical.
144 *
145 * Returns: %TRUE if the value contains a string in its canonical
146 * representation, as returned by g_intern_string(). See also
147 * g_value_set_interned_string().
148 *
149 * Since: 2.66
150 */
151#define G_VALUE_IS_INTERNED_STRING(value) (G_VALUE_HOLDS_STRING (value) && ((value)->data[1].v_uint & G_VALUE_INTERNED_STRING)) GLIB_AVAILABLE_MACRO_IN_2_66
152/**
153 * G_VALUE_HOLDS_POINTER:
154 * @value: a valid #GValue structure
155 *
156 * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER.
157 *
158 * Returns: %TRUE on success.
159 */
160#define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
161/**
162 * G_TYPE_GTYPE:
163 *
164 * The type for #GType.
165 */
166#define G_TYPE_GTYPE (g_gtype_get_type())
167/**
168 * G_VALUE_HOLDS_GTYPE:
169 * @value: a valid #GValue structure
170 *
171 * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE.
172 *
173 * Since: 2.12
174 * Returns: %TRUE on success.
175 */
176#define G_VALUE_HOLDS_GTYPE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE))
177/**
178 * G_VALUE_HOLDS_VARIANT:
179 * @value: a valid #GValue structure
180 *
181 * Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT.
182 *
183 * Returns: %TRUE on success.
184 *
185 * Since: 2.26
186 */
187#define G_VALUE_HOLDS_VARIANT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT))
188
189
190/* --- prototypes --- */
191GLIB_DEPRECATED_IN_2_32_FOR(g_value_set_schar)
192void g_value_set_char (GValue *value,
193 gchar v_char);
194GLIB_DEPRECATED_IN_2_32_FOR(g_value_get_schar)
195gchar g_value_get_char (const GValue *value);
196GLIB_AVAILABLE_IN_ALL
197void g_value_set_schar (GValue *value,
198 gint8 v_char);
199GLIB_AVAILABLE_IN_ALL
200gint8 g_value_get_schar (const GValue *value);
201GLIB_AVAILABLE_IN_ALL
202void g_value_set_uchar (GValue *value,
203 guchar v_uchar);
204GLIB_AVAILABLE_IN_ALL
205guchar g_value_get_uchar (const GValue *value);
206GLIB_AVAILABLE_IN_ALL
207void g_value_set_boolean (GValue *value,
208 gboolean v_boolean);
209GLIB_AVAILABLE_IN_ALL
210gboolean g_value_get_boolean (const GValue *value);
211GLIB_AVAILABLE_IN_ALL
212void g_value_set_int (GValue *value,
213 gint v_int);
214GLIB_AVAILABLE_IN_ALL
215gint g_value_get_int (const GValue *value);
216GLIB_AVAILABLE_IN_ALL
217void g_value_set_uint (GValue *value,
218 guint v_uint);
219GLIB_AVAILABLE_IN_ALL
220guint g_value_get_uint (const GValue *value);
221GLIB_AVAILABLE_IN_ALL
222void g_value_set_long (GValue *value,
223 glong v_long);
224GLIB_AVAILABLE_IN_ALL
225glong g_value_get_long (const GValue *value);
226GLIB_AVAILABLE_IN_ALL
227void g_value_set_ulong (GValue *value,
228 gulong v_ulong);
229GLIB_AVAILABLE_IN_ALL
230gulong g_value_get_ulong (const GValue *value);
231GLIB_AVAILABLE_IN_ALL
232void g_value_set_int64 (GValue *value,
233 gint64 v_int64);
234GLIB_AVAILABLE_IN_ALL
235gint64 g_value_get_int64 (const GValue *value);
236GLIB_AVAILABLE_IN_ALL
237void g_value_set_uint64 (GValue *value,
238 guint64 v_uint64);
239GLIB_AVAILABLE_IN_ALL
240guint64 g_value_get_uint64 (const GValue *value);
241GLIB_AVAILABLE_IN_ALL
242void g_value_set_float (GValue *value,
243 gfloat v_float);
244GLIB_AVAILABLE_IN_ALL
245gfloat g_value_get_float (const GValue *value);
246GLIB_AVAILABLE_IN_ALL
247void g_value_set_double (GValue *value,
248 gdouble v_double);
249GLIB_AVAILABLE_IN_ALL
250gdouble g_value_get_double (const GValue *value);
251GLIB_AVAILABLE_IN_ALL
252void g_value_set_string (GValue *value,
253 const gchar *v_string);
254GLIB_AVAILABLE_IN_ALL
255void g_value_set_static_string (GValue *value,
256 const gchar *v_string);
257GLIB_AVAILABLE_IN_2_66
258void g_value_set_interned_string (GValue *value,
259 const gchar *v_string);
260GLIB_AVAILABLE_IN_ALL
261const gchar * g_value_get_string (const GValue *value);
262GLIB_AVAILABLE_IN_ALL
263gchar* g_value_dup_string (const GValue *value);
264GLIB_AVAILABLE_IN_ALL
265void g_value_set_pointer (GValue *value,
266 gpointer v_pointer);
267GLIB_AVAILABLE_IN_ALL
268gpointer g_value_get_pointer (const GValue *value);
269GLIB_AVAILABLE_IN_ALL
270GType g_gtype_get_type (void);
271GLIB_AVAILABLE_IN_ALL
272void g_value_set_gtype (GValue *value,
273 GType v_gtype);
274GLIB_AVAILABLE_IN_ALL
275GType g_value_get_gtype (const GValue *value);
276GLIB_AVAILABLE_IN_ALL
277void g_value_set_variant (GValue *value,
278 GVariant *variant);
279GLIB_AVAILABLE_IN_ALL
280void g_value_take_variant (GValue *value,
281 GVariant *variant);
282GLIB_AVAILABLE_IN_ALL
283GVariant* g_value_get_variant (const GValue *value);
284GLIB_AVAILABLE_IN_ALL
285GVariant* g_value_dup_variant (const GValue *value);
286
287
288/* Convenience for registering new pointer types */
289GLIB_AVAILABLE_IN_ALL
290GType g_pointer_type_register_static (const gchar *name);
291
292/* debugging aid, describe value contents as string */
293GLIB_AVAILABLE_IN_ALL
294gchar* g_strdup_value_contents (const GValue *value);
295
296
297GLIB_AVAILABLE_IN_ALL
298void g_value_take_string (GValue *value,
299 gchar *v_string);
300GLIB_DEPRECATED_FOR(g_value_take_string)
301void g_value_set_string_take_ownership (GValue *value,
302 gchar *v_string);
303
304
305/* humpf, need a C representable type name for G_TYPE_STRING */
306/**
307 * gchararray:
308 *
309 * A C representable type name for %G_TYPE_STRING.
310 */
311typedef gchar* gchararray;
312
313
314G_END_DECLS
315
316#endif /* __G_VALUETYPES_H__ */
317

source code of include/glib-2.0/gobject/gvaluetypes.h