Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce support for struct<->dict (de)serialization #459

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

sangelovic
Copy link
Collaborator

@sangelovic sangelovic commented Oct 10, 2024

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 an a{sv} dictionary into a user-defined struct. The former one is achieved by decorating the struct with sdbus::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 type a{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 and SDBUSCPP_ENABLE_RELAXED_DICT2STRUCT_DESERIALIZATION macros serve the purpose.

Closes #397

@sangelovic sangelovic force-pushed the feat/struct-as-dict-serialization branch 2 times, most recently from e3881c7 to 264a49a Compare October 11, 2024 13:34
@sangelovic sangelovic changed the title Feat/struct as dict serialization feat: introduce support for struct-as-dict serialization Oct 11, 2024
@sangelovic sangelovic force-pushed the feat/struct-as-dict-serialization branch from 63e8f5c to 565794a Compare October 11, 2024 14:19
@sangelovic sangelovic requested a review from Oxymoron79 October 11, 2024 14:19
@sangelovic sangelovic changed the title feat: introduce support for struct-as-dict serialization feat: introduce support for struct<->dict (de)serialization Oct 11, 2024
@sangelovic sangelovic marked this pull request as ready for review October 11, 2024 15:01
@sangelovic sangelovic merged commit 02ca721 into master Nov 20, 2024
6 checks passed
@sangelovic sangelovic deleted the feat/struct-as-dict-serialization branch November 20, 2024 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serialization of maps into structs and vice versa
1 participant