#ifndef RFL_AVRO_SCHEMA_HPP_ #define RFL_AVRO_SCHEMA_HPP_ #include #include "../Ref.hpp" #include "SchemaImpl.hpp" namespace rfl::avro { template class Schema { public: using Type = std::remove_cvref_t; Schema(const std::string& _json_str) : impl_(Ref::make(_json_str)) {} static Result> from_json(const std::string& _json_str) noexcept { try { return Schema(_json_str); } catch (std::exception& e) { return error(e.what()); } } /// The JSON string used to create this schema. const std::string& json_str() const { return impl_->json_str(); } /// The JSON string used to create this schema. const std::string& str() const { return impl_->json_str(); } /// The interface used to create new values. avro_value_iface_t* iface() const { return impl_->iface(); }; private: /// We are using the "pimpl"-pattern Ref impl_; }; } // namespace rfl::avro #endif