initial matador ng commit
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#ifndef QUERY_STATEMENT_IMPL_HPP
|
||||
#define QUERY_STATEMENT_IMPL_HPP
|
||||
|
||||
#include "matador/sql/query_context.hpp"
|
||||
#include "matador/sql/internal/query_result_impl.hpp"
|
||||
#include "matador/sql/object_parameter_binder.hpp"
|
||||
|
||||
#include "matador/utils/data_type_traits.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
class sql_error;
|
||||
|
||||
class statement_impl
|
||||
{
|
||||
protected:
|
||||
explicit statement_impl(query_context query);
|
||||
|
||||
public:
|
||||
virtual ~statement_impl() = default;
|
||||
|
||||
virtual utils::result<size_t, utils::error> execute() = 0;
|
||||
virtual utils::result<std::unique_ptr<query_result_impl>, utils::error> fetch() = 0;
|
||||
|
||||
template < class Type >
|
||||
void bind_object(Type &obj)
|
||||
{
|
||||
object_parameter_binder object_binder_;
|
||||
object_binder_.reset(start_index());
|
||||
object_binder_.bind(obj, binder());
|
||||
}
|
||||
|
||||
template < class Type >
|
||||
void bind(const size_t pos, Type &val)
|
||||
{
|
||||
utils::data_type_traits<Type>::bind_value(binder(), adjust_index(pos), val);
|
||||
}
|
||||
|
||||
void bind(size_t pos, const char *value, size_t size);
|
||||
void bind(size_t pos, std::string &val, size_t size);
|
||||
|
||||
virtual void reset() = 0;
|
||||
|
||||
[[nodiscard]] const std::vector<std::string>& bind_vars() const;
|
||||
[[nodiscard]] bool is_valid_host_var(const std::string &host_var, size_t pos) const;
|
||||
|
||||
protected:
|
||||
virtual utils::attribute_writer& binder() = 0;
|
||||
[[nodiscard]] virtual size_t start_index() const;
|
||||
[[nodiscard]] virtual size_t adjust_index(size_t index) const;
|
||||
|
||||
protected:
|
||||
friend class statement;
|
||||
|
||||
query_context query_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //QUERY_STATEMENT_IMPL_HPP
|
||||
Reference in New Issue
Block a user