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

Seamlessly support non-default-constructable custom class deserialization #1087

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

mzoll
Copy link

@mzoll mzoll commented Mar 3, 2022

The current API of the convert<T>::decode construct is limited to default constructable structs with visible members only. This is limiting and does not follow RAII.

The here patch allows to declare in the custom 'struct convert' for any type T a decode method by slightly different, but more instructive, signature T convert<T>::decode(const Node& node). Within that method T can be constructed by the user from the data serialized from node and the result returned without the need to manipulate the members of an uninitialized reference. Problems in the deserialization process are marked by throwing the DecodeException, effectively replacing the old convoluted bool return signaling deserialization success.

While users are free to implement this new API the old API is still supported in static code-path switches based on the decode-signature detected.

The complete documentation is found at the bottom of docs/Tutorial.md

tests have been added and pass.

This patch closes #993
This patch also shows an alternative solution to merge request #1010

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.

custom converter for non default-constructable data-types
1 participant