renamed foreign class to entity, introduced interface class query_result_reader

This commit is contained in:
2023-11-24 17:40:57 +01:00
parent 700cbc0652
commit c2a96f4cbd
18 changed files with 285 additions and 207 deletions
+19 -9
View File
@@ -1,31 +1,45 @@
#include "matador/sql/query_result_impl.hpp"
#include "matador/sql/query_result_reader.hpp"
namespace matador::sql {
detail::pk_reader::pk_reader(query_result_reader &reader)
: reader_(reader) {}
void detail::pk_reader::on_primary_key(const char *id, std::string &value, size_t size) {
reader_.read_value(id, column_index_, value, size);
}
query_result_impl::query_result_impl(std::unique_ptr<query_result_reader> &&reader, record prototype)
: prototype_(std::move(prototype))
, reader_(std::move(reader))
, pk_reader_(*reader_)
{}
void query_result_impl::on_primary_key(const char *id, std::string &value, size_t size)
{
read_value(id, column_index_++, value, size);
reader_->read_value(id, column_index_++, value, size);
}
void query_result_impl::on_revision(const char *id, unsigned long long int &rev)
{
read_value(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)
{
read_value(id, column_index_++, value, attr.size());
reader_->read_value(id, column_index_++, value, attr.size());
}
void query_result_impl::on_attribute(const char *id, std::string &value, const utils::field_attributes &attr)
{
read_value(id, column_index_++, value, attr.size());
reader_->read_value(id, column_index_++, value, attr.size());
}
void
query_result_impl::on_attribute(const char *id, any_type &value, data_type_t type, const utils::field_attributes &attr)
{
read_value(id, column_index_++, value, type, attr.size());
reader_->read_value(id, column_index_++, value, type, attr.size());
}
const record& query_result_impl::prototype() const
@@ -33,8 +47,4 @@ const record& query_result_impl::prototype() const
return prototype_;
}
query_result_impl::query_result_impl(record prototype)
: prototype_(std::move(prototype))
{}
}