added sql function and alias

This commit is contained in:
2023-11-22 19:57:25 +01:00
parent 145c4dc0a3
commit 72f9d28d0d
22 changed files with 356 additions and 236 deletions
+17 -4
View File
@@ -105,6 +105,19 @@ private:
query_result<Type> *result_{nullptr};
};
namespace detail {
template < typename Type >
Type* create_prototype(const record &/*prototype*/)
{
return new Type{};
}
template <>
record* create_prototype<record>(const record &prototype);
}
template < typename Type >
class query_result
{
@@ -116,8 +129,8 @@ public:
explicit query_result(std::unique_ptr<query_result_impl> impl)
: impl_(std::move(impl)) {}
query_result(std::unique_ptr<query_result_impl> impl, creator_func creator)
: creator_(creator)
query_result(std::unique_ptr<query_result_impl> impl, record record_prototype)
: record_prototype_(std::move(record_prototype))
, impl_(std::move(impl)) {}
iterator begin() { return std::move(++iterator(this)); }
@@ -126,7 +139,7 @@ public:
private:
friend class query_result_iterator<Type>;
Type* create() { return creator_(); }
Type* create() { return detail::create_prototype<Type>(record_prototype_); }
void bind(const Type &obj)
{
@@ -139,7 +152,7 @@ private:
}
private:
creator_func creator_ = []{ return new Type; };
record record_prototype_;
std::unique_ptr<query_result_impl> impl_;
};