18 #include <type_traits>
25 #ifndef DBUSCXX_MESSAGEITERATOR_H
26 #define DBUSCXX_MESSAGEITERATOR_H
28 #if defined(__GNUC__) && (__GNUC__ <= 8)
34 #define DBUSCXX_MESSAGEITERATOR_OPERATOR_VARIANT(iter) iter.operator DBus::Variant()
35 #define DBUSCXX_MESSAGEITERATOR_OPERATOR_SIGNATURE(iter) iter.operator DBus::Signature()
36 #define DBUSCXX_MESSAGEITERATOR_OPERATOR_MULTIPLE_RETURN(iter) iter.operator DBus::MultipleReturn()
38 #define DBUSCXX_MESSAGEITERATOR_OPERATOR_VARIANT(iter) (DBus::Variant)iter
39 #define DBUSCXX_MESSAGEITERATOR_OPERATOR_SIGNATURE(iter) (DBus::Signature)iter
40 #define DBUSCXX_MESSAGEITERATOR_OPERATOR_MULTIPLE_RETURN(iter) (DBus::MultipleReturn)iter
47 template<
typename ... T>
class MultipleReturn;
70 std::shared_ptr<Demarshaling> demarshal );
152 operator std::string();
153 operator std::shared_ptr<FileDescriptor>();
156 template <
typename T>
157 operator std::vector<T>() {
167 template <
typename Key,
typename Data>
168 operator std::map<Key, Data>() {
173 return get_dict<Key, Data>();
176 template <
typename... T>
177 operator std::tuple<T...>() {
178 std::tuple<T...> tup;
183 template <
typename... T>
207 template <
typename T>
222 array.push_back( val );
226 template <
typename... T>
229 std::apply( [subiter](
auto&& ...arg )
mutable {
230 ( subiter >> ... >> arg );
235 template <
typename Key,
typename Data>
253 subSubiter >> val_key;
254 subSubiter >> val_data;
255 dict[ val_key ] = val_data;
263 template <
typename... T>
265 std::tuple<T...> tup;
266 std::apply( [
this](
auto&& ...arg )
mutable {
267 ( *
this >> ... >> arg );
274 template <
typename Key,
typename Data>
276 std::map<Key, Data> newMap;
281 template <
typename Key,
typename Data>
287 get_dict<Key, Data>( m );
292 template <
typename... T>
299 template <
typename T>
305 this->get_array<T>( v );
316 template<
typename ... T>
323 template <
typename T>
325 v =
static_cast<T
>( *this );
347 void align(
int alignment );
Extraction iterator allowing values to be retrieved from a message.
Definition: messageiterator.h:56
MessageIterator()
Definition: messageiterator.cpp:69
int64_t get_int64()
Definition: messageiterator.cpp:542
int32_t get_int32()
Definition: messageiterator.cpp:526
void get_multiplereturn(MultipleReturn< T... > &v)
Definition: messageiterator.h:264
MessageIterator & operator>>(std::map< Key, Data > &m)
Definition: messageiterator.h:282
std::shared_ptr< priv_data > m_priv
Definition: messageiterator.h:350
bool is_fixed() const
True if the element type is a fixed type.
Definition: messageiterator.cpp:186
void get_array(std::vector< T > &array)
Get values in an array, pushing them back one at a time.
Definition: messageiterator.h:208
std::string signature() const
Returns the current signature of the iterator.
Definition: messageiterator.cpp:215
MessageIterator & operator>>(Variant &v)
Definition: messageiterator.h:310
SignatureIterator signature_iterator()
Definition: messageiterator.cpp:613
MessageIterator & operator>>(std::vector< T > &v)
Definition: messageiterator.h:300
uint16_t get_uint16()
Definition: messageiterator.cpp:518
MessageIterator recurse()
If the iterator points to a container recurses into the container returning a sub-iterator.
Definition: messageiterator.cpp:204
uint32_t get_uint32()
Definition: messageiterator.cpp:534
MessageIterator & operator>>(std::tuple< T... > &v)
Definition: messageiterator.h:293
T get()
Definition: messageiterator.h:331
uint64_t get_uint64()
Definition: messageiterator.cpp:550
bool is_array() const
True if the iterator points to an array.
Definition: messageiterator.cpp:196
DataType arg_type() const
Returns the argument type that the iterator points to.
Definition: messageiterator.cpp:174
bool is_dict() const
True if the iterator points to a dictionary.
Definition: messageiterator.cpp:200
MessageIterator & operator>>(MultipleReturn< T... > &v)
Definition: messageiterator.h:317
MessageIterator & operator++()
Definition: messageiterator.cpp:157
const Message * message() const
Returns a pointer to the message associated with this iterator or NULL if no message is associated.
Definition: messageiterator.cpp:98
bool is_valid() const
True if this is a valid iterator.
Definition: messageiterator.cpp:106
void invalidate()
Invalidates the iterator.
Definition: messageiterator.cpp:102
friend class Variant
Definition: messageiterator.h:354
bool operator==(const MessageIterator &other)
Definition: messageiterator.cpp:169
double get_double()
Definition: messageiterator.cpp:558
DataType element_type() const
Returns the element type of the array that the iterator points to.
Definition: messageiterator.cpp:178
void get_struct(std::tuple< T... > &tup)
Definition: messageiterator.h:227
bool next()
Moves the iterator to the next field and invalidates it if it moves beyond the last field.
Definition: messageiterator.cpp:134
bool has_next() const
True if there are any more fields left to iterate over.
Definition: messageiterator.cpp:128
void get_dict(std::map< Key, Data > &dict)
Definition: messageiterator.h:236
std::string get_string()
Definition: messageiterator.cpp:566
bool get_bool()
Definition: messageiterator.cpp:494
bool is_container() const
True if the iterator points to a container.
Definition: messageiterator.cpp:191
void align(int alignment)
Align our memory to the specified location.
Definition: messageiterator.cpp:609
Signature get_signature()
Definition: messageiterator.cpp:605
MessageIterator & operator>>(T &v)
Definition: messageiterator.h:324
std::map< Key, Data > get_dict()
Definition: messageiterator.h:275
Variant get_variant()
Definition: messageiterator.cpp:598
std::shared_ptr< FileDescriptor > get_filedescriptor()
Definition: messageiterator.cpp:578
int16_t get_int16()
Definition: messageiterator.cpp:510
uint8_t get_uint8()
Definition: messageiterator.cpp:502
This class represents a basic DBus message and also serves as a base class for the specialized messag...
Definition: message.h:43
Definition: multiplereturn.h:29
std::tuple< Ts... > m_data
Definition: multiplereturn.h:31
A SignatureIterator allows you to iterate over a given DBus signature, and to extract useful informat...
Definition: signatureiterator.h:33
Represents a DBus signature.
Definition: signature.h:74
A Variant is a type-safe union for DBus operations.
Definition: variant.h:42
Global DBus namespace, where everything happens.
Definition: callmessage.cpp:18
DataType
Definition: enums.h:52