1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
4 * SPDX-License-Identifier: LGPL-2.1-or-later
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 * gvaluetypes.h: GLib default values
21 #ifndef __G_VALUETYPES_H__
22 #define __G_VALUETYPES_H__
24 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
25 #error "Only <glib-object.h> can be included directly."
28 #include <gobject/gvalue.h>
32 /* --- type macros --- */
35 * @value: a valid #GValue structure
37 * Checks whether the given #GValue can hold values of type %G_TYPE_CHAR.
39 * Returns: %TRUE on success.
41 #define G_VALUE_HOLDS_CHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR))
43 * G_VALUE_HOLDS_UCHAR:
44 * @value: a valid #GValue structure
46 * Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR.
48 * Returns: %TRUE on success.
50 #define G_VALUE_HOLDS_UCHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR))
52 * G_VALUE_HOLDS_BOOLEAN:
53 * @value: a valid #GValue structure
55 * Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN.
57 * Returns: %TRUE on success.
59 #define G_VALUE_HOLDS_BOOLEAN(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN))
62 * @value: a valid #GValue structure
64 * Checks whether the given #GValue can hold values of type %G_TYPE_INT.
66 * Returns: %TRUE on success.
68 #define G_VALUE_HOLDS_INT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT))
71 * @value: a valid #GValue structure
73 * Checks whether the given #GValue can hold values of type %G_TYPE_UINT.
75 * Returns: %TRUE on success.
77 #define G_VALUE_HOLDS_UINT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT))
80 * @value: a valid #GValue structure
82 * Checks whether the given #GValue can hold values of type %G_TYPE_LONG.
84 * Returns: %TRUE on success.
86 #define G_VALUE_HOLDS_LONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG))
88 * G_VALUE_HOLDS_ULONG:
89 * @value: a valid #GValue structure
91 * Checks whether the given #GValue can hold values of type %G_TYPE_ULONG.
93 * Returns: %TRUE on success.
95 #define G_VALUE_HOLDS_ULONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG))
97 * G_VALUE_HOLDS_INT64:
98 * @value: a valid #GValue structure
100 * Checks whether the given #GValue can hold values of type %G_TYPE_INT64.
102 * Returns: %TRUE on success.
104 #define G_VALUE_HOLDS_INT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64))
106 * G_VALUE_HOLDS_UINT64:
107 * @value: a valid #GValue structure
109 * Checks whether the given #GValue can hold values of type %G_TYPE_UINT64.
111 * Returns: %TRUE on success.
113 #define G_VALUE_HOLDS_UINT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64))
115 * G_VALUE_HOLDS_FLOAT:
116 * @value: a valid #GValue structure
118 * Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT.
120 * Returns: %TRUE on success.
122 #define G_VALUE_HOLDS_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
124 * G_VALUE_HOLDS_DOUBLE:
125 * @value: a valid #GValue structure
127 * Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE.
129 * Returns: %TRUE on success.
131 #define G_VALUE_HOLDS_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
133 * G_VALUE_HOLDS_STRING:
134 * @value: a valid #GValue structure
136 * Checks whether the given #GValue can hold values of type %G_TYPE_STRING.
138 * Returns: %TRUE on success.
140 #define G_VALUE_HOLDS_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
142 * G_VALUE_IS_INTERNED_STRING:
143 * @value: a valid #GValue structure
145 * Checks whether @value contains a string which is canonical.
147 * Returns: %TRUE if the value contains a string in its canonical
148 * representation, as returned by g_intern_string(). See also
149 * g_value_set_interned_string().
153 #define G_VALUE_IS_INTERNED_STRING(value) (G_VALUE_HOLDS_STRING (value) && ((value)->data[1].v_uint & G_VALUE_INTERNED_STRING)) GOBJECT_AVAILABLE_MACRO_IN_2_66
155 * G_VALUE_HOLDS_POINTER:
156 * @value: a valid #GValue structure
158 * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER.
160 * Returns: %TRUE on success.
162 #define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
166 * The type for #GType.
168 #define G_TYPE_GTYPE (g_gtype_get_type())
170 * G_VALUE_HOLDS_GTYPE:
171 * @value: a valid #GValue structure
173 * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE.
176 * Returns: %TRUE on success.
178 #define G_VALUE_HOLDS_GTYPE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE))
180 * G_VALUE_HOLDS_VARIANT:
181 * @value: a valid #GValue structure
183 * Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT.
185 * Returns: %TRUE on success.
189 #define G_VALUE_HOLDS_VARIANT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT))
192 /* --- prototypes --- */
193 GOBJECT_DEPRECATED_IN_2_32_FOR(g_value_set_schar)
194 void g_value_set_char (GValue *value,
196 GOBJECT_DEPRECATED_IN_2_32_FOR(g_value_get_schar)
197 gchar g_value_get_char (const GValue *value);
198 GOBJECT_AVAILABLE_IN_ALL
199 void g_value_set_schar (GValue *value,
201 GOBJECT_AVAILABLE_IN_ALL
202 gint8 g_value_get_schar (const GValue *value);
203 GOBJECT_AVAILABLE_IN_ALL
204 void g_value_set_uchar (GValue *value,
206 GOBJECT_AVAILABLE_IN_ALL
207 guchar g_value_get_uchar (const GValue *value);
208 GOBJECT_AVAILABLE_IN_ALL
209 void g_value_set_boolean (GValue *value,
211 GOBJECT_AVAILABLE_IN_ALL
212 gboolean g_value_get_boolean (const GValue *value);
213 GOBJECT_AVAILABLE_IN_ALL
214 void g_value_set_int (GValue *value,
216 GOBJECT_AVAILABLE_IN_ALL
217 gint g_value_get_int (const GValue *value);
218 GOBJECT_AVAILABLE_IN_ALL
219 void g_value_set_uint (GValue *value,
221 GOBJECT_AVAILABLE_IN_ALL
222 guint g_value_get_uint (const GValue *value);
223 GOBJECT_AVAILABLE_IN_ALL
224 void g_value_set_long (GValue *value,
226 GOBJECT_AVAILABLE_IN_ALL
227 glong g_value_get_long (const GValue *value);
228 GOBJECT_AVAILABLE_IN_ALL
229 void g_value_set_ulong (GValue *value,
231 GOBJECT_AVAILABLE_IN_ALL
232 gulong g_value_get_ulong (const GValue *value);
233 GOBJECT_AVAILABLE_IN_ALL
234 void g_value_set_int64 (GValue *value,
236 GOBJECT_AVAILABLE_IN_ALL
237 gint64 g_value_get_int64 (const GValue *value);
238 GOBJECT_AVAILABLE_IN_ALL
239 void g_value_set_uint64 (GValue *value,
241 GOBJECT_AVAILABLE_IN_ALL
242 guint64 g_value_get_uint64 (const GValue *value);
243 GOBJECT_AVAILABLE_IN_ALL
244 void g_value_set_float (GValue *value,
246 GOBJECT_AVAILABLE_IN_ALL
247 gfloat g_value_get_float (const GValue *value);
248 GOBJECT_AVAILABLE_IN_ALL
249 void g_value_set_double (GValue *value,
251 GOBJECT_AVAILABLE_IN_ALL
252 gdouble g_value_get_double (const GValue *value);
253 GOBJECT_AVAILABLE_IN_ALL
254 void g_value_set_string (GValue *value,
255 const gchar *v_string);
256 GOBJECT_AVAILABLE_IN_ALL
257 void g_value_set_static_string (GValue *value,
258 const gchar *v_string);
259 GOBJECT_AVAILABLE_IN_2_66
260 void g_value_set_interned_string (GValue *value,
261 const gchar *v_string);
262 GOBJECT_AVAILABLE_IN_ALL
263 const gchar * g_value_get_string (const GValue *value);
264 GOBJECT_AVAILABLE_IN_ALL
265 gchar* g_value_dup_string (const GValue *value);
266 GOBJECT_AVAILABLE_IN_ALL
267 void g_value_set_pointer (GValue *value,
269 GOBJECT_AVAILABLE_IN_ALL
270 gpointer g_value_get_pointer (const GValue *value);
271 GOBJECT_AVAILABLE_IN_ALL
272 GType g_gtype_get_type (void);
273 GOBJECT_AVAILABLE_IN_ALL
274 void g_value_set_gtype (GValue *value,
276 GOBJECT_AVAILABLE_IN_ALL
277 GType g_value_get_gtype (const GValue *value);
278 GOBJECT_AVAILABLE_IN_ALL
279 void g_value_set_variant (GValue *value,
281 GOBJECT_AVAILABLE_IN_ALL
282 void g_value_take_variant (GValue *value,
284 GOBJECT_AVAILABLE_IN_ALL
285 GVariant* g_value_get_variant (const GValue *value);
286 GOBJECT_AVAILABLE_IN_ALL
287 GVariant* g_value_dup_variant (const GValue *value);
290 /* Convenience for registering new pointer types */
291 GOBJECT_AVAILABLE_IN_ALL
292 GType g_pointer_type_register_static (const gchar *name);
294 /* debugging aid, describe value contents as string */
295 GOBJECT_AVAILABLE_IN_ALL
296 gchar* g_strdup_value_contents (const GValue *value);
299 GOBJECT_AVAILABLE_IN_ALL
300 void g_value_take_string (GValue *value,
302 GOBJECT_DEPRECATED_FOR(g_value_take_string)
303 void g_value_set_string_take_ownership (GValue *value,
307 /* humpf, need a C representable type name for G_TYPE_STRING */
311 * A C representable type name for %G_TYPE_STRING.
313 typedef gchar* gchararray;
318 #endif /* __G_VALUETYPES_H__ */