query/source/orm/query/internal/query_result_impl.cpp

44 lines
1.6 KiB
C++

#include "matador/sql/internal/query_result_impl.hpp"
#include "matador/sql/interface/query_result_reader.hpp"
namespace matador::sql {
detail::pk_reader::pk_reader(query_result_reader &reader)
: reader_(reader) {
}
query_result_impl::query_result_impl(std::unique_ptr<query_result_reader> &&reader,
std::vector<object::attribute> prototype,
const std::shared_ptr<object::object_resolver_factory>& resolver_factory,
const size_t column_index)
: column_index_(column_index)
, prototype_(std::move(prototype))
, reader_(std::move(reader))
, resolver_factory_(resolver_factory)
, id_reader_(*reader_)
, pk_reader_(*reader_) {
}
void query_result_impl::on_revision(const char *id, uint64_t &rev) {
utils::data_type_traits<uint64_t>::read_value(*reader_, id, column_index_++, rev);
reader_->read_value(id, column_index_++, rev);
}
void query_result_impl::on_attribute(const char *id, char *value, const utils::field_attributes &attr) {
utils::data_type_traits<char *>::read_value(*reader_, id, column_index_++, value, attr.size());
}
void query_result_impl::on_attribute(const char *id, std::string &value, const utils::field_attributes &attr) {
utils::data_type_traits<std::string>::read_value(*reader_, id, column_index_++, value, attr.size());
}
void
query_result_impl::on_attribute(const char *id, utils::value &val, const utils::field_attributes &attr) {
reader_->read_value(id, column_index_++, val, attr.size());
}
const std::vector<object::attribute> &query_result_impl::prototype() const {
return prototype_;
}
}