GVariant: add GVariantVectors utility struct
[platform/upstream/glib.git] / glib / gvariant-vectors.h
1
2 #ifndef __G_VARIANT_VECTORS_H__
3 #define __G_VARIANT_VECTORS_H__
4
5 #include <glib/garray.h>
6
7 typedef struct
8 {
9   GByteArray *extra_bytes;
10   GArray     *vectors;
11   GByteArray *offsets;
12 } GVariantVectors;
13
14
15 /* If ->bytes is NULL then offset/size point inside of extra_bytes,
16  * otherwise pointer/size point to memory owned by the GBytes.
17  */
18 typedef struct
19 {
20   GBytes *gbytes;
21   union {
22     gconstpointer pointer;
23     gsize         offset;
24   } data;
25   gsize    size;
26 } GVariantVector;
27
28 void                    g_variant_vectors_init                          (GVariantVectors *vectors);
29
30
31 gsize                   g_variant_vectors_append_pad                    (GVariantVectors *vectors,
32                                                                          gsize            padding);
33
34
35 void                    g_variant_vectors_append_copy                   (GVariantVectors *vectors,
36                                                                          gconstpointer    data,
37                                                                          gsize            size);
38
39
40 void                    g_variant_vectors_append_gbytes                 (GVariantVectors *vectors,
41                                                                          GBytes          *gbytes,
42                                                                          gconstpointer    data,
43                                                                          gsize            size);
44
45
46 gsize                   g_variant_vectors_reserve_offsets               (GVariantVectors *vectors,
47                                                                          guint            n_offsets,
48                                                                          guint            offset_size);
49
50
51 void                    g_variant_vectors_write_to_offsets              (GVariantVectors *vectors,
52                                                                          gsize            offset,
53                                                                          gsize            value,
54                                                                          gsize            offset_key);
55
56
57 void                    g_variant_vectors_commit_offsets                (GVariantVectors *vectors,
58                                                                          gsize            offset_key);
59
60 #endif /* __G_GVARIANT_VECTORS_H__ */