#ifndef RFL_CAPNPROTO_SCHEMA_HPP_ #define RFL_CAPNPROTO_SCHEMA_HPP_ #include #include #include "../Ref.hpp" #include "SchemaImpl.hpp" namespace rfl::capnproto { template class Schema { public: using Type = std::remove_cvref_t; Schema(const std::string& _str) : impl_(Ref::make(_str)) {} static Result> from_string(const std::string& _str) noexcept { try { return Schema(_str); } catch (std::exception& e) { return error(e.what()); } } /// The string used to create this schema. const std::string& str() const { return impl_->str(); } /// The struct schema used to generate new values. const capnp::ParsedSchema& value() const { return impl_->value(); }; private: /// We are using the "pimpl"-pattern Ref impl_; }; } // namespace rfl::capnproto #endif