#ifndef RFL_PARSING_SCHEMAFUL_ISSCHEMAFULREADER_HPP_ #define RFL_PARSING_SCHEMAFUL_ISSCHEMAFULREADER_HPP_ #include #include #include #include #include "../../Result.hpp" namespace rfl::parsing::schemaful { using MockVariantType = std::variant; template struct MockMapReader { void read(const std::string_view&, typename R::InputVarType&) const {} }; template struct MockObjectReader { void read(const int, typename R::InputVarType&) const {} }; template struct MockUnionReader { static rfl::Result read(const R&, const size_t, typename R::InputVarType&) { return error("This is a mock type."); } }; template concept IsSchemafulReader = requires(R r, typename R::InputVarType var, typename R::InputObjectType obj, typename R::InputMapType m, typename R::InputUnionType u, MockMapReader map_reader, MockObjectReader object_reader) { /// A schemaful reader needs to differentiate between objects, for which /// the field names are known at compile time and maps, for which the /// field names are not known at compile time. { r.read_map(map_reader, m) } -> std::same_as>; /// A schemaful reader can read fields by order and does not have to /// compare strings - the correct order of the fields is guaranteed by the /// schema. { r.read_object(object_reader, obj) } -> std::same_as>; /// A schemaful reader needs an explicit union type. { r.template read_union>(u) } -> std::same_as>; /// It needs to be possible to transform variables to maps. { r.to_map(var) } -> std::same_as>; /// It needs to be possible to transform variables to unions. { r.to_union(var) } -> std::same_as>; }; } // namespace rfl::parsing::schemaful #endif