Sometimes an API that you are interfacing with would be more convenient if you could pass the parameters as a struct, or perhaps you want to serialize a struct to DBus as a collection of basic types.
DBus-cxx has the ability to help you out, by letting you define custom types that you can send across the bus. Note that all types must still consist of only standard DBus types; there is no way to add another type that can be marshalled on the bus(see the dbus types page for more details on what types can be sent and received).
In order to serialize a custom type, we need three things:
ii
would be two INT32 values. This method must be named signature
in the DBus namespace.operator>>
override for the DBus::MessageIterator
classoperator<<
override for the DBus::MessageAppendIterator
classThere are some caveats with doing this:
See the examples/types folder for a complete example.