GVariant: support serialising to GVariantVectors
[platform/upstream/glib.git] / glib / gvariant-serialiser.h
1 /*
2  * Copyright © 2007, 2008 Ryan Lortie
3  * Copyright © 2010 Codethink Limited
4  *
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 License, or (at your option) any later version.
9  *
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.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
17  *
18  * Author: Ryan Lortie <desrt@desrt.ca>
19  */
20
21 #ifndef __G_VARIANT_SERIALISER_H__
22 #define __G_VARIANT_SERIALISER_H__
23
24 #include "gvarianttypeinfo.h"
25 #include "gvariant-vectors.h"
26
27 typedef struct
28 {
29   GVariantTypeInfo *type_info;
30   guchar           *data;
31   gsize             size;
32 } GVariantSerialised;
33
34 /* deserialisation */
35 GLIB_AVAILABLE_IN_ALL
36 gsize                           g_variant_serialised_n_children         (GVariantSerialised        container);
37 GLIB_AVAILABLE_IN_ALL
38 GVariantSerialised              g_variant_serialised_get_child          (GVariantSerialised        container,
39                                                                          gsize                     index);
40
41 /* serialisation */
42 typedef void                  (*GVariantSerialisedFiller)               (GVariantSerialised       *serialised,
43                                                                          gpointer                  data);
44
45 GLIB_AVAILABLE_IN_ALL
46 gsize                           g_variant_serialiser_needed_size        (GVariantTypeInfo         *info,
47                                                                          GVariantSerialisedFiller  gsv_filler,
48                                                                          const gpointer           *children,
49                                                                          gsize                     n_children);
50
51 GLIB_AVAILABLE_IN_ALL
52 void                            g_variant_serialiser_serialise          (GVariantSerialised        container,
53                                                                          GVariantSerialisedFiller  gsv_filler,
54                                                                          const gpointer           *children,
55                                                                          gsize                     n_children);
56
57 /* misc */
58 GLIB_AVAILABLE_IN_ALL
59 gboolean                        g_variant_serialised_is_normal          (GVariantSerialised        value);
60 GLIB_AVAILABLE_IN_ALL
61 void                            g_variant_serialised_byteswap           (GVariantSerialised        value);
62
63 /* validation of strings */
64 GLIB_AVAILABLE_IN_ALL
65 gboolean                        g_variant_serialiser_is_string          (gconstpointer             data,
66                                                                          gsize                     size);
67 GLIB_AVAILABLE_IN_ALL
68 gboolean                        g_variant_serialiser_is_object_path     (gconstpointer             data,
69                                                                          gsize                     size);
70 GLIB_AVAILABLE_IN_ALL
71 gboolean                        g_variant_serialiser_is_signature       (gconstpointer             data,
72                                                                          gsize                     size);
73
74
75 gsize                           g_variant_callback_write_to_vectors     (GVariantVectors          *vectors,
76                                                                          gpointer                  data,
77                                                                          GVariantTypeInfo        **type_info);
78 void                            g_variant_serialiser_write_to_vectors   (GVariantVectors          *items,
79                                                                          GVariantTypeInfo         *type_info,
80                                                                          gsize                     size,
81                                                                          const gpointer           *children,
82                                                                          gsize                     n_children);
83
84 #endif /* __G_VARIANT_SERIALISER_H__ */