Closed domcir closed 6 months ago
Hi @domcir ,
Thanks for your questions.
I would refer you to the documentation, where a lot of these questions are covered:
https://github.com/getml/reflect-cpp/tree/main/docs
But to answer your questions directly:
Yes, std::unique_ptr
and std::shared_ptr
are supported. They are treated as optional fields, though (https://github.com/getml/reflect-cpp/blob/main/docs/optional_fields.md).
No, you cannot serialize private and protected fields. This is because rfl::xxx::write
does not have access to these fields. This is something that other programming languages, like Rust or Go, would not allow you to do either. However, you can set up your classes with private fields to be supported by reflect-cpp, like this (https://github.com/getml/reflect-cpp/blob/main/docs/custom_classes.md) or this (https://github.com/getml/reflect-cpp/blob/main/docs/custom_parser.md).
No, you should not have a constructor at all. The struct should be an aggregate (https://github.com/getml/reflect-cpp/blob/main/docs/structs.md).
Thanks for the answers!
Hi Great work! Is it possible to use smart pointers on classes to be serialise? Is it possible to serialise private and protected attributes? Structs are public by default, is a public constructor necessary? Thanks Dom