#ifndef RFL_PARSING_PARSER_FILEPATH_HPP_ #define RFL_PARSING_PARSER_FILEPATH_HPP_ #include #include #include "../Result.hpp" #include "Parser_base.hpp" #include "schema/Type.hpp" namespace rfl { namespace parsing { template requires AreReaderAndWriter struct Parser { using InputVarType = typename R::InputVarType; /// Expresses the variables as type T. static Result read(const R& _r, const InputVarType& _var) noexcept { const auto to_path = [&](std::string&& _str) -> Result { try { return std::filesystem::path(_str); } catch (std::exception& e) { return error(e.what()); } }; return Parser::read(_r, _var).and_then( to_path); } template static void write(const W& _w, const std::filesystem::path& _p, const P& _parent) { return Parser::write(_w, _p.string(), _parent); } static schema::Type to_schema( std::map* _definitions) { return Parser::to_schema(_definitions); } }; } // namespace parsing } // namespace rfl #endif