#pragma once #include #include #include 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); void db_init(const std::string &filename); void db_shutdown(); std::string db_get_setting(const std::string &key); void db_set_setting(const std::string &key, const std::string &value); std::map db_get_settings(const std::string &prefix);