@@ -79,16 +79,12 @@ struct Parser {
7979 return Parser<R, W, ReflectionType, ProcessorsType>::read (_r, _var)
8080 .and_then (wrap_in_t );
8181
82- } else if constexpr (std::is_class_v<T> && std::is_aggregate_v<T>) {
83- if constexpr (ProcessorsType::default_if_missing_ ||
84- internal::has_default_val_v<T>) {
85- return read_struct_with_default (_r, _var);
86- } else {
87- return read_struct (_r, _var);
88- }
82+ } else if constexpr (ProcessorsType::default_if_missing_ ||
83+ internal::has_default_val_v<T>) {
84+ return read_struct_with_default (_r, _var);
8985
9086 } else {
91- return _r. template to_basic_type <std:: remove_cvref_t <T>>( _var);
87+ return read_struct (_r, _var);
9288 }
9389 }
9490 }
@@ -113,15 +109,12 @@ struct Parser {
113109 Parser<R, W, ReflectionType, ProcessorsType>::write (_w, r, _parent);
114110 }
115111
116- } else if constexpr (std::is_class_v<T> && std::is_aggregate_v<T>) {
112+ } else {
117113 const auto ptr_named_tuple = ProcessorsType::template process<T>(
118114 internal::to_ptr_named_tuple (_var));
119115 using PtrNamedTupleType = std::remove_cvref_t <decltype (ptr_named_tuple)>;
120116 Parser<R, W, PtrNamedTupleType, ProcessorsType>::write (
121117 _w, ptr_named_tuple, _parent);
122-
123- } else {
124- ParentType::add_value (_w, _var, _parent);
125118 }
126119 }
127120
@@ -130,34 +123,8 @@ struct Parser {
130123 std::map<std::string, schema::Type>* _definitions) {
131124 using U = std::remove_cvref_t <T>;
132125 using Type = schema::Type;
133- if constexpr (std::is_same<U, bool >()) {
134- return Type{Type::Boolean{}};
135-
136- } else if constexpr (std::is_same<U, std::int32_t >()) {
137- return Type{Type::Int32{}};
138-
139- } else if constexpr (std::is_same<U, std::int64_t >()) {
140- return Type{Type::Int64{}};
141-
142- } else if constexpr (std::is_same<U, std::uint32_t >()) {
143- return Type{Type::UInt32{}};
144-
145- } else if constexpr (std::is_same<U, std::uint64_t >()) {
146- return Type{Type::UInt64{}};
147-
148- } else if constexpr (std::is_integral<U>()) {
149- return Type{Type::Integer{}};
150-
151- } else if constexpr (std::is_same<U, float >()) {
152- return Type{Type::Float{}};
153-
154- } else if constexpr (std::is_floating_point_v<U>) {
155- return Type{Type::Double{}};
156-
157- } else if constexpr (std::is_same<U, std::string>()) {
158- return Type{Type::String{}};
159126
160- } else if constexpr (rfl::internal::is_description_v<U>) {
127+ if constexpr (rfl::internal::is_description_v<U>) {
161128 return make_description<U>(_definitions);
162129
163130 } else if constexpr (std::is_class_v<U> && std::is_aggregate_v<U>) {
@@ -234,10 +201,10 @@ struct Parser {
234201 .validation_ = ValidationType::template to_schema<ReflectionType>()}};
235202 }
236203
237- // / The way this works is that we allocate space on the stack in this size of
238- // / the struct in which we then write the individual fields using
239- // / views and placement new. This is how we deal with the fact that some
240- // / fields might not be default-constructible.
204+ // / The way this works is that we allocate space on the stack in this size
205+ // / of the struct in which we then write the individual fields using views
206+ // / and placement new. This is how we deal with the fact that some fields
207+ // / might not be default-constructible.
241208 static Result<T> read_struct (const R& _r, const InputVarType& _var) {
242209 alignas (T) unsigned char buf[sizeof (T)]{};
243210 auto ptr = internal::ptr_cast<T*>(&buf);
@@ -254,10 +221,10 @@ struct Parser {
254221 return res;
255222 }
256223
257- // / This is actually more straight-forward than the standard case - we just
258- // / allocate a struct and then fill it. But it is less efficient and it
259- // / assumes that all values on the struct have a default constructor, so we
260- // / only use it when the DefaultIfMissing preprocessor is added.
224+ // / This is actually more straight-forward than the standard case - we
225+ // / just allocate a struct and then fill it. But it is less efficient and
226+ // / it assumes that all values on the struct have a default constructor,
227+ // / so we only use it when the DefaultIfMissing preprocessor is added.
261228 static Result<T> read_struct_with_default (const R& _r,
262229 const InputVarType& _var) {
263230 auto t = T{};
0 commit comments