gvaluetypes.h 9.43 KB
Newer Older
1
/* GObject - GLib Type, Object, Parameter and Signal Library
2
 * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
3 4 5 6
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * 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 10
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
12 13 14
 * Lesser General Public License for more details.
 *
 * 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 18
 *
 * gvaluetypes.h: GLib default values
 */
19 20 21
#ifndef __G_VALUETYPES_H__
#define __G_VALUETYPES_H__

22 23 24
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
#error "Only <glib-object.h> can be included directly."
#endif
25

26
#include	<gobject/gvalue.h>
27

28
G_BEGIN_DECLS
29 30

/* --- type macros --- */
Stefan Kost's avatar
Stefan Kost committed
31 32 33 34 35 36 37 38
/**
 * G_VALUE_HOLDS_CHAR:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_CHAR.
 * 
 * Returns: %TRUE on success.
 */
39
#define G_VALUE_HOLDS_CHAR(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR))
Stefan Kost's avatar
Stefan Kost committed
40 41 42 43 44 45 46 47
/**
 * G_VALUE_HOLDS_UCHAR:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR.
 * 
 * Returns: %TRUE on success.
 */
48
#define G_VALUE_HOLDS_UCHAR(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR))
Stefan Kost's avatar
Stefan Kost committed
49 50 51 52 53 54 55 56
/**
 * G_VALUE_HOLDS_BOOLEAN:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN.
 * 
 * Returns: %TRUE on success.
 */
57
#define G_VALUE_HOLDS_BOOLEAN(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN))
Stefan Kost's avatar
Stefan Kost committed
58 59 60 61 62 63 64 65
/**
 * G_VALUE_HOLDS_INT:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_INT.
 * 
 * Returns: %TRUE on success.
 */
66
#define G_VALUE_HOLDS_INT(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT))
Stefan Kost's avatar
Stefan Kost committed
67 68 69 70 71 72 73 74
/**
 * G_VALUE_HOLDS_UINT:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_UINT.
 * 
 * Returns: %TRUE on success.
 */
75
#define G_VALUE_HOLDS_UINT(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT))
Stefan Kost's avatar
Stefan Kost committed
76 77 78 79 80 81 82 83
/**
 * G_VALUE_HOLDS_LONG:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_LONG.
 * 
 * Returns: %TRUE on success.
 */
84
#define G_VALUE_HOLDS_LONG(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG))
Stefan Kost's avatar
Stefan Kost committed
85 86 87 88 89 90 91 92
/**
 * G_VALUE_HOLDS_ULONG:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_ULONG.
 * 
 * Returns: %TRUE on success.
 */
93
#define G_VALUE_HOLDS_ULONG(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG))
Stefan Kost's avatar
Stefan Kost committed
94 95 96 97 98 99 100 101
/**
 * G_VALUE_HOLDS_INT64:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_INT64.
 * 
 * Returns: %TRUE on success.
 */
102
#define G_VALUE_HOLDS_INT64(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64))
Stefan Kost's avatar
Stefan Kost committed
103 104 105 106 107 108 109 110
/**
 * G_VALUE_HOLDS_UINT64:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_UINT64.
 * 
 * Returns: %TRUE on success.
 */
111
#define G_VALUE_HOLDS_UINT64(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64))
Stefan Kost's avatar
Stefan Kost committed
112 113 114 115 116 117 118 119
/**
 * G_VALUE_HOLDS_FLOAT:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT.
 * 
 * Returns: %TRUE on success.
 */
120
#define G_VALUE_HOLDS_FLOAT(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
Stefan Kost's avatar
Stefan Kost committed
121 122 123 124 125 126 127 128
/**
 * G_VALUE_HOLDS_DOUBLE:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE.
 * 
 * Returns: %TRUE on success.
 */
129
#define G_VALUE_HOLDS_DOUBLE(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
Stefan Kost's avatar
Stefan Kost committed
130 131 132 133 134 135 136 137
/**
 * G_VALUE_HOLDS_STRING:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_STRING.
 * 
 * Returns: %TRUE on success.
 */
138
#define G_VALUE_HOLDS_STRING(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
Stefan Kost's avatar
Stefan Kost committed
139 140 141 142 143 144 145 146
/**
 * G_VALUE_HOLDS_POINTER:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER.
 * 
 * Returns: %TRUE on success.
 */
147
#define G_VALUE_HOLDS_POINTER(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
Stefan Kost's avatar
Stefan Kost committed
148 149 150 151 152
/**
 * G_TYPE_GTYPE:
 * 
 * The type for #GType.
 */
