2 * Copyright © 2007, 2008 Ryan Lortie
3 * Copyright © 2009, 2010 Codethink Limited
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the licence, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Ryan Lortie <desrt@desrt.ca>
23 #ifndef __G_VARIANT_TYPE_H__
24 #define __G_VARIANT_TYPE_H__
26 #include <glib/gmessages.h>
27 #include <glib/gtypes.h>
29 typedef struct _GVariantType GVariantType;
32 * G_VARIANT_TYPE_BOOLEAN:
34 * The type of a value that can be either %TRUE or %FALSE.
36 #define G_VARIANT_TYPE_BOOLEAN ((const GVariantType *) "b")
39 * G_VARIANT_TYPE_BYTE:
41 * The type of an integer value that can range from 0 to 255.
43 #define G_VARIANT_TYPE_BYTE ((const GVariantType *) "y")
46 * G_VARIANT_TYPE_INT16:
48 * The type of an integer value that can range from -32768 to 32767.
50 #define G_VARIANT_TYPE_INT16 ((const GVariantType *) "n")
53 * G_VARIANT_TYPE_UINT16:
55 * The type of an integer value that can range from 0 to 65535.
56 * There were about this many people living in Toronto in the 1870s.
58 #define G_VARIANT_TYPE_UINT16 ((const GVariantType *) "q")
61 * G_VARIANT_TYPE_INT32:
63 * The type of an integer value that can range from -2147483648 to
66 #define G_VARIANT_TYPE_INT32 ((const GVariantType *) "i")
69 * G_VARIANT_TYPE_UINT32:
71 * The type of an integer value that can range from 0 to 4294967295.
72 * That's one number for everyone who was around in the late 1970s.
74 #define G_VARIANT_TYPE_UINT32 ((const GVariantType *) "u")
77 * G_VARIANT_TYPE_INT64:
79 * The type of an integer value that can range from
80 * -9223372036854775808 to 9223372036854775807.
82 #define G_VARIANT_TYPE_INT64 ((const GVariantType *) "x")
85 * G_VARIANT_TYPE_UINT64:
87 * The type of an integer value that can range from 0 to
88 * 18446744073709551616. That's a really big number, but a Rubik's
89 * cube can have a bit more than twice as many possible positions.
91 #define G_VARIANT_TYPE_UINT64 ((const GVariantType *) "t")
94 * G_VARIANT_TYPE_DOUBLE:
96 * The type of a double precision IEEE754 floating point number.
97 * These guys go up to about 1.80e308 (plus and minus) but miss out on
98 * some numbers in between. In any case, that's far greater than the
99 * estimated number of fundamental particles in the observable
102 #define G_VARIANT_TYPE_DOUBLE ((const GVariantType *) "d")
105 * G_VARIANT_TYPE_STRING:
107 * The type of a string. "" is a string. %NULL is not a string.
109 #define G_VARIANT_TYPE_STRING ((const GVariantType *) "s")
112 * G_VARIANT_TYPE_OBJECT_PATH:
114 * The type of a DBus object reference. These are strings of a
115 * specific format used to identify objects at a given destination on
118 * If you are not interacting with DBus, then there is no reason to make
119 * use of this type. If you are, then the DBus specification contains a
120 * precise description of valid object paths.
122 #define G_VARIANT_TYPE_OBJECT_PATH ((const GVariantType *) "o")
125 * G_VARIANT_TYPE_SIGNATURE:
127 * The type of a DBus type signature. These are strings of a specific
128 * format used as type signatures for DBus methods and messages.
130 * If you are not interacting with DBus, then there is no reason to make
131 * use of this type. If you are, then the DBus specification contains a
132 * precise description of valid signature strings.
134 #define G_VARIANT_TYPE_SIGNATURE ((const GVariantType *) "g")
137 * G_VARIANT_TYPE_VARIANT:
139 * The type of a box that contains any other value (including another
142 #define G_VARIANT_TYPE_VARIANT ((const GVariantType *) "v")
145 * G_VARIANT_TYPE_HANDLE:
147 * The type of a 32bit signed integer value, that by convention, is used
148 * as an index into an array of file descriptors that are sent alongside
151 * If you are not interacting with DBus, then there is no reason to make
154 #define G_VARIANT_TYPE_HANDLE ((const GVariantType *) "h")
157 * G_VARIANT_TYPE_UNIT:
159 * The empty tuple type. Has only one instance. Known also as "triv"
162 #define G_VARIANT_TYPE_UNIT ((const GVariantType *) "()")
165 * G_VARIANT_TYPE_ANY:
167 * An indefinite type that is a supertype of every type (including
170 #define G_VARIANT_TYPE_ANY ((const GVariantType *) "*")
173 * G_VARIANT_TYPE_BASIC:
175 * An indefinite type that is a supertype of every basic (ie:
176 * non-container) type.
178 #define G_VARIANT_TYPE_BASIC ((const GVariantType *) "?")
181 * G_VARIANT_TYPE_MAYBE:
183 * An indefinite type that is a supertype of every maybe type.
185 #define G_VARIANT_TYPE_MAYBE ((const GVariantType *) "m*")
188 * G_VARIANT_TYPE_ARRAY:
190 * An indefinite type that is a supertype of every array type.
192 #define G_VARIANT_TYPE_ARRAY ((const GVariantType *) "a*")
195 * G_VARIANT_TYPE_TUPLE:
197 * An indefinite type that is a supertype of every tuple type,
198 * regardless of the number of items in the tuple.
200 #define G_VARIANT_TYPE_TUPLE ((const GVariantType *) "r")
203 * G_VARIANT_TYPE_DICT_ENTRY:
205 * An indefinite type that is a supertype of every dictionary entry
208 #define G_VARIANT_TYPE_DICT_ENTRY ((const GVariantType *) "{?*}")
211 * G_VARIANT_TYPE_DICTIONARY:
213 * An indefinite type that is a supertype of every dictionary type --
214 * that is, any array type that has an element type equal to any
215 * dictionary entry type.
217 #define G_VARIANT_TYPE_DICTIONARY ((const GVariantType *) "a{?*}")
219 #ifndef G_DISABLE_CHECKS
220 # define G_VARIANT_TYPE(str) (g_variant_type_checked_ ((str)))
222 # define G_VARIANT_TYPE(str) ((const GVariantType *) (str))
227 /* type string checking */
228 gboolean g_variant_type_string_is_valid (const gchar *type_string);
229 gboolean g_variant_type_string_scan (const gchar *string,
231 const gchar **endptr);
234 void g_variant_type_free (GVariantType *type);
235 GVariantType * g_variant_type_copy (const GVariantType *type);
236 GVariantType * g_variant_type_new (const gchar *type_string);
239 gsize g_variant_type_get_string_length (const GVariantType *type);
240 const gchar * g_variant_type_peek_string (const GVariantType *type);
241 gchar * g_variant_type_dup_string (const GVariantType *type);
244 gboolean g_variant_type_is_definite (const GVariantType *type);
245 gboolean g_variant_type_is_container (const GVariantType *type);
246 gboolean g_variant_type_is_basic (const GVariantType *type);
247 gboolean g_variant_type_is_maybe (const GVariantType *type);
248 gboolean g_variant_type_is_array (const GVariantType *type);
249 gboolean g_variant_type_is_tuple (const GVariantType *type);
250 gboolean g_variant_type_is_dict_entry (const GVariantType *type);
252 /* for hash tables */
253 guint g_variant_type_hash (gconstpointer type);
254 gboolean g_variant_type_equal (gconstpointer type1,
255 gconstpointer type2);
258 gboolean g_variant_type_is_subtype_of (const GVariantType *type,
259 const GVariantType *supertype);
261 /* type iterator interface */
262 const GVariantType * g_variant_type_element (const GVariantType *type);
263 const GVariantType * g_variant_type_first (const GVariantType *type);
264 const GVariantType * g_variant_type_next (const GVariantType *type);
265 gsize g_variant_type_n_items (const GVariantType *type);
266 const GVariantType * g_variant_type_key (const GVariantType *type);
267 const GVariantType * g_variant_type_value (const GVariantType *type);
270 GVariantType * g_variant_type_new_array (const GVariantType *element);
271 GVariantType * g_variant_type_new_maybe (const GVariantType *element);
272 GVariantType * g_variant_type_new_tuple (const GVariantType * const *items,
274 GVariantType * g_variant_type_new_dict_entry (const GVariantType *key,
275 const GVariantType *value);
278 const GVariantType * g_variant_type_checked_ (const gchar *);
282 #endif /* __G_VARIANT_TYPE_H__ */