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);
64 const GVariantType * g_variant_get_type (GVariant *value);
65 const gchar * g_variant_get_type_string (GVariant *value);
66 gboolean g_variant_is_of_type (GVariant *value,
67 const GVariantType *type);
68 gboolean g_variant_is_container (GVariant *value);
69 GVariantClass g_variant_classify (GVariant *value);
70 GVariant * g_variant_new_boolean (gboolean boolean);
71 GVariant * g_variant_new_byte (guchar byte);
72 GVariant * g_variant_new_int16 (gint16 int16);
73 GVariant * g_variant_new_uint16 (guint16 uint16);
74 GVariant * g_variant_new_int32 (gint32 int32);
75 GVariant * g_variant_new_uint32 (guint32 uint32);
76 GVariant * g_variant_new_int64 (gint64 int64);
77 GVariant * g_variant_new_uint64 (guint64 uint64);
78 GVariant * g_variant_new_handle (gint32 handle);
79 GVariant * g_variant_new_double (gdouble floating);
80 GVariant * g_variant_new_string (const gchar *string);
81 GVariant * g_variant_new_object_path (const gchar *object_path);
82 gboolean g_variant_is_object_path (const gchar *string);
83 GVariant * g_variant_new_signature (const gchar *signature);
84 gboolean g_variant_is_signature (const gchar *string);
85 GVariant * g_variant_new_variant (GVariant *value);
86 GVariant * g_variant_new_strv (const gchar * const *strv,
88 GVariant * g_variant_new_bytestring (const gchar *string);
89 GVariant * g_variant_new_bytestring_array (const gchar * const *strv,
92 gboolean g_variant_get_boolean (GVariant *value);
93 guchar g_variant_get_byte (GVariant *value);
94 gint16 g_variant_get_int16 (GVariant *value);
95 guint16 g_variant_get_uint16 (GVariant *value);
96 gint32 g_variant_get_int32 (GVariant *value);
97 guint32 g_variant_get_uint32 (GVariant *value);
98 gint64 g_variant_get_int64 (GVariant *value);
99 guint64 g_variant_get_uint64 (GVariant *value);
100 gint32 g_variant_get_handle (GVariant *value);
101 gdouble g_variant_get_double (GVariant *value);
102 GVariant * g_variant_get_variant (GVariant *value);
103 const gchar * g_variant_get_string (GVariant *value,
105 gchar * g_variant_dup_string (GVariant *value,
107 const gchar ** g_variant_get_strv (GVariant *value,
109 gchar ** g_variant_dup_strv (GVariant *value,
111 const gchar * g_variant_get_bytestring (GVariant *value);
112 gchar * g_variant_dup_bytestring (GVariant *value,
114 const gchar ** g_variant_get_bytestring_array (GVariant *value,
116 gchar ** g_variant_dup_bytestring_array (GVariant *value,
119 GVariant * g_variant_new_maybe (const GVariantType *child_type,
121 GVariant * g_variant_new_array (const GVariantType *child_type,
122 GVariant * const *children,
124 GVariant * g_variant_new_tuple (GVariant * const *children,
126 GVariant * g_variant_new_dict_entry (GVariant *key,
129 GVariant * g_variant_get_maybe (GVariant *value);
130 gsize g_variant_n_children (GVariant *value);
131 void g_variant_get_child (GVariant *value,
133 const gchar *format_string,
135 GVariant * g_variant_get_child_value (GVariant *value,
137 gboolean g_variant_lookup (GVariant *value,
139 const gchar *format_string,
141 GVariant * g_variant_lookup_value (GVariant *value,
143 const GVariantType *type);
144 gconstpointer g_variant_get_fixed_array (GVariant *value,
148 gsize g_variant_get_size (GVariant *value);
149 gconstpointer g_variant_get_data (GVariant *value);
150 void g_variant_store (GVariant *value,
153 gchar * g_variant_print (GVariant *value,
154 gboolean type_annotate);
155 GString * g_variant_print_string (GVariant *value,
157 gboolean type_annotate);
159 guint g_variant_hash (gconstpointer value);
160 gboolean g_variant_equal (gconstpointer one,
163 GVariant * g_variant_get_normal_form (GVariant *value);
164 gboolean g_variant_is_normal_form (GVariant *value);
165 GVariant * g_variant_byteswap (GVariant *value);
166 GVariant * g_variant_new_from_data (const GVariantType *type,
170 GDestroyNotify notify,
173 typedef struct _GVariantIter GVariantIter;
174 struct _GVariantIter {
179 GVariantIter * g_variant_iter_new (GVariant *value);
180 gsize g_variant_iter_init (GVariantIter *iter,
182 GVariantIter * g_variant_iter_copy (GVariantIter *iter);
183 gsize g_variant_iter_n_children (GVariantIter *iter);
184 void g_variant_iter_free (GVariantIter *iter);
185 GVariant * g_variant_iter_next_value (GVariantIter *iter);
186 gboolean g_variant_iter_next (GVariantIter *iter,
187 const gchar *format_string,
189 gboolean g_variant_iter_loop (GVariantIter *iter,
190 const gchar *format_string,
194 typedef struct _GVariantBuilder GVariantBuilder;
195 struct _GVariantBuilder {
202 G_VARIANT_PARSE_ERROR_FAILED
203 } GVariantParseError;
204 #define G_VARIANT_PARSE_ERROR (g_variant_parser_get_error_quark ())
206 GQuark g_variant_parser_get_error_quark (void);
208 GVariantBuilder * g_variant_builder_new (const GVariantType *type);
209 void g_variant_builder_unref (GVariantBuilder *builder);
210 GVariantBuilder * g_variant_builder_ref (GVariantBuilder *builder);
211 void g_variant_builder_init (GVariantBuilder *builder,
212 const GVariantType *type);
213 GVariant * g_variant_builder_end (GVariantBuilder *builder);
214 void g_variant_builder_clear (GVariantBuilder *builder);
215 void g_variant_builder_open (GVariantBuilder *builder,
216 const GVariantType *type);
217 void g_variant_builder_close (GVariantBuilder *builder);
218 void g_variant_builder_add_value (GVariantBuilder *builder,
220 void g_variant_builder_add (GVariantBuilder *builder,
221 const gchar *format_string,
223 void g_variant_builder_add_parsed (GVariantBuilder *builder,
227 GVariant * g_variant_new (const gchar *format_string,
229 void g_variant_get (GVariant *value,
230 const gchar *format_string,
232 GVariant * g_variant_new_va (const gchar *format_string,
233 const gchar **endptr,
235 void g_variant_get_va (GVariant *value,
236 const gchar *format_string,
237 const gchar **endptr,
241 GVariant * g_variant_parse (const GVariantType *type,
244 const gchar **endptr,
246 GVariant * g_variant_new_parsed (const gchar *format,
248 GVariant * g_variant_new_parsed_va (const gchar *format,
251 gint g_variant_compare (gconstpointer one,
255 #endif /* __G_VARIANT_H__ */