153
#define	G_TYPE_GTYPE			 (g_gtype_get_type())
Stefan Kost's avatar
Stefan Kost committed
154 155 156 157 158 159 160 161 162
/**
 * G_VALUE_HOLDS_GTYPE:
 * @value: a valid #GValue structure
 * 
 * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE.
 * 
 * Since: 2.12
 * Returns: %TRUE on success.
 */
163
#define G_VALUE_HOLDS_GTYPE(value)	 (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE))
164 165 166 167 168 169 170 171 172 173 174
/**
 * G_VALUE_HOLDS_VARIANT:
 * @value: a valid #GValue structure
 *
 * Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT.
 *
 * Returns: %TRUE on success.
 *
 * Since: 2.26
 */
#define G_VALUE_HOLDS_VARIANT(value)     (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT))
175 176 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 185
void		      g_value_set_schar		(GValue	      *value,
						 gint8	       v_char);
186
GLIB_AVAILABLE_IN_ALL
187
gint8		      g_value_get_schar		(const GValue *value);
188
GLIB_AVAILABLE_IN_ALL
189 190
void		      g_value_set_uchar		(GValue	      *value,
						 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,
Havoc Pennington's avatar
Havoc Pennington committed
195
						 gboolean      v_boolean);
196
GLIB_AVAILABLE_IN_ALL
197
gboolean	      g_value_get_boolean	(const GValue *value);
198
GLIB_AVAILABLE_IN_ALL
199 200
void		      g_value_set_int		(GValue	      *value,
						 gint	       v_int);
201
GLIB_AVAILABLE_IN_ALL
202
gint		      g_value_get_int		(const GValue *value);
203
GLIB_AVAILABLE_IN_ALL
204 205
void		      g_value_set_uint		(GValue	      *value,
						 guint	       v_uint);
206
GLIB_AVAILABLE_IN_ALL
207
guint		      g_value_get_uint		(const GValue *value);
208
GLIB_AVAILABLE_IN_ALL
209 210
void		      g_value_set_long		(GValue	      *value,
						 glong	       v_long);
211
GLIB_AVAILABLE_IN_ALL
212
glong		      g_value_get_long		(const GValue *value);
213
GLIB_AVAILABLE_IN_ALL
214 215
void		      g_value_set_ulong		(GValue	      *value,
						 gulong	       v_ulong);
216
GLIB_AVAILABLE_IN_ALL
217
gulong		      g_value_get_ulong		(const GValue *value);
218
GLIB_AVAILABLE_IN_ALL
219 220
void		      g_value_set_int64		(GValue	      *value,
						 gint64	       v_int64);
221
GLIB_AVAILABLE_IN_ALL
222
gint64		      g_value_get_int64		(const GValue *value);
223
GLIB_AVAILABLE_IN_ALL
224 225
void		      g_value_set_uint64	(GValue	      *value,
						 guint64      v_uint64);
226
GLIB_AVAILABLE_IN_ALL
227
guint64		      g_value_get_uint64	(const GValue *value);
228
GLIB_AVAILABLE_IN_ALL
229 230
void		      g_value_set_float		(GValue	      *value,
						 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,
Havoc Pennington's avatar
Havoc Pennington committed
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,
Havoc Pennington's avatar
Havoc Pennington committed
240
						 const gchar  *v_string);
241
GLIB_AVAILABLE_IN_ALL
242
void		      g_value_set_static_string (GValue	      *value,
Havoc Pennington's avatar
Havoc Pennington committed
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,
Havoc Pennington's avatar
Havoc Pennington committed
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 257
void		      g_value_set_gtype	        (GValue	      *value,
						 GType         v_gtype);
258
GLIB_AVAILABLE_IN_ALL
259
GType	              g_value_get_gtype	        (const GValue *value);
260
GLIB_AVAILABLE_IN_ALL
261 262
void		      g_value_set_variant	(GValue	      *value,
						 GVariant     *variant);
263
GLIB_AVAILABLE_IN_ALL
264 265
void		      g_value_take_variant	(GValue	      *value,
						 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);
270 271


272
/* Convenience for registering new pointer types */
273
GLIB_AVAILABLE_IN_ALL
274 275
GType                 g_pointer_type_register_static (const gchar *name);

276
/* debugging aid, describe value contents as string */
277
GLIB_AVAILABLE_IN_ALL
278 279 280
gchar*                g_strdup_value_contents   (const GValue *value);


281
GLIB_AVAILABLE_IN_ALL
282 283
void g_value_take_string		        (GValue		   *value,
						 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);
287 288


289
/* humpf, need a C representable type name for G_TYPE_STRING */
Stefan Kost's avatar
Stefan Kost committed
290 291 292 293 294
/**
 * gchararray:
 * 
 * A C representable type name for #G_TYPE_STRING.
 */
295 296
typedef gchar* gchararray;

297

298
G_END_DECLS
299 300

#endif /* __G_VALUETYPES_H__ */