Merge branch '1465-bye-bye-g-gnuc-malloc' into 'master'
[glib.git] / gobject / gvaluetypes.h
blob9274435329a31792fefe8babc6a06ff8aaf3086f
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
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.
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.
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/>.
17 * gvaluetypes.h: GLib default values
19 #ifndef __G_VALUETYPES_H__
20 #define __G_VALUETYPES_H__
22 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
23 #error "Only <glib-object.h> can be included directly."
24 #endif
26 #include <gobject/gvalue.h>
28 G_BEGIN_DECLS
30 /* --- type macros --- */
31 /**
32 * G_VALUE_HOLDS_CHAR:
33 * @value: a valid #GValue structure
35 * Checks whether the given #GValue can hold values of type %G_TYPE_CHAR.
37 * Returns: %TRUE on success.
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
44 * Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR.
46 * Returns: %TRUE on success.
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
53 * Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN.
55 * Returns: %TRUE on success.
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
62 * Checks whether the given #GValue can hold values of type %G_TYPE_INT.
64 * Returns: %TRUE on success.
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
71 * Checks whether the given #GValue can hold values of type %G_TYPE_UINT.
73 * Returns: %TRUE on success.
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
80 * Checks whether the given #GValue can hold values of type %G_TYPE_LONG.
82 * Returns: %TRUE on success.
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
89 * Checks whether the given #GValue can hold values of type %G_TYPE_ULONG.
91 * Returns: %TRUE on success.
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
98 * Checks whether the given #GValue can hold values of type %G_TYPE_INT64.
100 * Returns: %TRUE on success.
102 #define G_VALUE_HOLDS_INT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64))
104 * G_VALUE_HOLDS_UINT64:
105 * @value: a valid #GValue structure
107 * Checks whether the given #GValue can hold values of type %G_TYPE_UINT64.
109 * Returns: %TRUE on success.
111 #define G_VALUE_HOLDS_UINT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64))
113 * G_VALUE_HOLDS_FLOAT:
114 * @value: a valid #GValue structure
116 * Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT.
118 * Returns: %TRUE on success.
120 #define G_VALUE_HOLDS_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
122 * G_VALUE_HOLDS_DOUBLE:
123 * @value: a valid #GValue structure
125 * Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE.
127 * Returns: %TRUE on success.
129 #define G_VALUE_HOLDS_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
131 * G_VALUE_HOLDS_STRING:
132 * @value: a valid #GValue structure
134 * Checks whether the given #GValue can hold values of type %G_TYPE_STRING.
136 * Returns: %TRUE on success.
138 #define G_VALUE_HOLDS_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
140 * G_VALUE_HOLDS_POINTER:
141 * @value: a valid #GValue structure
143 * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER.
145 * Returns: %TRUE on success.
147 #define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
149 * G_TYPE_GTYPE:
151 * The type for #GType.
153 #define G_TYPE_GTYPE (g_gtype_get_type())
155 * G_VALUE_HOLDS_GTYPE:
156 * @value: a valid #GValue structure
158 * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE.
160 * Since: 2.12
161 * Returns: %TRUE on success.
163 #define G_VALUE_HOLDS_GTYPE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE))
165 * G_VALUE_HOLDS_VARIANT:
166 * @value: a valid #GValue structure
168 * Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT.
170 * Returns: %TRUE on success.
172 * Since: 2.26
174 #define G_VALUE_HOLDS_VARIANT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT))
177 /* --- prototypes --- */
178 GLIB_DEPRECATED_IN_2_32_FOR(g_value_set_schar)
179 void g_value_set_char (GValue *value,
180 gchar v_char);
181 GLIB_DEPRECATED_IN_2_32_FOR(g_value_get_schar)
182 gchar g_value_get_char (const GValue *value);
183 GLIB_AVAILABLE_IN_ALL
184 void g_value_set_schar (GValue *value,
185 gint8 v_char);
186 GLIB_AVAILABLE_IN_ALL
187 gint8 g_value_get_schar (const GValue *value);
188 GLIB_AVAILABLE_IN_ALL
189 void g_value_set_uchar (GValue *value,
190 guchar v_uchar);
191 GLIB_AVAILABLE_IN_ALL
192 guchar g_value_get_uchar (const GValue *value);
193 GLIB_AVAILABLE_IN_ALL
194 void g_value_set_boolean (GValue *value,
195 gboolean v_boolean);
196 GLIB_AVAILABLE_IN_ALL
197 gboolean g_value_get_boolean (const GValue *value);
198 GLIB_AVAILABLE_IN_ALL
199 void g_value_set_int (GValue *value,
200 gint v_int);
201 GLIB_AVAILABLE_IN_ALL
202 gint g_value_get_int (const GValue *value);
203 GLIB_AVAILABLE_IN_ALL
204 void g_value_set_uint (GValue *value,
205 guint v_uint);
206 GLIB_AVAILABLE_IN_ALL
207 guint g_value_get_uint (const GValue *value);
208 GLIB_AVAILABLE_IN_ALL
209 void g_value_set_long (GValue *value,
210 glong v_long);
211 GLIB_AVAILABLE_IN_ALL
212 glong g_value_get_long (const GValue *value);
213 GLIB_AVAILABLE_IN_ALL
214 void g_value_set_ulong (GValue *value,
215 gulong v_ulong);
216 GLIB_AVAILABLE_IN_ALL
217 gulong g_value_get_ulong (const GValue *value);
218 GLIB_AVAILABLE_IN_ALL
219 void g_value_set_int64 (GValue *value,
220 gint64 v_int64);
221 GLIB_AVAILABLE_IN_ALL
222 gint64 g_value_get_int64 (const GValue *value);
223 GLIB_AVAILABLE_IN_ALL
224 void g_value_set_uint64 (GValue *value,
225 guint64 v_uint64);
226 GLIB_AVAILABLE_IN_ALL
227 guint64 g_value_get_uint64 (const GValue *value);
228 GLIB_AVAILABLE_IN_ALL
229 void g_value_set_float (GValue *value,
230 gfloat v_float);
231 GLIB_AVAILABLE_IN_ALL
232 gfloat g_value_get_float (const GValue *value);
233 GLIB_AVAILABLE_IN_ALL
234 void g_value_set_double (GValue *value,
235 gdouble v_double);
236 GLIB_AVAILABLE_IN_ALL
237 gdouble g_value_get_double (const GValue *value);
238 GLIB_AVAILABLE_IN_ALL
239 void g_value_set_string (GValue *value,
240 const gchar *v_string);
241 GLIB_AVAILABLE_IN_ALL
242 void g_value_set_static_string (GValue *value,
243 const gchar *v_string);
244 GLIB_AVAILABLE_IN_ALL
245 const gchar * g_value_get_string (const GValue *value);
246 GLIB_AVAILABLE_IN_ALL
247 gchar* g_value_dup_string (const GValue *value);
248 GLIB_AVAILABLE_IN_ALL
249 void g_value_set_pointer (GValue *value,
250 gpointer v_pointer);
251 GLIB_AVAILABLE_IN_ALL
252 gpointer g_value_get_pointer (const GValue *value);
253 GLIB_AVAILABLE_IN_ALL
254 GType g_gtype_get_type (void);
255 GLIB_AVAILABLE_IN_ALL
256 void g_value_set_gtype (GValue *value,
257 GType v_gtype);
258 GLIB_AVAILABLE_IN_ALL
259 GType g_value_get_gtype (const GValue *value);
260 GLIB_AVAILABLE_IN_ALL
261 void g_value_set_variant (GValue *value,
262 GVariant *variant);
263 GLIB_AVAILABLE_IN_ALL
264 void g_value_take_variant (GValue *value,
265 GVariant *variant);
266 GLIB_AVAILABLE_IN_ALL
267 GVariant* g_value_get_variant (const GValue *value);
268 GLIB_AVAILABLE_IN_ALL
269 GVariant* g_value_dup_variant (const GValue *value);
272 /* Convenience for registering new pointer types */
273 GLIB_AVAILABLE_IN_ALL
274 GType g_pointer_type_register_static (const gchar *name);
276 /* debugging aid, describe value contents as string */
277 GLIB_AVAILABLE_IN_ALL
278 gchar* g_strdup_value_contents (const GValue *value);
281 GLIB_AVAILABLE_IN_ALL
282 void g_value_take_string (GValue *value,
283 gchar *v_string);
284 GLIB_DEPRECATED_FOR(g_value_take_string)
285 void g_value_set_string_take_ownership (GValue *value,
286 gchar *v_string);
289 /* humpf, need a C representable type name for G_TYPE_STRING */
291 * gchararray:
293 * A C representable type name for #G_TYPE_STRING.
295 typedef gchar* gchararray;
298 G_END_DECLS
300 #endif /* __G_VALUETYPES_H__ */