#ifndef QUERY_FK_VALUE_EXTRACTOR_HPP #define QUERY_FK_VALUE_EXTRACTOR_HPP #include "matador/sql/any_type.hpp" #include "matador/utils/access.hpp" #include "matador/utils/field_attributes.hpp" namespace matador::sql::detail { class fk_value_extractor { public: fk_value_extractor() = default; template any_type extract(Type &x) { matador::utils::access::process(*this, x); return value_; } template void on_primary_key(const char *, ValueType &pk, typename std::enable_if::value && !std::is_same::value>::type* = 0) { value_ = pk; } void on_primary_key(const char * /*id*/, std::string &pk, size_t size); void on_revision(const char * /*id*/, unsigned long long &/*rev*/) {} template < class Type > void on_attribute(const char * /*id*/, Type &/*x*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {} void on_attribute(const char * /*id*/, char * /*x*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {} template void on_belongs_to(const char * /*id*/, Pointer &/*x*/, utils::cascade_type) {} template void on_has_one(const char * /*id*/, Pointer &/*x*/, utils::cascade_type) {} template void on_has_many(const char *, ContainerType &, const char *, const char *, utils::cascade_type) {} template void on_has_many(const char *, ContainerType &, utils::cascade_type) {} private: any_type value_{}; }; } #endif //QUERY_FK_VALUE_EXTRACTOR_HPP