initial matador ng commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#include "matador/sql/interface/connection_impl.hpp"
|
||||
|
||||
#include "matador/sql/backend_provider.hpp"
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
connection_impl::connection_impl(const connection_info &info)
|
||||
: info_(info)
|
||||
, dialect_(backend_provider::instance().connection_dialect(info.type))
|
||||
{}
|
||||
|
||||
const connection_info &connection_impl::info() const {
|
||||
return info_;
|
||||
}
|
||||
|
||||
const class dialect & connection_impl::dialect() const {
|
||||
return dialect_;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "matador/sql/interface/query_result_reader.hpp"
|
||||
|
||||
#include "matador/utils/basic_types.hpp"
|
||||
#include "matador/utils/convert.hpp"
|
||||
#include "matador/utils/string.hpp"
|
||||
#include "matador/utils/value.hpp"
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
template < typename Type >
|
||||
void convert(const char *val_str, utils::value &val)
|
||||
{
|
||||
if (val_str == nullptr) {
|
||||
val = utils::value(Type{});
|
||||
return;
|
||||
}
|
||||
Type local_val{};
|
||||
const auto res = utils::to<Type>(val_str);
|
||||
val = *res;
|
||||
}
|
||||
|
||||
// utils::blob query_result_reader::read_blob(const size_t index)
|
||||
// {
|
||||
// const auto *data = column(index);
|
||||
// if (data == nullptr) {
|
||||
// return {};
|
||||
// }
|
||||
// const auto len = strlen(data);
|
||||
// const auto *bytes = reinterpret_cast<const unsigned char*>(data);
|
||||
// return utils::blob{bytes, bytes+len};
|
||||
// }
|
||||
|
||||
// utils::attribute_reader &query_result_reader::result_binder()
|
||||
// {
|
||||
// return empty_result_binder_;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "matador/sql/interface/statement_impl.hpp"
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
statement_impl::statement_impl(query_context query)
|
||||
: query_(std::move(query))
|
||||
{}
|
||||
|
||||
void statement_impl::bind(const size_t pos, const char *value, const size_t size)
|
||||
{
|
||||
utils::data_type_traits<const char*>::bind_value(binder(), adjust_index(pos), value, size);
|
||||
}
|
||||
|
||||
void statement_impl::bind(const size_t pos, std::string &val, const size_t size)
|
||||
{
|
||||
utils::data_type_traits<std::string>::bind_value(binder(), adjust_index(pos), val, size);
|
||||
}
|
||||
|
||||
const std::vector<std::string> &statement_impl::bind_vars() const
|
||||
{
|
||||
return query_.bind_vars;
|
||||
}
|
||||
|
||||
bool statement_impl::is_valid_host_var(const std::string &host_var, const size_t pos) const
|
||||
{
|
||||
const auto host_var_at_pos = bind_vars().at(pos);
|
||||
|
||||
return host_var_at_pos == host_var;
|
||||
}
|
||||
|
||||
size_t statement_impl::start_index() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t statement_impl::adjust_index( size_t index ) const
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user