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 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_HOLDS_POINTER:
141 * @value: a valid #GValue structure
142 *
143 * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER.
144 *
145 * Returns: %TRUE on success.
146 */
147#define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
148/**
149 * G_TYPE_GTYPE:
150 *
151 * The type for #GType.
152 */
153#define G_TYPE_GTYPE (g_gtype_get_type())
154/**
155 * G_VALUE_HOLDS_GTYPE:
156 * @value: a valid #GValue structure
157 *
158 * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE.
159 *
160 * Since: 2.12
161 * Returns: %TRUE on success.
162 */
163#define G_VALUE_HOLDS_GTYPE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE))
164/**
165 * G_VALUE_HOLDS_VARIANT:
166 * @value: a valid #GValue structure
167 *
168 * Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT.
169 *
170 * Returns: %TRUE on success.
171 *
172 * Since: 2.26
173 */
174#define G_VALUE_HOLDS_VARIANT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT))
175
176
177/* --- prototypes --- */
178GLIB_DEPRECATED_IN_2_32_FOR(g_value_set_schar)
179void g_value_set_char (GValue *value,
180 gchar v_char);
181GLIB_DEPRECATED_IN_2_32_FOR(g_value_get_schar)
182gchar g_value_get_char (const GValue *value);
183GLIB_AVAILABLE_IN_ALL
184void g_value_set_schar (GValue *value,
185 gint8 v_char);
186GLIB_AVAILABLE_IN_ALL
187gint8 g_value_get_schar (const GValue *value);
188GLIB_AVAILABLE_IN_ALL
189void g_value_set_uchar (GValue *value,
190 guchar v_uchar);
191GLIB_AVAILABLE_IN_ALL
192guchar g_value_get_uchar (const GValue *value);
193GLIB_AVAILABLE_IN_ALL
194void g_value_set_boolean (GValue *value,
195 gboolean v_boolean);
196GLIB_AVAILABLE_IN_ALL
197gboolean g_value_get_boolean (const GValue *value);
198GLIB_AVAILABLE_IN_ALL
199void g_value_set_int (GValue *value,
200 gint v_int);
201GLIB_AVAILABLE_IN_ALL
202gint g_value_get_int (const GValue *value);
203GLIB_AVAILABLE_IN_ALL
204void g_value_set_uint (GValue *value,
205 guint v_uint);
206GLIB_AVAILABLE_IN_ALL
207guint g_value_get_uint (const GValue *value);
208GLIB_AVAILABLE_IN_ALL
209void g_value_set_long (GValue *value,
210 glong v_long);
211GLIB_AVAILABLE_IN_ALL
212glong g_value_get_long (const GValue *value);
213GLIB_AVAILABLE_IN_ALL
214void g_value_set_ulong (GValue *value,
215 gulong v_ulong);
216GLIB_AVAILABLE_IN_ALL
217gulong g_value_get_ulong (const GValue *value);
218GLIB_AVAILABLE_IN_ALL
219void g_value_set_int64 (GValue *value,
220 gint64 v_int64);
221GLIB_AVAILABLE_IN_ALL
222gint64 g_value_get_int64 (const GValue *value);
223GLIB_AVAILABLE_IN_ALL
224void g_value_set_uint64 (GValue *value,
225 guint64 v_uint64);
226GLIB_AVAILABLE_IN_ALL
227guint64 g_value_get_uint64 (const GValue *value);
228GLIB_AVAILABLE_IN_ALL
229void g_value_set_float (GValue *value,
230 gfloat v_float);
231GLIB_AVAILABLE_IN_ALL
232gfloat g_value_get_float (const GValue *value);
233GLIB_AVAILABLE_IN_ALL
234void g_value_set_double (GValue *value,
235 gdouble v_double);
236GLIB_AVAILABLE_IN_ALL
237gdouble g_value_get_double (const GValue *value);
238GLIB_AVAILABLE_IN_ALL
239void g_value_set_string (GValue *value,
240 const gchar *v_string);
241GLIB_AVAILABLE_IN_ALL
242void g_value_set_static_string (GValue *value,
243 const gchar *v_string);
244GLIB_AVAILABLE_IN_ALL
245const gchar * g_value_get_string (const GValue *value);
246GLIB_AVAILABLE_IN_ALL
247gchar* g_value_dup_string (const GValue *value);
248GLIB_AVAILABLE_IN_ALL
249void g_value_set_pointer (GValue *value,
250 gpointer v_pointer);
251GLIB_AVAILABLE_IN_ALL
252gpointer g_value_get_pointer (const GValue *value);
253GLIB_AVAILABLE_IN_ALL
254GType g_gtype_get_type (void);
255GLIB_AVAILABLE_IN_ALL
256void g_value_set_gtype (GValue *value,
257 GType v_gtype);
258GLIB_AVAILABLE_IN_ALL
259GType g_value_get_gtype (const GValue *value);
260GLIB_AVAILABLE_IN_ALL
261void g_value_set_variant (GValue *value,
262 GVariant *variant);
263GLIB_AVAILABLE_IN_ALL
264void g_value_take_variant (GValue *value,
265 GVariant *variant);
266GLIB_AVAILABLE_IN_ALL
267GVariant* g_value_get_variant (const GValue *value);
268GLIB_AVAILABLE_IN_ALL
269GVariant* g_value_dup_variant (const GValue *value);
270
271
272/* Convenience for registering new pointer types */
273GLIB_AVAILABLE_IN_ALL
274GType g_pointer_type_register_static (const gchar *name);
275
276/* debugging aid, describe value contents as string */
277GLIB_AVAILABLE_IN_ALL
278gchar* g_strdup_value_contents (const GValue *value);
279
280
281GLIB_AVAILABLE_IN_ALL
282void g_value_take_string (GValue *value,
283 gchar *v_string);
284GLIB_DEPRECATED_FOR(g_value_take_string)
285void g_value_set_string_take_ownership (GValue *value,
286 gchar *v_string);
287
288
289/* humpf, need a C representable type name for G_TYPE_STRING */
290/**
291 * gchararray:
292 *
293 * A C representable type name for #G_TYPE_STRING.
294 */
295typedef gchar* gchararray;
296
297
298G_END_DECLS
299
300#endif /* __G_VALUETYPES_H__ */
301