2022-07-06 22:14:37 +02:00
|
|
|
#ifndef SQLITE3_QUERY_RESULT_H
|
|
|
|
#define SQLITE3_QUERY_RESULT_H
|
2022-06-30 13:23:48 +02:00
|
|
|
|
2022-07-06 22:14:37 +02:00
|
|
|
#include "core/ustring.h"
|
|
|
|
#include "core/vector.h"
|
2022-06-30 13:23:48 +02:00
|
|
|
|
2022-07-06 22:14:37 +02:00
|
|
|
#include "../database/query_result.h"
|
2022-06-30 13:23:48 +02:00
|
|
|
|
2022-07-06 22:14:37 +02:00
|
|
|
struct sqlite3;
|
2022-06-30 13:23:48 +02:00
|
|
|
|
|
|
|
class Sqlite3QueryResult : public QueryResult {
|
2022-07-06 22:14:37 +02:00
|
|
|
GDCLASS(Sqlite3QueryResult, QueryResult);
|
2022-06-30 13:23:48 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
bool next_row();
|
2022-07-06 22:14:37 +02:00
|
|
|
String get_cell(const int index);
|
2022-06-30 13:23:48 +02:00
|
|
|
bool is_cell_null(const int index);
|
|
|
|
int get_last_insert_rowid();
|
2022-07-06 22:14:37 +02:00
|
|
|
String get_error_message();
|
2022-06-30 13:23:48 +02:00
|
|
|
|
|
|
|
void query(const String &query, sqlite3 *conn);
|
|
|
|
|
|
|
|
static int run_query_finished(void *data, int argc, char **argv, char **col_names);
|
|
|
|
|
|
|
|
Sqlite3QueryResult();
|
|
|
|
~Sqlite3QueryResult();
|
|
|
|
|
2022-07-06 22:14:37 +02:00
|
|
|
protected:
|
2022-06-30 13:23:48 +02:00
|
|
|
struct Cell {
|
|
|
|
bool null;
|
|
|
|
String data;
|
|
|
|
|
|
|
|
Cell() {
|
|
|
|
null = false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sqlite3QueryResultRow {
|
2022-07-06 22:14:37 +02:00
|
|
|
Vector<Cell> cells;
|
2022-06-30 13:23:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
char **col_names;
|
2022-07-06 22:14:37 +02:00
|
|
|
Vector<Sqlite3QueryResultRow *> rows;
|
2022-06-30 13:23:48 +02:00
|
|
|
int current_row;
|
2022-07-06 22:14:37 +02:00
|
|
|
char *err_msg;
|
2022-06-30 13:23:48 +02:00
|
|
|
|
|
|
|
sqlite3 *_connection;
|
|
|
|
};
|
|
|
|
|
2022-07-06 22:14:37 +02:00
|
|
|
#endif
|