25 #ifndef FABLE_SCHEMA_PASSTHRU_HPP_ 26 #define FABLE_SCHEMA_PASSTHRU_HPP_ 31 #include <boost/optional.hpp> 51 using PrototypeSchema = P;
54 :
Passthru(ptr, PrototypeSchema(
nullptr,
""), std::move(desc)) {}
55 Passthru(
Type* ptr,
const PrototypeSchema& prototype, std::string&& desc)
56 :
Base<Passthru<P>>(prototype.type(), std::move(desc)), prototype_(prototype), ptr_(ptr) {
57 prototype_.reset_ptr();
61 std::string
type_string()
const override {
return prototype_.type_string(); }
64 Json j = prototype_.json_schema();
65 this->augment_schema(j);
72 prototype_.validate(c);
77 assert(ptr_ !=
nullptr);
82 assert(ptr_ !=
nullptr);
83 *ptr_ = deserialize(c);
86 Json serialize(
const Type& x)
const {
return *x; }
88 Type deserialize(
const Conf& c)
const {
return c; }
93 PrototypeSchema prototype_;
101 template <
typename P>
102 Passthru<P> make_schema(
Conf* ptr,
const P& prototype, std::string&& desc) {
103 return Passthru<P>(ptr, prototype, std::move(desc));
109 #endif // FABLE_SCHEMA_PASSTHRU_HPP_
void to_json(Json &j) const override
Definition: passthru.hpp:76
Definition: ignore.hpp:46
std::string type_string() const override
Definition: passthru.hpp:61
void validate(const Conf &c) const override
Definition: passthru.hpp:69
nlohmann::json Json
Definition: json.hpp:62
Definition: passthru.hpp:48
virtual Json to_json() const
Definition: interface.hpp:220
void from_conf(const Conf &c) override
Definition: passthru.hpp:81
void reset_ptr() override
Definition: passthru.hpp:90
Json json_schema() const override
Definition: passthru.hpp:63
Definition: interface.hpp:354