#pragma once #include "json/json_common.hpp" #include namespace json { namespace binder { template class binder_impl { public: virtual binder_impl * clone() const = 0; virtual ~binder_impl() {} virtual void parse(T &, char const *&, parser::options) const = 0; virtual void write(T const &, std::ostream &) const = 0; }; template class binder { public: binder() : impl(nullptr) {} binder(binder const & other) : impl(other.impl->clone()) {} binder(binder_impl const * p) : impl(p) {} binder(binder_impl const & r) : impl(r.clone()) {} ~binder() { delete impl; } void parse(T & object, char const *& data, parser::options opts) const { if (!impl) return; // error? impl->parse(object, data, opts); } void write(T const & object, std::ostream & data) const { if (!impl) return; // error? impl->write(object, data); } private: binder_impl const * impl; }; }}