mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 18:56:19 +08:00
This commit is contained in:
@@ -193,7 +193,9 @@ struct Parser {
|
||||
} else if constexpr (internal::is_validator_v<U>) {
|
||||
return make_validated<U>(_definitions);
|
||||
|
||||
} else if constexpr (internal::has_reflection_type_v<U>) {
|
||||
} else if constexpr (internal::has_reflection_type_v<U> ||
|
||||
internal::has_read_reflector<U> ||
|
||||
internal::has_write_reflector<U>) {
|
||||
return make_reference<U>(_definitions);
|
||||
|
||||
} else {
|
||||
@@ -235,13 +237,21 @@ struct Parser {
|
||||
std::map<std::string, schema::Type>* _definitions) {
|
||||
using Type = schema::Type;
|
||||
const auto name = make_type_name<U>();
|
||||
|
||||
if (_definitions->find(name) == _definitions->end()) {
|
||||
(*_definitions)[name] =
|
||||
Type{Type::Integer{}}; // Placeholder to avoid infinite loop.
|
||||
|
||||
if constexpr (internal::has_reflection_type_v<U>) {
|
||||
(*_definitions)[name] =
|
||||
Parser<R, W, typename U::ReflectionType, ProcessorsType>::to_schema(
|
||||
_definitions);
|
||||
|
||||
} else if constexpr (internal::has_read_reflector<U> ||
|
||||
internal::has_write_reflector<U>) {
|
||||
(*_definitions)[name] = Parser<R, W, typename Reflector<U>::ReflType,
|
||||
ProcessorsType>::to_schema(_definitions);
|
||||
|
||||
} else {
|
||||
using NamedTupleType = internal::processed_t<U, ProcessorsType>;
|
||||
(*_definitions)[name] =
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#include "../type_name_t.hpp"
|
||||
#include "is_tagged_union_wrapper.hpp"
|
||||
|
||||
namespace rfl {
|
||||
namespace parsing {
|
||||
namespace rfl::parsing {
|
||||
|
||||
inline std::string replace_non_alphanumeric(std::string _str) {
|
||||
for (auto& ch : _str) {
|
||||
@@ -24,7 +23,6 @@ static std::string make_type_name() {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace parsing
|
||||
} // namespace rfl
|
||||
} // namespace rfl::parsing
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user