| 1 | #ifndef ENGINE_SQLITE_H |
| 2 | #define ENGINE_SQLITE_H |
| 3 | #include <memory> |
| 4 | |
| 5 | struct sqlite3; |
| 6 | struct sqlite3_stmt; |
| 7 | class IStorage; |
| 8 | |
| 9 | class CSqliteDeleter |
| 10 | { |
| 11 | public: |
| 12 | void operator()(sqlite3 *pSqlite); |
| 13 | }; |
| 14 | class CSqliteStmtDeleter |
| 15 | { |
| 16 | public: |
| 17 | void operator()(sqlite3_stmt *pStmt); |
| 18 | }; |
| 19 | typedef std::unique_ptr<sqlite3, CSqliteDeleter> CSqlite; |
| 20 | typedef std::unique_ptr<sqlite3_stmt, CSqliteStmtDeleter> CSqliteStmt; |
| 21 | |
| 22 | int SqliteHandleError(int Error, sqlite3 *pSqlite, const char *pContext); |
| 23 | #define SQLITE_HANDLE_ERROR(x) SqliteHandleError(x, &*pSqlite, #x) |
| 24 | |
| 25 | CSqlite SqliteOpen(IStorage *pStorage, const char *pPath); |
| 26 | CSqliteStmt SqlitePrepare(sqlite3 *pSqlite, const char *pStatement); |
| 27 | #endif // ENGINE_SQLITE_H |
| 28 | |