1 /*
2  * Distributed under the Boost Software License, Version 1.0.
3  *    (See accompanying file LICENSE_1_0.txt or copy at
4  *          http://www.boost.org/LICENSE_1_0.txt)
5  */
6 module glib.gvariant;
7 
8 import glib.gtypes;
9 import glib.gvarianttype;
10 import glib.gstring;
11 import glib.gbytes;
12 import glib.gquark;
13 import glib.garray;
14 import glib.gerror;
15 
16 import core.stdc.stdarg;
17 
18 struct GVariant;
19 
20 enum GVariantClass
21 {
22   G_VARIANT_CLASS_BOOLEAN       = 'b',
23   G_VARIANT_CLASS_BYTE          = 'y',
24   G_VARIANT_CLASS_INT16         = 'n',
25   G_VARIANT_CLASS_UINT16        = 'q',
26   G_VARIANT_CLASS_INT32         = 'i',
27   G_VARIANT_CLASS_UINT32        = 'u',
28   G_VARIANT_CLASS_INT64         = 'x',
29   G_VARIANT_CLASS_UINT64        = 't',
30   G_VARIANT_CLASS_HANDLE        = 'h',
31   G_VARIANT_CLASS_DOUBLE        = 'd',
32   G_VARIANT_CLASS_STRING        = 's',
33   G_VARIANT_CLASS_OBJECT_PATH   = 'o',
34   G_VARIANT_CLASS_SIGNATURE     = 'g',
35   G_VARIANT_CLASS_VARIANT       = 'v',
36   G_VARIANT_CLASS_MAYBE         = 'm',
37   G_VARIANT_CLASS_ARRAY         = 'a',
38   G_VARIANT_CLASS_TUPLE         = '(',
39   G_VARIANT_CLASS_DICT_ENTRY    = '{'
40 }
41 
42 struct GVariantIter {
43   /*< private >*/
44   gsize[16] x;
45 }
46 
47 
48 struct GVariantBuilder {
49   /*< private >*/
50   gsize[16] x;
51 }
52 
53 enum GVariantParseError
54 {
55   G_VARIANT_PARSE_ERROR_FAILED,
56   G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED,
57   G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE,
58   G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED,
59   G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END,
60   G_VARIANT_PARSE_ERROR_INVALID_CHARACTER,
61   G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING,
62   G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH,
63   G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE,
64   G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING,
65   G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE,
66   G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE,
67   G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG,
68   G_VARIANT_PARSE_ERROR_TYPE_ERROR,
69   G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN,
70   G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD,
71   G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT,
72   G_VARIANT_PARSE_ERROR_VALUE_EXPECTED
73 }
74 
75 //enum G_VARIANT_PARSE_ERROR = g_variant_parse_error_quark ();
76 
77 struct GVariantDict {
78   /*< private >*/
79   gsize[16] x;
80 }
81 
82 extern (C) {
83 
84 
85     void                            g_variant_unref                         (GVariant             *value);
86 
87     GVariant *                      g_variant_ref                           (GVariant             *value);
88 
89     GVariant *                      g_variant_ref_sink                      (GVariant             *value);
90 
91     gboolean                        g_variant_is_floating                   (GVariant             *value);
92 
93     GVariant *                      g_variant_take_ref                      (GVariant             *value);
94 
95 
96     const(GVariantType) *            g_variant_get_type                      (GVariant             *value);
97 
98     const(gchar) *                   g_variant_get_type_string               (GVariant             *value);
99 
100     gboolean                        g_variant_is_of_type                    (GVariant             *value,
101                                                                              const(GVariantType)   *type);
102 
103     gboolean                        g_variant_is_container                  (GVariant             *value);
104 
105     GVariantClass                   g_variant_classify                      (GVariant             *value);
106 
107     GVariant *                      g_variant_new_boolean                   (gboolean              value);
108 
109     GVariant *                      g_variant_new_byte                      (guchar                value);
110 
111     GVariant *                      g_variant_new_int16                     (gint16                value);
112 
113     GVariant *                      g_variant_new_uint16                    (guint16               value);
114 
115     GVariant *                      g_variant_new_int32                     (gint32                value);
116 
117     GVariant *                      g_variant_new_uint32                    (guint32               value);
118 
119     GVariant *                      g_variant_new_int64                     (gint64                value);
120 
121     GVariant *                      g_variant_new_uint64                    (guint64               value);
122 
123     GVariant *                      g_variant_new_handle                    (gint32                value);
124 
125     GVariant *                      g_variant_new_double                    (gdouble               value);
126 
127     GVariant *                      g_variant_new_string                    (const(gchar)          *str);
128 
129     GVariant *                      g_variant_new_take_string               (gchar                *str);
130 
131     GVariant *                      g_variant_new_printf                    (const(gchar) *format_string, ...);
132 
133     GVariant *                      g_variant_new_object_path               (const(gchar)          *object_path);
134 
135     gboolean                        g_variant_is_object_path                (const(gchar)          *str);
136 
137     GVariant *                      g_variant_new_signature                 (const(gchar)          *signature);
138 
139     gboolean                        g_variant_is_signature                  (const(gchar)          *str);
140 
141     GVariant *                      g_variant_new_variant                   (GVariant             *value);
142 
143     GVariant *                      g_variant_new_strv                      (const(gchar*)  *strv,
144                                                                              gssize                length);
145 
146     GVariant *                      g_variant_new_objv                      (const(gchar*)  *strv,
147                                                                              gssize                length);
148 
149     GVariant *                      g_variant_new_bytestring                (const(gchar)          *str);
150 
151     GVariant *                      g_variant_new_bytestring_array          (const(gchar*) *strv,
152                                                                              gssize                length);
153 
154     GVariant *                      g_variant_new_fixed_array               (const(GVariantType)   *element_type,
155                                                                              gconstpointer         elements,
156                                                                              gsize                 n_elements,
157                                                                              gsize                 element_size);
158 
159     gboolean                        g_variant_get_boolean                   (GVariant             *value);
160 
161     guchar                          g_variant_get_byte                      (GVariant             *value);
162 
163     gint16                          g_variant_get_int16                     (GVariant             *value);
164 
165     guint16                         g_variant_get_uint16                    (GVariant             *value);
166 
167     gint32                          g_variant_get_int32                     (GVariant             *value);
168 
169     guint32                         g_variant_get_uint32                    (GVariant             *value);
170 
171     gint64                          g_variant_get_int64                     (GVariant             *value);
172 
173     guint64                         g_variant_get_uint64                    (GVariant             *value);
174 
175     gint32                          g_variant_get_handle                    (GVariant             *value);
176 
177     gdouble                         g_variant_get_double                    (GVariant             *value);
178 
179     GVariant *                      g_variant_get_variant                   (GVariant             *value);
180 
181     const(gchar) *                   g_variant_get_string                    (GVariant             *value,
182                                                                              gsize                *length);
183 
184     gchar *                         g_variant_dup_string                    (GVariant             *value,
185                                                                              gsize                *length);
186 
187     const(gchar) **                  g_variant_get_strv                      (GVariant             *value,
188                                                                              gsize                *length);
189 
190     gchar **                        g_variant_dup_strv                      (GVariant             *value,
191                                                                              gsize                *length);
192 
193     const(gchar) **                  g_variant_get_objv                      (GVariant             *value,
194                                                                              gsize                *length);
195 
196     gchar **                        g_variant_dup_objv                      (GVariant             *value,
197                                                                              gsize                *length);
198 
199     const(gchar) *                   g_variant_get_bytestring                (GVariant             *value);
200 
201     gchar *                         g_variant_dup_bytestring                (GVariant             *value,
202                                                                              gsize                *length);
203 
204     const(gchar) **                  g_variant_get_bytestring_array          (GVariant             *value,
205                                                                              gsize                *length);
206 
207     gchar **                        g_variant_dup_bytestring_array          (GVariant             *value,
208                                                                              gsize                *length);
209 
210 
211     GVariant *                      g_variant_new_maybe                     (const(GVariantType)   *child_type,
212                                                                              GVariant             *child);
213 
214     GVariant *                      g_variant_new_array                     (const(GVariantType)   *child_type,
215                                                                              GVariant **children,
216                                                                              gsize                 n_children);
217 
218     GVariant *                      g_variant_new_tuple                     (GVariant **children,
219                                                                              gsize                 n_children);
220 
221     GVariant *                      g_variant_new_dict_entry                (GVariant             *key,
222                                                                              GVariant             *value);
223 
224 
225     GVariant *                      g_variant_get_maybe                     (GVariant             *value);
226 
227     gsize                           g_variant_n_children                    (GVariant             *value);
228 
229     void                            g_variant_get_child                     (GVariant             *value,
230                                                                              gsize                 index_,
231                                                                              const(gchar)          *format_string,
232                                                                              ...);
233 
234     GVariant *                      g_variant_get_child_value               (GVariant             *value,
235                                                                              gsize                 index_);
236 
237     gboolean                        g_variant_lookup                        (GVariant             *dictionary,
238                                                                              const(gchar)          *key,
239                                                                              const(gchar)          *format_string,
240                                                                              ...);
241 
242     GVariant *                      g_variant_lookup_value                  (GVariant             *dictionary,
243                                                                              const(gchar)          *key,
244                                                                              const(GVariantType)   *expected_type);
245 
246     gconstpointer                   g_variant_get_fixed_array               (GVariant             *value,
247                                                                              gsize                *n_elements,
248                                                                              gsize                 element_size);
249 
250 
251     gsize                           g_variant_get_size                      (GVariant             *value);
252 
253     gconstpointer                   g_variant_get_data                      (GVariant             *value);
254 
255     GBytes *                        g_variant_get_data_as_bytes             (GVariant             *value);
256 
257     void                            g_variant_store                         (GVariant             *value,
258                                                                              gpointer              data);
259 
260 
261     gchar *                         g_variant_print                         (GVariant             *value,
262                                                                              gboolean              type_annotate);
263 
264     GString *                       g_variant_print_string                  (GVariant             *value,
265                                                                              GString              *str,
266                                                                              gboolean              type_annotate);
267 
268 
269     guint                           g_variant_hash                          (gconstpointer         value);
270 
271     gboolean                        g_variant_equal                         (gconstpointer         one,
272                                                                              gconstpointer         two);
273 
274 
275     GVariant *                      g_variant_get_normal_form               (GVariant             *value);
276 
277     gboolean                        g_variant_is_normal_form                (GVariant             *value);
278 
279     GVariant *                      g_variant_byteswap                      (GVariant             *value);
280 
281 
282     GVariant *                      g_variant_new_from_bytes                (const(GVariantType)   *type,
283                                                                              GBytes               *bytes,
284                                                                              gboolean              trusted);
285 
286     GVariant *                      g_variant_new_from_data                 (const(GVariantType)   *type,
287                                                                              gconstpointer         data,
288                                                                              gsize                 size,
289                                                                              gboolean              trusted,
290                                                                              GDestroyNotify        notify,
291                                                                              gpointer              user_data);
292 
293 
294     GVariantIter *                  g_variant_iter_new                      (GVariant             *value);
295 
296     gsize                           g_variant_iter_init                     (GVariantIter         *iter,
297                                                                              GVariant             *value);
298 
299     GVariantIter *                  g_variant_iter_copy                     (GVariantIter         *iter);
300 
301     gsize                           g_variant_iter_n_children               (GVariantIter         *iter);
302 
303     void                            g_variant_iter_free                     (GVariantIter         *iter);
304 
305     GVariant *                      g_variant_iter_next_value               (GVariantIter         *iter);
306 
307     gboolean                        g_variant_iter_next                     (GVariantIter         *iter,
308                                                                              const(gchar)          *format_string,
309                                                                              ...);
310 
311     gboolean                        g_variant_iter_loop                     (GVariantIter         *iter,
312                                                                              const(gchar)          *format_string,
313                                                                              ...);
314 
315 
316 
317     GQuark                          g_variant_parse_error_quark             ();
318 
319 
320     GVariantBuilder *               g_variant_builder_new                   (const(GVariantType)   *type);
321 
322     void                            g_variant_builder_unref                 (GVariantBuilder      *builder);
323 
324     GVariantBuilder *               g_variant_builder_ref                   (GVariantBuilder      *builder);
325 
326     void                            g_variant_builder_init                  (GVariantBuilder      *builder,
327                                                                              const(GVariantType)   *type);
328 
329     GVariant *                      g_variant_builder_end                   (GVariantBuilder      *builder);
330 
331     void                            g_variant_builder_clear                 (GVariantBuilder      *builder);
332 
333     void                            g_variant_builder_open                  (GVariantBuilder      *builder,
334                                                                              const(GVariantType)   *type);
335 
336     void                            g_variant_builder_close                 (GVariantBuilder      *builder);
337 
338     void                            g_variant_builder_add_value             (GVariantBuilder      *builder,
339                                                                              GVariant             *value);
340 
341     void                            g_variant_builder_add                   (GVariantBuilder      *builder,
342                                                                              const(gchar)          *format_string,
343                                                                              ...);
344 
345     void                            g_variant_builder_add_parsed            (GVariantBuilder      *builder,
346                                                                              const(gchar)          *format,
347                                                                              ...);
348 
349 
350     GVariant *                      g_variant_new                           (const(gchar)          *format_string,
351                                                                              ...);
352 
353     void                            g_variant_get                           (GVariant             *value,
354                                                                              const(gchar)          *format_string,
355                                                                              ...);
356 
357     GVariant *                      g_variant_new_va                        (const(gchar)          *format_string,
358                                                                              const(gchar)         **endptr,
359                                                                              va_list              *app);
360 
361     void                            g_variant_get_va                        (GVariant             *value,
362                                                                              const(gchar)          *format_string,
363                                                                              const(gchar)         **endptr,
364                                                                              va_list              *app);
365 
366     gboolean                        g_variant_check_format_string           (GVariant             *value,
367                                                                              const(gchar)          *format_string,
368                                                                              gboolean              copy_only);
369 
370 
371     GVariant *                      g_variant_parse                         (const(GVariantType)   *type,
372                                                                              const(gchar)          *text,
373                                                                              const(gchar)          *limit,
374                                                                              const(gchar)         **endptr,
375                                                                              GError              **error);
376 
377     GVariant *                      g_variant_new_parsed                    (const(gchar)          *format,
378                                                                              ...);
379 
380     GVariant *                      g_variant_new_parsed_va                 (const(gchar)          *format,
381                                                                              va_list              *app);
382 
383 
384     gchar *                         g_variant_parse_error_print_context     (GError               *error,
385                                                                              const(gchar)          *source_str);
386 
387 
388     gint                            g_variant_compare                       (gconstpointer one,
389                                                                              gconstpointer two);
390 
391 
392     GVariantDict *                  g_variant_dict_new                      (GVariant             *from_asv);
393 
394 
395     void                            g_variant_dict_init                     (GVariantDict         *dict,
396                                                                              GVariant             *from_asv);
397 
398 
399     gboolean                        g_variant_dict_lookup                   (GVariantDict         *dict,
400                                                                              const(gchar)          *key,
401                                                                              const(gchar)          *format_string,
402                                                                              ...);
403 
404     GVariant *                      g_variant_dict_lookup_value             (GVariantDict         *dict,
405                                                                              const(gchar)          *key,
406                                                                              const(GVariantType)   *expected_type);
407 
408     gboolean                        g_variant_dict_contains                 (GVariantDict         *dict,
409                                                                              const(gchar)          *key);
410 
411     void                            g_variant_dict_insert                   (GVariantDict         *dict,
412                                                                              const(gchar)          *key,
413                                                                              const(gchar)          *format_string,
414                                                                              ...);
415 
416     void                            g_variant_dict_insert_value             (GVariantDict         *dict,
417                                                                              const(gchar)          *key,
418                                                                              GVariant             *value);
419 
420     gboolean                        g_variant_dict_remove                   (GVariantDict         *dict,
421                                                                              const(gchar)          *key);
422 
423     void                            g_variant_dict_clear                    (GVariantDict         *dict);
424 
425     GVariant *                      g_variant_dict_end                      (GVariantDict         *dict);
426 
427     GVariantDict *                  g_variant_dict_ref                      (GVariantDict         *dict);
428 
429     void                            g_variant_dict_unref                    (GVariantDict         *dict);
430 
431 }
432