ef71831e0c43392bc9975f14a208378c1fe1ab00
[platform/upstream/dbus.git] / dbus / dbus-marshal-recursive.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-marshal-recursive.h  Marshalling routines for recursive types
3  *
4  * Copyright (C) 2004 Red Hat, Inc.
5  *
6  * Licensed under the Academic Free License version 2.1
7  * 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23
24 #ifndef DBUS_MARSHAL_RECURSIVE_H
25 #define DBUS_MARSHAL_RECURSIVE_H
26
27 #include <config.h>
28 #include <dbus/dbus-marshal-basic.h>
29
30 #ifndef PACKAGE
31 #error "config.h not included here"
32 #endif
33
34 typedef struct DBusTypeReader      DBusTypeReader;
35 typedef struct DBusTypeWriter      DBusTypeWriter;
36 typedef struct DBusTypeReaderClass DBusTypeReaderClass;
37
38 struct DBusTypeReader
39 {
40   int byte_order;
41   const DBusString *type_str;
42   int type_pos;
43   const DBusString *value_str;
44   int value_pos;
45
46   const DBusTypeReaderClass *klass;
47   union
48   {
49     struct {
50       int start_pos;
51       dbus_uint32_t len;
52       int element_type;
53     } array;
54
55     struct {
56       dbus_uint32_t finished : 1;
57     } strct;
58   } u;
59 };
60
61 struct DBusTypeWriter
62 {
63   int byte_order;
64   DBusString *type_str;
65   int type_pos;
66   DBusString *value_str;
67   int value_pos;
68
69   dbus_uint32_t type_pos_is_expectation : 1; /* type_pos is an insertion point or an expected next type */
70
71   dbus_uint32_t container_type : 8;
72   union
73   {
74     struct {
75       int start_pos; /* first element */
76       int len_pos;
77       int element_type_pos; /* position of array element type in type_str */
78     } array;
79   } u;
80 };
81
82 void        _dbus_type_reader_init                (DBusTypeReader    *reader,
83                                                    int                byte_order,
84                                                    const DBusString  *type_str,
85                                                    int                type_pos,
86                                                    const DBusString  *value_str,
87                                                    int                value_pos);
88 int         _dbus_type_reader_get_current_type    (DBusTypeReader    *reader);
89 dbus_bool_t _dbus_type_reader_array_is_empty      (DBusTypeReader    *reader);
90 void        _dbus_type_reader_read_basic          (DBusTypeReader    *reader,
91                                                    void              *value);
92 dbus_bool_t _dbus_type_reader_read_array_of_basic (DBusTypeReader    *reader,
93                                                    int                type,
94                                                    void             **array,
95                                                    int               *array_len);
96 void        _dbus_type_reader_recurse             (DBusTypeReader    *reader,
97                                                    DBusTypeReader    *subreader);
98 dbus_bool_t _dbus_type_reader_next                (DBusTypeReader    *reader);
99
100 void        _dbus_type_writer_init            (DBusTypeWriter *writer,
101                                                int             byte_order,
102                                                DBusString     *type_str,
103                                                int             type_pos,
104                                                DBusString     *value_str,
105                                                int             value_pos);
106 dbus_bool_t _dbus_type_writer_write_basic     (DBusTypeWriter *writer,
107                                                int             type,
108                                                const void     *value);
109 dbus_bool_t _dbus_type_writer_write_array     (DBusTypeWriter *writer,
110                                                int             type,
111                                                const void     *array,
112                                                int             array_len);
113 dbus_bool_t _dbus_type_writer_recurse_struct  (DBusTypeWriter *writer,
114                                                DBusTypeWriter *sub);
115 dbus_bool_t _dbus_type_writer_recurse_array   (DBusTypeWriter *writer,
116                                                const char     *element_type,
117                                                DBusTypeWriter *sub);
118 dbus_bool_t _dbus_type_writer_recurse_variant (DBusTypeWriter *writer,
119                                                const char     *contained_type,
120                                                DBusTypeWriter *sub);
121 dbus_bool_t _dbus_type_writer_unrecurse       (DBusTypeWriter *writer,
122                                                DBusTypeWriter *sub);
123
124
125
126 #endif /* DBUS_MARSHAL_RECURSIVE_H */