moved pk_reader to internal
This commit is contained in:
parent
4d886f0343
commit
e7e66f44e2
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef MATADOR_PK_READER_HPP
|
||||
#define MATADOR_PK_READER_HPP
|
||||
|
||||
#include "matador/sql/interface/query_result_reader.hpp"
|
||||
|
||||
namespace matador::sql::detail {
|
||||
class pk_reader {
|
||||
public:
|
||||
explicit pk_reader(query_result_reader &reader);
|
||||
|
||||
template<class Type>
|
||||
void read(Type &obj, const size_t column_index) {
|
||||
column_index_ = column_index;
|
||||
access::process(*this, obj);
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr = utils::default_pk_attributes);
|
||||
void on_revision(const char * /*id*/, uint64_t &/*rev*/) {
|
||||
++column_index_;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void on_attribute(const char * /*id*/, Type &/*x*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {
|
||||
++column_index_;
|
||||
}
|
||||
|
||||
template<class Pointer>
|
||||
void on_belongs_to(const char * /*id*/, Pointer &/*x*/, const utils::foreign_attributes &/*attr*/) {
|
||||
++column_index_;
|
||||
}
|
||||
template<class Pointer>
|
||||
static void on_has_one(const char * /*id*/, Pointer &/*x*/, const utils::foreign_attributes &/*attr*/) {}
|
||||
template<class ContainerType>
|
||||
static void on_has_many(const char * /*id*/, ContainerType &, const char * /*join_column*/, const utils::foreign_attributes &/*attr*/) {}
|
||||
template<class ContainerType>
|
||||
static void on_has_many_to_many(const char * /*id*/, ContainerType &c, const char * /*join_column*/, const char * /*inverse_join_column*/, const utils::foreign_attributes &/*attr*/) {}
|
||||
template<class ContainerType>
|
||||
static void on_has_many_to_many(const char * /*id*/, ContainerType &c, const utils::foreign_attributes &/*attr*/) {}
|
||||
|
||||
private:
|
||||
size_t column_index_{};
|
||||
query_result_reader &reader_;
|
||||
};
|
||||
|
||||
template<typename ValueType>
|
||||
void pk_reader::on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr) {
|
||||
utils::data_type_traits<ValueType>::read_value(reader_, id, column_index_++, value, attr.size());
|
||||
}
|
||||
}
|
||||
#endif // MATADOR_PK_READER_HPP
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "matador/sql/interface/query_result_reader.hpp"
|
||||
#include "matador/sql/internal/query_result_pk_resolver.hpp"
|
||||
#include "matador/sql/internal/pk_reader.hpp"
|
||||
#include "matador/sql/internal/identifier_reader.hpp"
|
||||
#include "matador/sql/resolver_service.hpp"
|
||||
#include "matador/sql/record.hpp"
|
||||
|
|
@ -31,50 +32,6 @@ class value;
|
|||
}
|
||||
|
||||
namespace matador::sql {
|
||||
namespace detail {
|
||||
class pk_reader {
|
||||
public:
|
||||
explicit pk_reader(query_result_reader &reader);
|
||||
|
||||
template<class Type>
|
||||
void read(Type &obj, const size_t column_index) {
|
||||
column_index_ = column_index;
|
||||
access::process(*this, obj);
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr = utils::default_pk_attributes);
|
||||
void on_revision(const char * /*id*/, uint64_t &/*rev*/) {
|
||||
++column_index_;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
void on_attribute(const char * /*id*/, Type &/*x*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {
|
||||
++column_index_;
|
||||
}
|
||||
|
||||
template<class Pointer>
|
||||
void on_belongs_to(const char * /*id*/, Pointer &/*x*/, const utils::foreign_attributes &/*attr*/) {
|
||||
++column_index_;
|
||||
}
|
||||
template<class Pointer>
|
||||
void on_has_one(const char * /*id*/, Pointer &/*x*/, const utils::foreign_attributes &/*attr*/) {
|
||||
++column_index_;
|
||||
}
|
||||
|
||||
template<class ContainerType>
|
||||
static void on_has_many(const char * /*id*/, ContainerType &, const char * /*join_column*/, const utils::foreign_attributes &/*attr*/) {}
|
||||
template<class ContainerType>
|
||||
static void on_has_many_to_many(const char * /*id*/, ContainerType &c, const char * /*join_column*/, const char * /*inverse_join_column*/, const utils::foreign_attributes &/*attr*/) {}
|
||||
template<class ContainerType>
|
||||
static void on_has_many_to_many(const char * /*id*/, ContainerType &c, const utils::foreign_attributes &/*attr*/) {}
|
||||
|
||||
private:
|
||||
size_t column_index_{};
|
||||
query_result_reader &reader_;
|
||||
};
|
||||
}
|
||||
|
||||
class query_result_impl {
|
||||
public:
|
||||
query_result_impl(std::unique_ptr<query_result_reader> &&reader,
|
||||
|
|
@ -278,13 +235,6 @@ bool query_result_impl::fetch(Type &obj) {
|
|||
} while (last_pk_ == current_pk_);
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
template<typename ValueType>
|
||||
void pk_reader::on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr) {
|
||||
utils::data_type_traits<ValueType>::read_value(reader_, id, column_index_++, value, attr.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //QUERY_QUERY_RESULT_IMPL_HPP
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ add_library(matador-orm STATIC
|
|||
../../include/matador/sql/internal/identifier_statement_binder.hpp
|
||||
../../include/matador/sql/internal/object_resolver_producer.hpp
|
||||
../../include/matador/sql/internal/object_result_binder.hpp
|
||||
../../include/matador/sql/internal/pk_reader.hpp
|
||||
../../include/matador/sql/internal/query_result_impl.hpp
|
||||
../../include/matador/sql/internal/query_result_pk_resolver.hpp
|
||||
../../include/matador/sql/internal/statement_object_resolver.hpp
|
||||
|
|
|
|||
Loading…
Reference in New Issue