2 * Copyright © 2007, 2008 Ryan Lortie
3 * Copyright © 2010 Codethink Limited
5 * SPDX-License-Identifier: LGPL-2.1-or-later
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.
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.
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/>.
20 * Author: Ryan Lortie <desrt@desrt.ca>
23 #ifndef __G_VARIANT_SERIALISER_H__
24 #define __G_VARIANT_SERIALISER_H__
26 #include "gvarianttypeinfo.h"
27 #include "gvariant-vectors.h"
31 GVariantTypeInfo *type_info;
34 gsize depth; /* same semantics as GVariant.depth */
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
41 * This is both read and set by g_variant_serialised_get_child() for arrays of
42 * non-fixed-width types, and for tuples.
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;
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
52 * This is always ≥ @ordered_offsets_up_to. It is always an element index.
54 * See documentation in gvariant-core.c for `struct GVariant` for details. */
55 gsize checked_offsets_up_to;
60 GVariantTypeInfo *type_info;
67 gsize g_variant_serialised_n_children (GVariantSerialised container);
69 GVariantSerialised g_variant_serialised_get_child (GVariantSerialised container,
72 gboolean g_variant_serialiser_unpack_all (GVariantTypeInfo *type_info,
73 const guchar *end_pointer,
76 GArray *unpacked_children);
79 typedef void (*GVariantSerialisedFiller) (GVariantSerialised *serialised,
83 gsize g_variant_serialiser_needed_size (GVariantTypeInfo *info,
84 GVariantSerialisedFiller gsv_filler,
85 const gpointer *children,
89 void g_variant_serialiser_serialise (GVariantSerialised container,
90 GVariantSerialisedFiller gsv_filler,
91 const gpointer *children,
95 GLIB_AVAILABLE_IN_2_60
96 gboolean g_variant_serialised_check (GVariantSerialised serialised);
98 gboolean g_variant_serialised_is_normal (GVariantSerialised value);
100 void g_variant_serialised_byteswap (GVariantSerialised value);
102 /* validation of strings */
103 GLIB_AVAILABLE_IN_ALL
104 gboolean g_variant_serialiser_is_string (gconstpointer data,
106 GLIB_AVAILABLE_IN_ALL
107 gboolean g_variant_serialiser_is_object_path (gconstpointer data,
109 GLIB_AVAILABLE_IN_ALL
110 gboolean g_variant_serialiser_is_signature (gconstpointer data,
114 gsize g_variant_callback_write_to_vectors (GVariantVectors *vectors,
116 GVariantTypeInfo **type_info);
117 void g_variant_serialiser_write_to_vectors (GVariantVectors *items,
118 GVariantTypeInfo *type_info,
120 const gpointer *children,
123 #endif /* __G_VARIANT_SERIALISER_H__ */