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_H__
24 #define __G_VARIANT_H__
26 #include <glib/gvarianttype.h>
27 #include <glib/gstring.h>
31 typedef struct _GVariant GVariant;
35 G_VARIANT_CLASS_BOOLEAN = 'b',
36 G_VARIANT_CLASS_BYTE = 'y',
37 G_VARIANT_CLASS_INT16 = 'n',
38 G_VARIANT_CLASS_UINT16 = 'q',
39 G_VARIANT_CLASS_INT32 = 'i',
40 G_VARIANT_CLASS_UINT32 = 'u',
41 G_VARIANT_CLASS_INT64 = 'x',
42 G_VARIANT_CLASS_UINT64 = 't',
43 G_VARIANT_CLASS_HANDLE = 'h',
44 G_VARIANT_CLASS_DOUBLE = 'd',
45 G_VARIANT_CLASS_STRING = 's',
46 G_VARIANT_CLASS_OBJECT_PATH = 'o',
47 G_VARIANT_CLASS_SIGNATURE = 'g',
48 G_VARIANT_CLASS_VARIANT = 'v',
49 G_VARIANT_CLASS_MAYBE = 'm',
50 G_VARIANT_CLASS_ARRAY = 'a',
51 G_VARIANT_CLASS_TUPLE = '(',
52 G_VARIANT_CLASS_DICT_ENTRY = '{'
55 void g_variant_unref (GVariant *value);
56 GVariant * g_variant_ref (GVariant *value);
57 GVariant * g_variant_ref_sink (GVariant *value);
59 const GVariantType * g_variant_get_type (GVariant *value);
60 const gchar * g_variant_get_type_string (GVariant *value);
61 gboolean g_variant_is_of_type (GVariant *value,
62 const GVariantType *type);
63 gboolean g_variant_is_container (GVariant *value);
64 GVariantClass g_variant_classify (GVariant *value);
66 GVariant * g_variant_new_boolean (gboolean boolean);
67 GVariant * g_variant_new_byte (guchar byte);
68 GVariant * g_variant_new_int16 (gint16 int16);
69 GVariant * g_variant_new_uint16 (guint16 uint16);
70 GVariant * g_variant_new_int32 (gint32 int32);
71 GVariant * g_variant_new_uint32 (guint32 uint32);
72 GVariant * g_variant_new_int64 (gint64 int64);
73 GVariant * g_variant_new_uint64 (guint64 uint64);
74 GVariant * g_variant_new_handle (gint32 handle);
75 GVariant * g_variant_new_double (gdouble floating);
76 GVariant * g_variant_new_string (const gchar *string);
77 GVariant * g_variant_new_object_path (const gchar *object_path);
78 gboolean g_variant_is_object_path (const gchar *string);
79 GVariant * g_variant_new_signature (const gchar *signature);
80 gboolean g_variant_is_signature (const gchar *string);
81 GVariant * g_variant_new_variant (GVariant *value);
82 GVariant * g_variant_new_strv (const gchar * const *strv,
85 gboolean g_variant_get_boolean (GVariant *value);
86 guchar g_variant_get_byte (GVariant *value);
87 gint16 g_variant_get_int16 (GVariant *value);
88 guint16 g_variant_get_uint16 (GVariant *value);
89 gint32 g_variant_get_int32 (GVariant *value);
90 guint32 g_variant_get_uint32 (GVariant *value);
91 gint64 g_variant_get_int64 (GVariant *value);
92 guint64 g_variant_get_uint64 (GVariant *value);
93 gint32 g_variant_get_handle (GVariant *value);
94 gdouble g_variant_get_double (GVariant *value);
95 GVariant * g_variant_get_variant (GVariant *value);
96 const gchar * g_variant_get_string (GVariant *value,
98 gchar * g_variant_dup_string (GVariant *value,
100 const gchar ** g_variant_get_strv (GVariant *value,
102 gchar ** g_variant_dup_strv (GVariant *value,
105 GVariant * g_variant_new_maybe (const GVariantType *child_type,
107 GVariant * g_variant_new_array (const GVariantType *child_type,
108 GVariant * const *children,
110 GVariant * g_variant_new_tuple (GVariant * const *children,
112 GVariant * g_variant_new_dict_entry (GVariant *key,
115 GVariant * g_variant_get_maybe (GVariant *value);
116 gsize g_variant_n_children (GVariant *value);
117 GVariant * g_variant_get_child_value (GVariant *value,
119 gconstpointer g_variant_get_fixed_array (GVariant *value,
123 gsize g_variant_get_size (GVariant *value);
124 gconstpointer g_variant_get_data (GVariant *value);
125 void g_variant_store (GVariant *value,
128 gchar * g_variant_print (GVariant *value,
129 gboolean type_annotate);
130 GString * g_variant_print_string (GVariant *value,
132 gboolean type_annotate);
134 guint g_variant_hash (gconstpointer value);
135 gboolean g_variant_equal (gconstpointer one,
138 typedef struct _GVariantIter GVariantIter;
139 struct _GVariantIter {
144 GVariantIter * g_variant_iter_new (GVariant *value);
145 gsize g_variant_iter_init (GVariantIter *iter,
147 GVariantIter * g_variant_iter_copy (GVariantIter *iter);
148 gsize g_variant_iter_n_children (GVariantIter *iter);
149 void g_variant_iter_free (GVariantIter *iter);
150 GVariant * g_variant_iter_next_value (GVariantIter *iter);
151 gboolean g_variant_iter_next (GVariantIter *iter,
152 const gchar *format_string,
154 gboolean g_variant_iter_loop (GVariantIter *iter,
155 const gchar *format_string,
159 typedef struct _GVariantBuilder GVariantBuilder;
160 struct _GVariantBuilder {
165 GVariantBuilder * g_variant_builder_new (const GVariantType *type);
166 void g_variant_builder_unref (GVariantBuilder *builder);
167 GVariantBuilder * g_variant_builder_ref (GVariantBuilder *builder);
168 void g_variant_builder_init (GVariantBuilder *builder,
169 const GVariantType *type);
170 GVariant * g_variant_builder_end (GVariantBuilder *builder);
171 void g_variant_builder_clear (GVariantBuilder *builder);
172 void g_variant_builder_open (GVariantBuilder *builder,
173 const GVariantType *type);
174 void g_variant_builder_close (GVariantBuilder *builder);
175 void g_variant_builder_add_value (GVariantBuilder *builder,
177 void g_variant_builder_add (GVariantBuilder *builder,
178 const gchar *format_string,
183 #endif /* __G_VARIANT_H__ */