feat: introduce support for struct<->dict (de)serialization #459
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This extends the functionality of
SDBUSCPP_REGISTER_STRUCT
macro.It now provides functionality for serializing a user-defined struct as an
a{sv}
dictionary, and for deserializing ana{sv}
dictionary into a user-defined struct. The former one is achieved by decorating the struct withsdbus::as_dictionary(struct)
, the latter one is an automatic behavior -- when sdbus-c++ is asked to deserialize into a struct but the data in the message is of typea{sv}
, then the dict-to-struct deserialization is performed automatically.There are some aspects of behavior in the serialization/deserialization functionality that can be customized by the client. Newly introduced
SDBUSCPP_ENABLE_NESTED_STRUCT2DICT_SERIALIZATION
andSDBUSCPP_ENABLE_RELAXED_DICT2STRUCT_DESERIALIZATION
macros serve the purpose.Closes #397