• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
28 G_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 --- */
191 GLIB_DEPRECATED_IN_2_32_FOR(g_value_set_schar)
192 void                  g_value_set_char          (GValue       *value,
193                                                  gchar         v_char);
194 GLIB_DEPRECATED_IN_2_32_FOR(g_value_get_schar)
195 gchar                 g_value_get_char          (const GValue *value);
196 GLIB_AVAILABLE_IN_ALL
197 void		      g_value_set_schar		(GValue	      *value,
198 						 gint8	       v_char);
199 GLIB_AVAILABLE_IN_ALL
200 gint8		      g_value_get_schar		(const GValue *value);
201 GLIB_AVAILABLE_IN_ALL
202 void		      g_value_set_uchar		(GValue	      *value,
203 						 guchar	       v_uchar);
204 GLIB_AVAILABLE_IN_ALL
205 guchar		      g_value_get_uchar		(const GValue *value);
206 GLIB_AVAILABLE_IN_ALL
207 void		      g_value_set_boolean	(GValue	      *value,
208 						 gboolean      v_boolean);
209 GLIB_AVAILABLE_IN_ALL
210 gboolean	      g_value_get_boolean	(const GValue *value);
211 GLIB_AVAILABLE_IN_ALL
212 void		      g_value_set_int		(GValue	      *value,
213 						 gint	       v_int);
214 GLIB_AVAILABLE_IN_ALL
215 gint		      g_value_get_int		(const GValue *value);
216 GLIB_AVAILABLE_IN_ALL
217 void		      g_value_set_uint		(GValue	      *value,
218 						 guint	       v_uint);
219 GLIB_AVAILABLE_IN_ALL
220 guint		      g_value_get_uint		(const GValue *value);
221 GLIB_AVAILABLE_IN_ALL
222 void		      g_value_set_long		(GValue	      *value,
223 						 glong	       v_long);
224 GLIB_AVAILABLE_IN_ALL
225 glong		      g_value_get_long		(const GValue *value);
226 GLIB_AVAILABLE_IN_ALL
227 void		      g_value_set_ulong		(GValue	      *value,
228 						 gulong	       v_ulong);
229 GLIB_AVAILABLE_IN_ALL
230 gulong		      g_value_get_ulong		(const GValue *value);
231 GLIB_AVAILABLE_IN_ALL
232 void		      g_value_set_int64		(GValue	      *value,
233 						 gint64	       v_int64);
234 GLIB_AVAILABLE_IN_ALL
235 gint64		      g_value_get_int64		(const GValue *value);
236 GLIB_AVAILABLE_IN_ALL
237 void		      g_value_set_uint64	(GValue	      *value,
238 						 guint64      v_uint64);
239 GLIB_AVAILABLE_IN_ALL
240 guint64		      g_value_get_uint64	(const GValue *value);
241 GLIB_AVAILABLE_IN_ALL
242 void		      g_value_set_float		(GValue	      *value,
243 						 gfloat	       v_float);
244 GLIB_AVAILABLE_IN_ALL
245 gfloat		      g_value_get_float		(const GValue *value);
246 GLIB_AVAILABLE_IN_ALL
247 void		      g_value_set_double	(GValue	      *value,
248 						 gdouble       v_double);
249 GLIB_AVAILABLE_IN_ALL
250 gdouble		      g_value_get_double	(const GValue *value);
251 GLIB_AVAILABLE_IN_ALL
252 void		      g_value_set_string	(GValue	      *value,
253 						 const gchar  *v_string);
254 GLIB_AVAILABLE_IN_ALL
255 void		      g_value_set_static_string (GValue	      *value,
256 						 const gchar  *v_string);
257 GLIB_AVAILABLE_IN_2_66
258 void		      g_value_set_interned_string (GValue      *value,
259 						   const gchar  *v_string);
260 GLIB_AVAILABLE_IN_ALL
261 const gchar *         g_value_get_string	(const GValue *value);
262 GLIB_AVAILABLE_IN_ALL
263 gchar*		      g_value_dup_string	(const GValue *value);
264 GLIB_AVAILABLE_IN_ALL
265 void		      g_value_set_pointer	(GValue	      *value,
266 						 gpointer      v_pointer);
267 GLIB_AVAILABLE_IN_ALL
268 gpointer	      g_value_get_pointer	(const GValue *value);
269 GLIB_AVAILABLE_IN_ALL
270 GType		      g_gtype_get_type		(void);
271 GLIB_AVAILABLE_IN_ALL
272 void		      g_value_set_gtype	        (GValue	      *value,
273 						 GType         v_gtype);
274 GLIB_AVAILABLE_IN_ALL
275 GType	              g_value_get_gtype	        (const GValue *value);
276 GLIB_AVAILABLE_IN_ALL
277 void		      g_value_set_variant	(GValue	      *value,
278 						 GVariant     *variant);
279 GLIB_AVAILABLE_IN_ALL
280 void		      g_value_take_variant	(GValue	      *value,
281 						 GVariant     *variant);
282 GLIB_AVAILABLE_IN_ALL
283 GVariant*	      g_value_get_variant	(const GValue *value);
284 GLIB_AVAILABLE_IN_ALL
285 GVariant*	      g_value_dup_variant	(const GValue *value);
286 
287 
288 /* Convenience for registering new pointer types */
289 GLIB_AVAILABLE_IN_ALL
290 GType                 g_pointer_type_register_static (const gchar *name);
291 
292 /* debugging aid, describe value contents as string */
293 GLIB_AVAILABLE_IN_ALL
294 gchar*                g_strdup_value_contents   (const GValue *value);
295 
296 
297 GLIB_AVAILABLE_IN_ALL
298 void g_value_take_string		        (GValue		   *value,
299 						 gchar		   *v_string);
300 GLIB_DEPRECATED_FOR(g_value_take_string)
301 void 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  */
311 typedef gchar* gchararray;
312 
313 
314 G_END_DECLS
315 
316 #endif /* __G_VALUETYPES_H__ */
317