#ifndef RFL_YAML_READ_HPP_ #define RFL_YAML_READ_HPP_ #include #include #include #include "../Processors.hpp" #include "../internal/wrap_in_rfl_array_t.hpp" #include "Parser.hpp" #include "Reader.hpp" namespace rfl { namespace yaml { using InputVarType = typename Reader::InputVarType; /// Parses an object from a YAML var. template auto read(const InputVarType& _var) { const auto r = Reader(); return Parser>::read(r, _var); } /// Parses an object from YAML using reflection. template Result> read(const std::string& _yaml_str ) { try { const auto var = InputVarType(YAML::Load(_yaml_str)); return read(var); } catch (std::exception& e) { return Error(e.what()); } } /// Parses an object from a stringstream. template auto read(std::istream& _stream) { const auto yaml_str = std::string( std::istreambuf_iterator(_stream), std::istreambuf_iterator() ); return read(yaml_str); } } // namespace yaml } // namespace rfl #endif