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 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
24 #error "Only <glib.h> can be included directly."
27 #ifndef __G_VARIANT_H__
28 #define __G_VARIANT_H__
30 #include <glib/gvarianttype.h>
31 #include <glib/gstring.h>
35 typedef struct _GVariant GVariant;
39 G_VARIANT_CLASS_BOOLEAN = 'b',
40 G_VARIANT_CLASS_BYTE = 'y',
41 G_VARIANT_CLASS_INT16 = 'n',
42 G_VARIANT_CLASS_UINT16 = 'q',
43 G_VARIANT_CLASS_INT32 = 'i',
44 G_VARIANT_CLASS_UINT32 = 'u',
45 G_VARIANT_CLASS_INT64 = 'x',
46 G_VARIANT_CLASS_UINT64 = 't',
47 G_VARIANT_CLASS_HANDLE = 'h',
48 G_VARIANT_CLASS_DOUBLE = 'd',
49 G_VARIANT_CLASS_STRING = 's',
50 G_VARIANT_CLASS_OBJECT_PATH = 'o',
51 G_VARIANT_CLASS_SIGNATURE = 'g',
52 G_VARIANT_CLASS_VARIANT = 'v',
53 G_VARIANT_CLASS_MAYBE = 'm',
54 G_VARIANT_CLASS_ARRAY = 'a',
55 G_VARIANT_CLASS_TUPLE = '(',
56 G_VARIANT_CLASS_DICT_ENTRY = '{'
59 void g_variant_unref (GVariant *value);
60 GVariant * g_variant_ref (GVariant *value);
61 GVariant * g_variant_ref_sink (GVariant *value);
62 gboolean g_variant_is_floating (GVariant *value);
63 GVariant * g_variant_take_ref (GVariant *value);
65 const GVariantType * g_variant_get_type (GVariant *value);
66 const gchar * g_variant_get_type_string (GVariant *value);
67 gboolean g_variant_is_of_type (GVariant *value,
68 const GVariantType *type);
69 gboolean g_variant_is_container (GVariant *value);
70 GVariantClass g_variant_classify (GVariant *value);
71 GVariant * g_variant_new_boolean (gboolean value);
72 GVariant * g_variant_new_byte (guchar value);
73 GVariant * g_variant_new_int16 (gint16 value);
74 GVariant * g_variant_new_uint16 (guint16 value);
75 GVariant * g_variant_new_int32 (gint32 value);
76 GVariant * g_variant_new_uint32 (guint32 value);
77 GVariant * g_variant_new_int64 (gint64 value);
78 GVariant * g_variant_new_uint64 (guint64 value);
79 GVariant * g_variant_new_handle (gint32 value);
80 GVariant * g_variant_new_double (gdouble value);
81 GVariant * g_variant_new_string (const gchar *string);
82 GVariant * g_variant_new_object_path (const gchar *object_path);
83 gboolean g_variant_is_object_path (const gchar *string);
84 GVariant * g_variant_new_signature (const gchar *signature);
85 gboolean g_variant_is_signature (const gchar *string);
86 GVariant * g_variant_new_variant (GVariant *value);
87 GVariant * g_variant_new_strv (const gchar * const *strv,
89 GVariant * g_variant_new_objv (const gchar * const *strv,
91 GVariant * g_variant_new_bytestring (const gchar *string);
92 GVariant * g_variant_new_bytestring_array (const gchar * const *strv,
94 GVariant * g_variant_new_fixed_array (const GVariantType *element_type,
95 gconstpointer elements,
98 gboolean g_variant_get_boolean (GVariant *value);
99 guchar g_variant_get_byte (GVariant *value);
100 gint16 g_variant_get_int16 (GVariant *value);
101 guint16 g_variant_get_uint16 (GVariant *value);
102 gint32 g_variant_get_int32 (GVariant *value);
103 guint32 g_variant_get_uint32 (GVariant *value);
104 gint64 g_variant_get_int64 (GVariant *value);
105 guint64 g_variant_get_uint64 (GVariant *value);
106 gint32 g_variant_get_handle (GVariant *value);
107 gdouble g_variant_get_double (GVariant *value);
108 GVariant * g_variant_get_variant (GVariant *value);
109 const gchar * g_variant_get_string (GVariant *value,
111 gchar * g_variant_dup_string (GVariant *value,
113 const gchar ** g_variant_get_strv (GVariant *value,
115 gchar ** g_variant_dup_strv (GVariant *value,
117 const gchar ** g_variant_get_objv (GVariant *value,
119 gchar ** g_variant_dup_objv (GVariant *value,
121 const gchar * g_variant_get_bytestring (GVariant *value);
122 gchar * g_variant_dup_bytestring (GVariant *value,
124 const gchar ** g_variant_get_bytestring_array (GVariant *value,
126 gchar ** g_variant_dup_bytestring_array (GVariant *value,
129 GVariant * g_variant_new_maybe (const GVariantType *child_type,
131 GVariant * g_variant_new_array (const GVariantType *child_type,
132 GVariant * const *children,
134 GVariant * g_variant_new_tuple (GVariant * const *children,
136 GVariant * g_variant_new_dict_entry (GVariant *key,
139 GVariant * g_variant_get_maybe (GVariant *value);
140 gsize g_variant_n_children (GVariant *value);
141 void g_variant_get_child (GVariant *value,
143 const gchar *format_string,
145 GVariant * g_variant_get_child_value (GVariant *value,
147 gboolean g_variant_lookup (GVariant *dictionary,
149 const gchar *format_string,
151 GVariant * g_variant_lookup_value (GVariant *dictionary,
153 const GVariantType *expected_type);
154 gconstpointer g_variant_get_fixed_array (GVariant *value,
158 gsize g_variant_get_size (GVariant *value);
159 gconstpointer g_variant_get_data (GVariant *value);
160 void g_variant_store (GVariant *value,
163 gchar * g_variant_print (GVariant *value,
164 gboolean type_annotate);
165 GString * g_variant_print_string (GVariant *value,
167 gboolean type_annotate);
169 guint g_variant_hash (gconstpointer value);
170 gboolean g_variant_equal (gconstpointer one,
173 GVariant * g_variant_get_normal_form (GVariant *value);
174 gboolean g_variant_is_normal_form (GVariant *value);
175 GVariant * g_variant_byteswap (GVariant *value);
176 GVariant * g_variant_new_from_data (const GVariantType *type,
180 GDestroyNotify notify,
183 typedef struct _GVariantIter GVariantIter;
184 struct _GVariantIter {
189 GVariantIter * g_variant_iter_new (GVariant *value);
190 gsize g_variant_iter_init (GVariantIter *iter,
192 GVariantIter * g_variant_iter_copy (GVariantIter *iter);
193 gsize g_variant_iter_n_children (GVariantIter *iter);
194 void g_variant_iter_free (GVariantIter *iter);
195 GVariant * g_variant_iter_next_value (GVariantIter *iter);
196 gboolean g_variant_iter_next (GVariantIter *iter,
197 const gchar *format_string,
199 gboolean g_variant_iter_loop (GVariantIter *iter,
200 const gchar *format_string,
204 typedef struct _GVariantBuilder GVariantBuilder;
205 struct _GVariantBuilder {
212 G_VARIANT_PARSE_ERROR_FAILED,
213 G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED,
214 G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE,
215 G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED,
216 G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END,
217 G_VARIANT_PARSE_ERROR_INVALID_CHARACTER,
218 G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING,
219 G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH,
220 G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE,
221 G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING,
222 G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE,
223 G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE,
224 G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG,
225 G_VARIANT_PARSE_ERROR_TYPE_ERROR,
226 G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN,
227 G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD,
228 G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT,
229 G_VARIANT_PARSE_ERROR_VALUE_EXPECTED
230 } GVariantParseError;
231 #define G_VARIANT_PARSE_ERROR (g_variant_parser_get_error_quark ())
233 GQuark g_variant_parser_get_error_quark (void);
235 GVariantBuilder * g_variant_builder_new (const GVariantType *type);
236 void g_variant_builder_unref (GVariantBuilder *builder);
237 GVariantBuilder * g_variant_builder_ref (GVariantBuilder *builder);
238 void g_variant_builder_init (GVariantBuilder *builder,
239 const GVariantType *type);
240 GVariant * g_variant_builder_end (GVariantBuilder *builder);
241 void g_variant_builder_clear (GVariantBuilder *builder);
242 void g_variant_builder_open (GVariantBuilder *builder,
243 const GVariantType *type);
244 void g_variant_builder_close (GVariantBuilder *builder);
245 void g_variant_builder_add_value (GVariantBuilder *builder,
247 void g_variant_builder_add (GVariantBuilder *builder,
248 const gchar *format_string,
250 void g_variant_builder_add_parsed (GVariantBuilder *builder,
254 GVariant * g_variant_new (const gchar *format_string,
256 void g_variant_get (GVariant *value,
257 const gchar *format_string,
259 GVariant * g_variant_new_va (const gchar *format_string,
260 const gchar **endptr,
262 void g_variant_get_va (GVariant *value,
263 const gchar *format_string,
264 const gchar **endptr,
268 GVariant * g_variant_parse (const GVariantType *type,
271 const gchar **endptr,
273 GVariant * g_variant_new_parsed (const gchar *format,
275 GVariant * g_variant_new_parsed_va (const gchar *format,
278 gint g_variant_compare (gconstpointer one,
282 #endif /* __G_VARIANT_H__ */