| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | #ifndef SQLITEPP_HH |
| 25 | #define SQLITEPP_HH |
| 26 | |
| 27 | #include <util/types.hh> |
| 28 | |
| 29 | struct sqlite3; |
| 30 | struct sqlite3_stmt; |
| 31 | struct sqlite3_value; |
| 32 | |
| 33 | namespace sqlitepp { |
| 34 | class Instance { |
| 35 | public: |
| 36 | Instance(); |
| 37 | ~Instance(); |
| 38 | |
| 39 | sqlite3 *GetDB() { return m_pDB; } |
| 40 | bool Exec(string sql); |
| 41 | i64 GetLastInsertId(); |
| 42 | |
| 43 | private: |
| 44 | sqlite3 *m_pDB; |
| 45 | }; |
| 46 | |
| 47 | class Stmt { |
| 48 | public: |
| 49 | Stmt(sqlite3 *pDB); |
| 50 | ~Stmt(); |
| 51 | |
| 52 | bool Prepare(const std::string &sql); |
| 53 | bool BindBlob(int index, any data, u32 size); |
| 54 | bool BindBlob64(int index, any data, u64 size); |
| 55 | bool BindDouble(int index, f64 data); |
| 56 | bool BindInt(int index, i32 data); |
| 57 | bool BindInt64(int index, i64 data); |
| 58 | bool BindNull(int index); |
| 59 | bool BindText(int index, const string &data); |
| 60 | bool BindText16(int index, const string &data); |
| 61 | bool BindText64(int index, const string &data); |
| 62 | |
| 63 | const void *ColumnBlob(int col); |
| 64 | f64 ColumnDouble(int col); |
| 65 | int ColumnInt(int col); |
| 66 | i64 ColumnInt64(int col); |
| 67 | string ColumnText(int col); |
| 68 | |
| 69 | sqlite3_value *ColumnValue(int col); |
| 70 | int ColumnBytes(int col); |
| 71 | int ColumnBytes16(int col); |
| 72 | int ColumnType(int col); |
| 73 | int Step(); |
| 74 | |
| 75 | private: |
| 76 | sqlite3 *m_pDB; |
| 77 | sqlite3_stmt *m_pSTMT = nullptr; |
| 78 | }; |
| 79 | } |
| 80 | |
| 81 | #endif |