d6a89b5291694438227ad01cfb19b3d758b3267e
[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, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Ryan Lortie <desrt@desrt.ca>
21  */
22
23 #ifndef __G_VARIANT_SERIALISER_H__
24 #define __G_VARIANT_SERIALISER_H__
25
26 #include "gvarianttypeinfo.h"
27
28 typedef struct
29 {
30   GVariantTypeInfo *type_info;
31   guchar           *data;
32   gsize             size;
33 } GVariantSerialised;
34
35 /* deserialisation */
36 G_GNUC_INTERNAL
37 gsize                           g_variant_serialised_n_children         (GVariantSerialised        container);
38 G_GNUC_INTERNAL
39 GVariantSerialised              g_variant_serialised_get_child          (GVariantSerialised        container,
40                                                                          gsize                     index);
41
42 /* serialisation */
43 typedef void                  (*GVariantSerialisedFiller)               (GVariantSerialised       *serialised,
44                                                                          gpointer                  data);
45
46 G_GNUC_INTERNAL
47 gsize                           g_variant_serialiser_needed_size        (GVariantTypeInfo         *info,
48                                                                          GVariantSerialisedFiller  gsv_filler,
49                                                                          const gpointer           *children,
50                                                                          gsize                     n_children);
51
52 G_GNUC_INTERNAL
53 void                            g_variant_serialiser_serialise          (GVariantSerialised        container,
54                                                                          GVariantSerialisedFiller  gsv_filler,
55                                                                          const gpointer           *children,
56                                                                          gsize                     n_children);
57
58 /* misc */
59 G_GNUC_INTERNAL
60 gboolean                        g_variant_serialised_is_normal          (GVariantSerialised        value);
61 G_GNUC_INTERNAL
62 void                            g_variant_serialised_byteswap           (GVariantSerialised        value);
63
64 /* validation of strings */
65 G_GNUC_INTERNAL
66 gboolean                        g_variant_serialiser_is_string          (gconstpointer             data,
67                                                                          gsize                     size);
68 G_GNUC_INTERNAL
69 gboolean                        g_variant_serialiser_is_object_path     (gconstpointer             data,
70                                                                          gsize                     size);
71 G_GNUC_INTERNAL
72 gboolean                        g_variant_serialiser_is_signature       (gconstpointer             data,
73                                                                          gsize                     size);
74
75 #endif /* __G_VARIANT_SERIALISER_H__ */