//===----------------------------------------------------------------------===// // DuckDB // // duckdb/planner/bound_constraint.hpp // // //===----------------------------------------------------------------------===// #pragma once #include "duckdb/common/common.hpp" #include "duckdb/parser/constraint.hpp" #include "duckdb/common/serializer.hpp" #include "duckdb/common/exception.hpp" namespace duckdb { //! Bound equivalent of Constraint class BoundConstraint { public: explicit BoundConstraint(ConstraintType type) : type(type) {}; virtual ~BoundConstraint() { } void Serialize(Serializer &serializer) const { serializer.Write(type); } static unique_ptr Deserialize(Deserializer &source) { return make_uniq(source.Read()); } ConstraintType type; public: template TARGET &Cast() { if (type != TARGET::TYPE) { throw InternalException("Failed to cast constraint to type - bound constraint type mismatch"); } return reinterpret_cast(*this); } template const TARGET &Cast() const { if (type != TARGET::TYPE) { throw InternalException("Failed to cast constraint to type - bound constraint type mismatch"); } return reinterpret_cast(*this); } }; } // namespace duckdb