#ifndef RFL_PARSING_PARSER_DEFAULTVAL_HPP_ #define RFL_PARSING_PARSER_DEFAULTVAL_HPP_ #include #include #include "../DefaultVal.hpp" #include "AreReaderAndWriter.hpp" #include "Parent.hpp" #include "Parser_base.hpp" #include "schema/Type.hpp" namespace rfl::parsing { template requires AreReaderAndWriter> struct Parser, ProcessorsType> { using InputVarType = typename R::InputVarType; using ParentType = Parent; static Result> read(const R& _r, const InputVarType& _var) noexcept { return Parser, ProcessorsType>::read(_r, _var) .transform([](auto&& _t) { return DefaultVal(std::forward(_t)); }); } template static void write(const W& _w, const DefaultVal& _d, const P& _parent) { Parser, ProcessorsType>::write(_w, _d.value(), _parent); } static schema::Type to_schema( std::map* _definitions) { using U = std::remove_cvref_t; return schema::Type{ Parser::to_schema(_definitions)}; } }; } // namespace rfl::parsing #endif