added sqlite query result and enhanced column generator and value extractor
This commit is contained in:
@@ -26,9 +26,14 @@ public:
|
||||
void close() override;
|
||||
bool is_open() override;
|
||||
|
||||
void execute(const std::string &stmt) override;
|
||||
std::unique_ptr<sql::query_result_impl> fetch(const std::string &stmt) override;
|
||||
void prepare(const std::string &stmt) override;
|
||||
|
||||
size_t execute(const std::string &stmt) override;
|
||||
|
||||
private:
|
||||
static int parse_result(void* param, int column_count, char** values, char** columns);
|
||||
|
||||
private:
|
||||
sqlite3 *sqlite_db_{};
|
||||
};
|
||||
|
||||
@@ -1,10 +1,46 @@
|
||||
#ifndef QUERY_SQLITE_QUERY_RESULT_HPP
|
||||
#define QUERY_SQLITE_QUERY_RESULT_HPP
|
||||
|
||||
#include "matador/sql/query_result_impl.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace matador::backends::sqlite {
|
||||
|
||||
class sqlite_query_result {
|
||||
class sqlite_query_result : public sql::query_result_impl {
|
||||
public:
|
||||
void read_value(const char *id, size_t index, char &value) override;
|
||||
void read_value(const char *id, size_t index, short &value) override;
|
||||
void read_value(const char *id, size_t index, int &value) override;
|
||||
void read_value(const char *id, size_t index, long &value) override;
|
||||
void read_value(const char *id, size_t index, long long int &value) override;
|
||||
void read_value(const char *id, size_t index, unsigned char &value) override;
|
||||
void read_value(const char *id, size_t index, unsigned short &value) override;
|
||||
void read_value(const char *id, size_t index, unsigned int &value) override;
|
||||
void read_value(const char *id, size_t index, unsigned long &value) override;
|
||||
void read_value(const char *id, size_t index, unsigned long long int &value) override;
|
||||
void read_value(const char *id, size_t index, bool &value) override;
|
||||
void read_value(const char *id, size_t index, float &value) override;
|
||||
void read_value(const char *id, size_t index, double &value) override;
|
||||
void read_value(const char *id, size_t index, char *value, size_t size) override;
|
||||
void read_value(const char *id, size_t index, std::string &value) override;
|
||||
void read_value(const char *id, size_t index, std::string &value, size_t s) override;
|
||||
|
||||
protected:
|
||||
[[nodiscard]] bool next_row() override;
|
||||
|
||||
private:
|
||||
friend class sqlite_connection;
|
||||
|
||||
private:
|
||||
void push_back(char **row_values, int column_count);
|
||||
|
||||
private:
|
||||
using columns = std::vector<char*>;
|
||||
using rows = std::vector<columns>;
|
||||
|
||||
rows result_;
|
||||
size_t row_index_ = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user