/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright 2018 Danny Robson */ #include "base.hpp" #include "type.hpp" #include "length.hpp" #include "inequality.hpp" #include "properties.hpp" #include "enum.hpp" using util::json::schema::constraint::base; /////////////////////////////////////////////////////////////////////////////// std::unique_ptr base::instantiate (std::string const &name, ::json::tree::node const &def) { if (name == "type") return std::make_unique (def); if (name == "minLength") return std::make_unique (def); if (name == "maxLength") return std::make_unique (def); if (name == "minimum") return std::make_unique (def); if (name == "exclusiveMaximum") return std::make_unique (def); if (name == "exclusiveMinimum") return std::make_unique (def); if (name == "multipleOf") return std::make_unique (def); if (name == "maximum") return std::make_unique (def); if (name == "properties") return std::make_unique (def); if (name == "patternProperties") return std::make_unique (def); if (name == "additionalProperties") return std::make_unique (def); if (name == "enum") return std::make_unique (def); throw unknown_constraint (name); }