spec: Remove kdbus-extension packages for _with_da_profile
[platform/upstream/glib.git] / glib / gvariant-serialiser.h
1 /*
2  * Copyright © 2007, 2008 Ryan Lortie
3  * Copyright © 2010 Codethink Limited
4  *
5  * SPDX-License-Identifier: LGPL-2.1-or-later
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
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 #include "gvariant-vectors.h"
28
29 typedef struct
30 {
31   GVariantTypeInfo *type_info;
32   guchar           *data;
33   gsize             size;
34   gsize             depth;  /* same semantics as GVariant.depth */
35
36   /* If ordered_offsets_up_to == n this means that all the frame offsets up to and
37    * including the frame offset determining the end of element n are in order.
38    * This guarantees that the bytes of element n don't overlap with any previous
39    * element.
40    *
41    * This is both read and set by g_variant_serialised_get_child() for arrays of
42    * non-fixed-width types, and for tuples.
43    *
44    * Even when dealing with tuples, @ordered_offsets_up_to is an element index,
45    * rather than an index into the frame offsets. */
46   gsize             ordered_offsets_up_to;
47
48   /* Similar to @ordered_offsets_up_to. This gives the index of the child element
49    * whose frame offset is the highest in the offset table which has been
50    * checked so far.
51    *
52    * This is always ≥ @ordered_offsets_up_to. It is always an element index.
53    *
54    * See documentation in gvariant-core.c for `struct GVariant` for details. */
55   gsize             checked_offsets_up_to;
56 } GVariantSerialised;
57
58 typedef struct
59 {
60   GVariantTypeInfo *type_info;
61   gsize             skip;
62   gsize             size;
63 } GVariantUnpacked;
64
65 /* deserialisation */
66 GLIB_AVAILABLE_IN_ALL
67 gsize                           g_variant_serialised_n_children         (GVariantSerialised        container);
68 GLIB_AVAILABLE_IN_ALL
69 GVariantSerialised              g_variant_serialised_get_child          (GVariantSerialised        container,
70                                                                          gsize                     index);
71
72 gboolean                        g_variant_serialiser_unpack_all         (GVariantTypeInfo         *type_info,
73                                                                          const guchar             *end_pointer,
74                                                                          gsize                     end_size,
75                                                                          gsize                     total_size,
76                                                                          GArray                   *unpacked_children);
77
78 /* serialisation */
79 typedef void                  (*GVariantSerialisedFiller)               (GVariantSerialised       *serialised,
80                                                                          gpointer                  data);
81
82 GLIB_AVAILABLE_IN_ALL
83 gsize                           g_variant_serialiser_needed_size        (GVariantTypeInfo         *info,
84                                                                          GVariantSerialisedFiller  gsv_filler,
85                                                                          const gpointer           *children,
86                                                                          gsize                     n_children);
87
88 GLIB_AVAILABLE_IN_ALL
89 void                            g_variant_serialiser_serialise          (GVariantSerialised        container,
90                                                                          GVariantSerialisedFiller  gsv_filler,
91                                                                          const gpointer           *children,
92                                                                          gsize                     n_children);
93
94 /* misc */
95 GLIB_AVAILABLE_IN_2_60
96 gboolean                        g_variant_serialised_check              (GVariantSerialised        serialised);
97 GLIB_AVAILABLE_IN_ALL
98 gboolean                        g_variant_serialised_is_normal          (GVariantSerialised        value);
99 GLIB_AVAILABLE_IN_ALL
100 void                            g_variant_serialised_byteswap           (GVariantSerialised        value);
101
102 /* validation of strings */
103 GLIB_AVAILABLE_IN_ALL
104 gboolean                        g_variant_serialiser_is_string          (gconstpointer             data,
105                                                                          gsize                     size);
106 GLIB_AVAILABLE_IN_ALL
107 gboolean                        g_variant_serialiser_is_object_path     (gconstpointer             data,
108                                                                          gsize                     size);
109 GLIB_AVAILABLE_IN_ALL
110 gboolean                        g_variant_serialiser_is_signature       (gconstpointer             data,
111                                                                          gsize                     size);
112
113
114 gsize                           g_variant_callback_write_to_vectors     (GVariantVectors          *vectors,
115                                                                          gpointer                  data,
116                                                                          GVariantTypeInfo        **type_info);
117 void                            g_variant_serialiser_write_to_vectors   (GVariantVectors          *items,
118                                                                          GVariantTypeInfo         *type_info,
119                                                                          gsize                     size,
120                                                                          const gpointer           *children,
121                                                                          gsize                     n_children);
122
123 #endif /* __G_VARIANT_SERIALISER_H__ */