-
Notifications
You must be signed in to change notification settings - Fork 300
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 formats: automatic serialization/deserialization based on Boost.PFR #472
base: develop
Are you sure you want to change the base?
feat formats: automatic serialization/deserialization based on Boost.PFR #472
Conversation
universal/include/userver/formats/universal/common_containers.hpp
Outdated
Show resolved
Hide resolved
universal/include/userver/formats/universal/common_containers.hpp
Outdated
Show resolved
Hide resolved
universal/include/userver/formats/universal/common_containers.hpp
Outdated
Show resolved
Hide resolved
template <> | ||
struct FieldConfig<int> { | ||
std::optional<Max<int>> Maximum; | ||
std::optional<Min<int>> Minimum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes it's desired to have a JSON field with a C++-reserved name, e.g. "default"
. In this case we should choose an alternative field name, e.g. default_value
, and override the JSON name for the field. For this we need std::optional<std::string_view> Name
for every single-field FieldConfig
. Not applicable to maps with their Additional
universal/include/userver/formats/universal/common_containers.hpp
Outdated
Show resolved
Hide resolved
universal/include/userver/formats/universal/common_containers.hpp
Outdated
Show resolved
Hide resolved
universal/include/userver/formats/universal/common_containers.hpp
Outdated
Show resolved
Hide resolved
universal/include/userver/formats/universal/common_containers.hpp
Outdated
Show resolved
Hide resolved
5703876
to
c3323b9
Compare
universal/include/userver/formats/universal/common_containers.hpp
Outdated
Show resolved
Hide resolved
universal/include/userver/formats/universal/common_containers.hpp
Outdated
Show resolved
Hide resolved
In a separate It should allow to write something like: template <>
inline constexpr auto formats::enums::kEnumMapping<SomeEnum> = [](auto selector) {
return selector
.Case(SomeEnum::kFoo, "foo")
.Case(SomeEnum::kBar, "bar");
}; and get:
|
Example