record refactoring

This commit is contained in:
2024-03-17 16:32:08 +01:00
parent 9a02abacea
commit 12919ba372
21 changed files with 390 additions and 118 deletions
+17 -1
View File
@@ -3,6 +3,7 @@
#include "matador/sql/any_type.hpp"
#include "matador/sql/any_type_to_visitor.hpp"
#include "matador/sql/data_type_traits.hpp"
#include "matador/utils/types.hpp"
@@ -64,11 +65,13 @@ class field
public:
explicit field(std::string name);
template<typename Type>
field(std::string name, Type value, int index = -1)
field(std::string name, Type value, size_t size = 0, int index = -1)
: name_(std::move(name))
, size_(size)
, index_(index)
, value_(value)
, type_(field_traits<Type>::type()) {}
field(std::string name, data_type_t data_type, size_t size = 0, int index = -1);
field(const field &x) = default;
field& operator=(const field &x) = default;
field(field &&x) noexcept;
@@ -82,6 +85,7 @@ public:
}
[[nodiscard]] const std::string& name() const;
[[nodiscard]] size_t size() const;
[[nodiscard]] int index() const;
template<class Type>
@@ -104,9 +108,21 @@ public:
friend std::ostream& operator<<(std::ostream &out, const field &col);
private:
template<class Operator>
void process(Operator &op)
{
op.on_attribute(name_.c_str(), value_, field_type_to_data_type(type_), size_);
}
private:
friend class record;
static data_type_t field_type_to_data_type(field_type type);
std::string name_;
int index_{-1};
any_type value_;
size_t size_{};
field_type type_;
};