D-Bus  1.13.7
dbus-marshal-recursive.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-marshal-recursive.h Marshalling routines for recursive types
3  *
4  * Copyright (C) 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 #ifndef DBUS_MARSHAL_RECURSIVE_H
25 #define DBUS_MARSHAL_RECURSIVE_H
26 
27 #include <dbus/dbus-protocol.h>
28 #include <dbus/dbus-list.h>
29 
30 typedef struct DBusTypeReader DBusTypeReader;
31 typedef struct DBusTypeWriter DBusTypeWriter;
34 
40 {
41  dbus_uint32_t byte_order : 8;
43  dbus_uint32_t finished : 1;
46  dbus_uint32_t array_len_offset : 3;
48  int type_pos;
50  int value_pos;
53  union
54  {
55  struct {
56  int start_pos;
57  } array;
58  } u;
59 };
60 
65 {
66  dbus_uint32_t byte_order : 8;
68  dbus_uint32_t container_type : 8;
70  dbus_uint32_t type_pos_is_expectation : 1;
72  dbus_uint32_t enabled : 1;
75  int type_pos;
77  int value_pos;
79  union
80  {
81  struct {
82  int start_pos;
83  int len_pos;
85  } array;
86  } u;
87 };
88 
94 {
96  int new_len;
97 };
98 
99 DBUS_PRIVATE_EXPORT
101  int byte_order,
102  const DBusString *type_str,
103  int type_pos,
104  const DBusString *value_str,
105  int value_pos);
106 DBUS_PRIVATE_EXPORT
108  const DBusString *type_str,
109  int type_pos);
110 DBUS_PRIVATE_EXPORT
112 DBUS_PRIVATE_EXPORT
114 DBUS_PRIVATE_EXPORT
116 DBUS_PRIVATE_EXPORT
117 void _dbus_type_reader_read_basic (const DBusTypeReader *reader,
118  void *value);
120 DBUS_PRIVATE_EXPORT
122  void *value,
123  int *n_elements);
124 void _dbus_type_reader_read_raw (const DBusTypeReader *reader,
125  const unsigned char **value_location);
126 DBUS_PRIVATE_EXPORT
128  DBusTypeReader *subreader);
129 DBUS_PRIVATE_EXPORT
132 DBUS_PRIVATE_EXPORT
134  const DBusString **str_p,
135  int *start_p,
136  int *len_p);
137 DBUS_PRIVATE_EXPORT
139  const void *value,
140  const DBusTypeReader *realign_root);
141 DBUS_PRIVATE_EXPORT
143  const DBusTypeReader *realign_root);
144 
145 dbus_bool_t _dbus_type_reader_equal_values (const DBusTypeReader *lhs,
146  const DBusTypeReader *rhs);
147 
148 void _dbus_type_signature_next (const char *signature,
149  int *type_pos);
150 
151 DBUS_PRIVATE_EXPORT
153  int byte_order,
155  int type_pos,
157  int value_pos);
159  int byte_order,
161  int value_pos);
164  int type_pos);
166 DBUS_PRIVATE_EXPORT
168  int byte_order,
169  const DBusString *type_str,
170  int type_pos,
172  int value_pos);
173 DBUS_PRIVATE_EXPORT
175  int type,
176  const void *value);
177 DBUS_PRIVATE_EXPORT
179  int element_type,
180  const void *value,
181  int n_elements);
182 DBUS_PRIVATE_EXPORT
184  int container_type,
185  const DBusString *contained_type,
186  int contained_type_start,
187  DBusTypeWriter *sub);
188 DBUS_PRIVATE_EXPORT
190  DBusTypeWriter *sub);
192  const DBusString *contained_type,
193  int contained_type_start,
194  DBusTypeWriter *sub);
195 DBUS_PRIVATE_EXPORT
197  DBusTypeReader *reader);
198 
199 
200 #endif /* DBUS_MARSHAL_RECURSIVE_H */
const DBusString * type_str
string containing signature of block
DBUS_PRIVATE_EXPORT void _dbus_type_reader_read_fixed_multi(const DBusTypeReader *reader, void *value, int *n_elements)
Reads a block of fixed-length basic values, from the current point in an array to the end of the arra...
void _dbus_type_writer_remove_types(DBusTypeWriter *writer)
Removes type string from the writer.
int start_pos
for array readers, the start of the array values
The type writer is an iterator for writing to a block of values.
DBUS_PRIVATE_EXPORT void _dbus_type_reader_recurse(DBusTypeReader *reader, DBusTypeReader *subreader)
Initialize a new reader pointing to the first type and corresponding value that&#39;s a child of the curr...
dbus_uint32_t finished
marks we&#39;re at end iterator for cases where we don&#39;t have another way to tell
int type_pos
current position in signature
void _dbus_type_signature_next(const char *signature, int *type_pos)
Skips to the next "complete" type inside a type signature.
dbus_uint32_t type_pos_is_expectation
type_pos can be either an insertion point for or an expected next type
Virtual table for a type reader.
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_type_writer_write_basic(DBusTypeWriter *writer, int type, const void *value)
Writes out a basic type.
DBUS_PRIVATE_EXPORT void _dbus_type_reader_init_types_only(DBusTypeReader *reader, const DBusString *type_str, int type_pos)
Like _dbus_type_reader_init() but the iteration is over the signature, not over values.
int new_len
the new value of the length in the written-out block
DBusString * value_str
where to write values
int type_pos
current pos in type_str
DBusString * type_str
where to write typecodes (or read type expectations)
const DBusTypeReaderClass * klass
the vtable for the reader
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_type_reader_delete(DBusTypeReader *reader, const DBusTypeReader *realign_root)
Recursively deletes any value pointed to by the reader, leaving the reader valid to continue reading...
DBUS_PRIVATE_EXPORT void _dbus_type_writer_init_values_only(DBusTypeWriter *writer, int byte_order, const DBusString *type_str, int type_pos, DBusString *value_str, int value_pos)
Like _dbus_type_writer_init(), except the type string passed in should correspond to an existing sign...
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_type_reader_set_basic(DBusTypeReader *reader, const void *value, const DBusTypeReader *realign_root)
Sets a new value for the basic type value pointed to by the reader, leaving the reader valid to conti...
void _dbus_type_writer_init_types_delayed(DBusTypeWriter *writer, int byte_order, DBusString *value_str, int value_pos)
Initialize a write iterator, with the signature to be provided later.
int element_type_pos
position of array element type in type_str
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_type_writer_unrecurse(DBusTypeWriter *writer, DBusTypeWriter *sub)
Closes a container created by _dbus_type_writer_recurse() and writes any additional information to th...
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
DBUS_PRIVATE_EXPORT void _dbus_type_reader_read_basic(const DBusTypeReader *reader, void *value)
Reads a basic-typed value, as with _dbus_marshal_read_basic().
int len_pos
position of length of the array
dbus_bool_t _dbus_type_writer_append_array(DBusTypeWriter *writer, const DBusString *contained_type, int contained_type_start, DBusTypeWriter *sub)
Append to an existing array.
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_type_reader_next(DBusTypeReader *reader)
Skip to the next value on this "level".
When modifying an existing block of values, array lengths may need to be adjusted; those adjustments ...
dbus_uint32_t enabled
whether to write values
dbus_uint32_t byte_order
byte order of the block
dbus_uint32_t byte_order
byte order to write values with
The type reader is an iterator for reading values from a block of values.
void _dbus_type_writer_add_types(DBusTypeWriter *writer, DBusString *type_str, int type_pos)
Adds type string to the writer, if it had none.
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_type_writer_write_reader(DBusTypeWriter *writer, DBusTypeReader *reader)
Iterate through all values in the given reader, writing a copy of each value to the writer...
int value_pos
next position to write
DBUS_PRIVATE_EXPORT void _dbus_type_reader_init(DBusTypeReader *reader, int byte_order, const DBusString *type_str, int type_pos, const DBusString *value_str, int value_pos)
Initializes a type reader.
union DBusTypeReader::@1 u
class-specific data
int len_pos_in_reader
where the length was in the original block
DBUS_PRIVATE_EXPORT int _dbus_type_reader_get_element_type(const DBusTypeReader *reader)
Gets the type of an element of the array the reader is currently pointing to.
DBUS_PRIVATE_EXPORT void _dbus_type_writer_init(DBusTypeWriter *writer, int byte_order, DBusString *type_str, int type_pos, DBusString *value_str, int value_pos)
Initialize a write iterator, which is used to write out values in serialized D-Bus format...
dbus_bool_t _dbus_type_reader_has_next(const DBusTypeReader *reader)
Check whether there&#39;s another value on this "level".
dbus_uint32_t container_type
what are we inside? (e.g.
int _dbus_type_reader_get_array_length(const DBusTypeReader *reader)
Returns the number of bytes in the array.
DBUS_PRIVATE_EXPORT int _dbus_type_reader_get_current_type(const DBusTypeReader *reader)
Gets the type of the value the reader is currently pointing to; or for a types-only reader gets the t...
DBUS_PRIVATE_EXPORT void _dbus_type_reader_get_signature(const DBusTypeReader *reader, const DBusString **str_p, int *start_p, int *len_p)
Gets the string and range of said string containing the signature of the current value.
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_type_writer_write_fixed_multi(DBusTypeWriter *writer, int element_type, const void *value, int n_elements)
Writes a block of fixed-length basic values, i.e.
dbus_uint32_t array_len_offset
bytes back from start_pos that len ends
int value_pos
current position in values
int start_pos
position of first element in the array
const DBusString * value_str
string containing values of block
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_type_writer_recurse(DBusTypeWriter *writer, int container_type, const DBusString *contained_type, int contained_type_start, DBusTypeWriter *sub)
Opens a new container and writes out the initial information for that container.
DBUS_PRIVATE_EXPORT int _dbus_type_reader_get_value_pos(const DBusTypeReader *reader)
Gets the current position in the value block.
void _dbus_type_reader_read_raw(const DBusTypeReader *reader, const unsigned char **value_location)
Get the address of the marshaled value in the data being read.