#ifndef RFL_TOML_WRITE_HPP_ #define RFL_TOML_WRITE_HPP_ #include #include #include #include #include #include "../Processors.hpp" #include "../parsing/Parent.hpp" #include "Parser.hpp" namespace rfl::toml { /// Writes a TOML into an ostream. template std::ostream& write(const auto& _obj, std::ostream& _stream) { using T = std::remove_cvref_t; using ParentType = parsing::Parent; ::toml::table root; auto w = Writer(&root); using ProcessorsType = Processors; static_assert(!ProcessorsType::no_field_names_, "The NoFieldNames processor is not supported for BSON, XML, " "TOML, or YAML."); Parser::write(w, _obj, typename ParentType::Root{}); _stream << root; return _stream; } /// Returns a TOML string. template std::string write(const auto& _obj) { using T = std::remove_cvref_t; using ParentType = parsing::Parent; std::stringstream sstream; ::toml::table root; auto w = Writer(&root); using ProcessorsType = Processors; static_assert(!ProcessorsType::no_field_names_, "The NoFieldNames processor is not supported for BSON, XML, " "TOML, or YAML."); Parser::write(w, _obj, typename ParentType::Root{}); sstream << root; return sstream.str(); } } // namespace rfl::toml #endif