1Net::DBus::Binding::IteUrsaetrorC(o3n)tributed Perl DocuNmeetn:t:aDtBiuosn::Binding::Iterator(3)
2
3
4

NAME

6       Net::DBus::Binding::Iterator - Reading and writing message parameters
7

SYNOPSIS

9       Creating a new message
10
11         my $msg = new Net::DBus::Binding::Message::Signal;
12         my $iterator = $msg->iterator;
13
14         $iterator->append_boolean(1);
15         $iterator->append_byte(123);
16
17       Reading from a message
18
19         my $msg = ...get it from somewhere...
20         my $iter = $msg->iterator();
21
22         my $i = 0;
23         while ($iter->has_next()) {
24           $iter->next();
25           $i++;
26           if ($i == 1) {
27              my $val = $iter->get_boolean();
28           } elsif ($i == 2) {
29              my $val = $iter->get_byte();
30           }
31         }
32

DESCRIPTION

34       Provides an iterator for reading or writing message fields. This module
35       provides a Perl API to access the dbus_message_iter_XXX methods in the
36       C API. The array and dictionary types are not yet supported, and there
37       are bugs in the Quad support (ie it always returns -1!).
38

METHODS

40       $res = $iter->has_next()
41           Determines if there are any more fields in the message itertor to
42           be read. Returns a positive value if there are more fields, zero
43           otherwise.
44
45       $success = $iter->next()
46           Skips the iterator onto the next field in the message.  Returns a
47           positive value if the current field pointer was successfully
48           advanced, zero otherwise.
49
50       my $val = $iter->get_boolean()
51       $iter->append_boolean($val);
52           Read or write a boolean value from/to the message iterator
53
54       my $val = $iter->get_byte()
55       $iter->append_byte($val);
56           Read or write a single byte value from/to the message iterator.
57
58       my $val = $iter->get_string()
59       $iter->append_string($val);
60           Read or write a UTF-8 string value from/to the message iterator
61
62       my $val = $iter->get_object_path()
63       $iter->append_object_path($val);
64           Read or write a UTF-8 string value, whose contents is a valid
65           object path, from/to the message iterator
66
67       my $val = $iter->get_signature()
68       $iter->append_signature($val);
69           Read or write a UTF-8 string, whose contents is a valid type
70           signature, value from/to the message iterator
71
72       my $val = $iter->get_int16()
73       $iter->append_int16($val);
74           Read or write a signed 16 bit value from/to the message iterator
75
76       my $val = $iter->get_uint16()
77       $iter->append_uint16($val);
78           Read or write an unsigned 16 bit value from/to the message iterator
79
80       my $val = $iter->get_int32()
81       $iter->append_int32($val);
82           Read or write a signed 32 bit value from/to the message iterator
83
84       my $val = $iter->get_uint32()
85       $iter->append_uint32($val);
86           Read or write an unsigned 32 bit value from/to the message iterator
87
88       my $val = $iter->get_int64()
89       $iter->append_int64($val);
90           Read or write a signed 64 bit value from/to the message iterator.
91           An error will be raised if this build of Perl does not support 64
92           bit integers
93
94       my $val = $iter->get_uint64()
95       $iter->append_uint64($val);
96           Read or write an unsigned 64 bit value from/to the message
97           iterator. An error will be raised if this build of Perl does not
98           support 64 bit integers
99
100       my $val = $iter->get_double()
101       $iter->append_double($val);
102           Read or write a double precision floating point value from/to the
103           message iterator
104
105       my $val = $iter->get_unix_fd()
106       $iter->append_unix_fd($val);
107           Read or write a unix_fd value from/to the message iterator
108
109       my $value = $iter->get()
110       my $value = $iter->get($type);
111           Get the current value pointed to by this iterator. If the optional
112           $type parameter is supplied, the wire type will be compared with
113           the desired type & a warning output if their differ. The $type
114           value must be one of the "Net::DBus::Binding::Message::TYPE*"
115           constants.
116
117       my $hashref = $iter->get_dict()
118           If the iterator currently points to a dictionary value, unmarshalls
119           and returns the value as a hash reference.
120
121       my $hashref = $iter->get_array()
122           If the iterator currently points to an array value, unmarshalls and
123           returns the value as a array reference.
124
125       my $hashref = $iter->get_variant()
126           If the iterator currently points to a variant value, unmarshalls
127           and returns the value contained in the variant.
128
129       my $hashref = $iter->get_struct()
130           If the iterator currently points to an struct value, unmarshalls
131           and returns the value as a array reference. The values in the array
132           correspond to members of the struct.
133
134       $iter->append($value)
135       $iter->append($value, $type)
136           Appends a value to the message associated with this iterator. The
137           value is marshalled into wire format, according to the following
138           rules.
139
140           If the $value is an instance of Net::DBus::Binding::Value, the
141           embedded data type is used.
142
143           If the $type parameter is supplied, that is taken to represent the
144           data type. The type must be one of the
145           "Net::DBus::Binding::Message::TYPE_*" constants.
146
147           Otherwise, the data type is chosen to be a string, dict or array
148           according to the perl data types SCALAR, HASH or ARRAY.
149
150       my $type = $iter->guess_type($value)
151           Make a best guess at the on the wire data type to use for
152           marshalling $value. If the value is a hash reference, the
153           dictionary type is returned; if the value is an array reference the
154           array type is returned; otherwise the string type is returned.
155
156       my $sig = $iter->format_signature($type)
157           Given a data type representation, construct a corresponding
158           signature string
159
160       $iter->append_array($value, $type)
161           Append an array of values to the message. The $value parameter must
162           be an array reference, whose elements all have the same data type
163           specified by the $type parameter.
164
165       $iter->append_struct($value, $type)
166           Append a struct to the message. The $value parameter must be an
167           array reference, whose elements correspond to members of the
168           structure. The $type parameter encodes the type of each member of
169           the struct.
170
171       $iter->append_dict($value, $type)
172           Append a dictionary to the message. The $value parameter must be an
173           hash reference.The $type parameter encodes the type of the key and
174           value of the hash.
175
176       $iter->append_variant($value)
177           Append a value to the message, encoded as a variant type. The
178           $value can be of any type, however, the variant will be encoded as
179           either a string, dictionary or array according to the rules of the
180           "guess_type" method.
181
182       my $type = $iter->get_arg_type
183           Retrieves the type code of the value pointing to by this iterator.
184           The returned code will correspond to one of the constants
185           "Net::DBus::Binding::Message::TYPE_*"
186
187       my $type = $iter->get_element_type
188           If the iterator points to an array, retrieves the type code of
189           array elements. The returned code will correspond to one of the
190           constants "Net::DBus::Binding::Message::TYPE_*"
191

AUTHOR

193       Daniel P. Berrange
194
196       Copyright (C) 2004-2011 Daniel P. Berrange
197

SEE ALSO

199       Net::DBus::Binding::Message
200
201
202
203perl v5.32.0                      2020-07-28   Net::DBus::Binding::Iterator(3)
Impressum