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