#ifndef RFL_BSON_PARSER_HPP_ #define RFL_BSON_PARSER_HPP_ #include #include "../parsing/Parser.hpp" #include "Reader.hpp" #include "Writer.hpp" namespace rfl::parsing { /// bson_oid_t needs to be treated as a special case, otherwise it will be /// read as a struct. template requires AreReaderAndWriter struct Parser { using InputVarType = typename R::InputVarType; using OutputVarType = typename W::OutputVarType; using ParentType = Parent; static Result read(const R& _r, const InputVarType& _var) noexcept { return _r.template to_basic_type(_var); } template static void write(const W& _w, const bson_oid_t& _oid, const P& _parent) noexcept { ParentType::add_value(_w, _oid, _parent); } static schema::Type to_schema( std::map* _definitions) { static_assert(rfl::always_false_v, "bson_oid_t cannot be expressed inside a JSON schema."); return schema::Type {schema::Type::String {}}; } }; } // namespace rfl::parsing namespace rfl::bson { template using Parser = parsing::Parser; } // namespace rfl::bson #endif