35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
#pragma once
|
|
#ifndef WIN32
|
|
#include <sqlite/sqlite3.h>
|
|
#include <memory>
|
|
#include "lib/utils/bts_export.h"
|
|
#include "lib/utils/bts_assert.h"
|
|
|
|
typedef struct sqlite3 sqlite3;
|
|
typedef struct sqlite3_stmt sqlite3_stmt;
|
|
typedef std::unique_ptr<sqlite3, int(*)(sqlite3*)> sqlite3_ptr;
|
|
typedef std::unique_ptr<sqlite3_stmt, int(*)(sqlite3_stmt*)> sqlite3_stmt_ptr;
|
|
|
|
#define SQLITE_CHK(x,c) \
|
|
do { \
|
|
if (x != SQLITE_OK) \
|
|
{ \
|
|
bts_assert_msg(false ,sqlite3_errmsg(c.get())); \
|
|
} \
|
|
} while(0)
|
|
|
|
namespace bts {
|
|
namespace utils {
|
|
|
|
void sqlite3_exec_nofail(sqlite3* db, const char* sql);
|
|
void sqlite3_exec_nofail(sqlite3_ptr& db, const char* sql);
|
|
|
|
sqlite3_ptr open_db(const char* path);
|
|
sqlite3_stmt_ptr prepare_query(sqlite3* db, const char* query);
|
|
sqlite3_stmt_ptr prepare_query(sqlite3_ptr& db, const char* query);
|
|
}}//namespace
|
|
|
|
#endif
|
|
|
|
|