master
ブランチ master
ShaderPlayground / include / util / sqlitepp.hh
2.4 KB、81行 生 Blame 履歴
1/*
2# 076 Free License
3
4Copyright (c) テクニカル諏訪子
5
6Permission is hereby granted to any person obtaining a copy of the software
7C++ Utils (the "Software") to use, modify, merge, copy, publish, distribute,
8sublicense, and/or sell copies of the Software, subject to the following conditions:
9
10 1. **Origin Attribution**:
11 - You must not misrepresent the origin of the Software; you must not claim
12 you created the original Software.
13 2. **Notice Preservation**:
14 - This license and the above copyright notice must remain intact in all copies
15 of the source code.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23*/
24#ifndef SQLITEPP_HH
25#define SQLITEPP_HH
26
27#include <util/types.hh>
28
29struct sqlite3;
30struct sqlite3_stmt;
31struct sqlite3_value;
32
33namespace 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 }; // class Instance
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 //const any ColumnText16(int col);
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 }; // class Stmt
79} // namespace sqlitepp
80
81#endif // SQLITEPP_HH