2020-11-22 18:18:45 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <sqlite3.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
extern sqlite3 *db;
|
|
|
|
|
|
|
|
extern void tui_abort(const char *fmt, ...);
|
|
|
|
#define SC(x) { const int res = (x); if(res != SQLITE_OK && res != SQLITE_ROW && res != SQLITE_DONE) { tui_abort("Database error:\n%s failed: (%d) %s", #x, res, sqlite3_errstr(res)); }}
|
|
|
|
|
|
|
|
class db_transaction {
|
|
|
|
public:
|
|
|
|
db_transaction();
|
|
|
|
~db_transaction();
|
|
|
|
};
|
|
|
|
std::string get_string(sqlite3_stmt *row, int col);
|
|
|
|
|
2020-11-22 20:29:45 +00:00
|
|
|
void db_init(const std::string &filename);
|
|
|
|
void db_shutdown();
|
2020-11-22 18:18:45 +00:00
|
|
|
|
|
|
|
std::string db_get_setting(const std::string &key);
|
|
|
|
void db_set_setting(const std::string &key, const std::string &value);
|
|
|
|
std::map<std::string, std::string> db_get_settings(const std::string &prefix);
|
|
|
|
|