Alternate e697dbe9c5997e35395fe158628dd8c5209481da
for Visual Studio 2022 and Windows 11.
読み取り中…
検索中…
一致する文字列を見つけられません
Statement.h
[詳解]
1
5
6#pragma once
7
8#include <Windows.h>
9#include "sqlite3.h"
10#include "Core.h"
11#include "Engine.h"
12
13namespace alt
14{
15 namespace db
16 {
19 class Statement : public Core
20 {
21 public:
24 :Core ()
25 {
26 _statement = nullptr;
27 }
28
30 virtual ~Statement ()
31 {
32 if (_statement) Finalize ();
33 }
34
42 bool Prepare (Engine engine, LPCTSTR lpctszSQL)
43 {
44 _lastError = ::sqlite3_prepare16 (engine.GetEngine (), lpctszSQL, -1, &_statement, nullptr);
45 return getResponse () && _statement != nullptr;
46 }
47
54 bool Bind (int position)
55 {
57 return getResponse ();
58 }
59
66 bool Bind (int position, int value)
67 {
68 _lastError = ::sqlite3_bind_int (_statement, position, value);
69 return getResponse ();
70 }
71
78 bool Bind (int position, sqlite3_int64 value)
79 {
80 _lastError = ::sqlite3_bind_int64 (_statement, position, value);
81 return getResponse ();
82 }
83
90 bool Bind (int position, double value)
91 {
92 _lastError = ::sqlite3_bind_double (_statement, position, value);
93 return getResponse ();
94 }
95
102 bool Bind (int position, LPCSTR value)
103 {
104 _lastError = ::sqlite3_bind_text (_statement, position, value, (int)lstrlenA (value), nullptr);
105 return getResponse ();
106 }
107
114 bool Bind (int position, LPCWSTR value)
115 {
116 _lastError = ::sqlite3_bind_text16 (_statement, position, value, (int)lstrlenW (value) * sizeof (wchar_t), nullptr);
117 return getResponse ();
118 }
119
121
126 bool Execute ()
127 {
129 return getResponse ();
130 }
131
136 bool ResetBind ()
137 {
139 bool ret = getResponse ();
140 if (!ret) return ret;
141
143 return getResponse ();
144 }
145
149 {
150 return ::sqlite3_column_count (_statement);
151 }
152
155 LPCTSTR GetColumnName (int position)
156 {
157 return (LPCTSTR)::sqlite3_column_name16 (_statement, position);
158 }
159
162 LPCTSTR GetColumnType (int position)
163 {
164 return (LPCTSTR)::sqlite3_column_decltype16 (_statement, position);
165 }
166
170 int GetIntValue (int position)
171 {
172 return ::sqlite3_column_int (_statement, position);
173 }
174
179 {
180 return ::sqlite3_column_int64 (_statement, position);
181 }
182
186 double GetDoubleValue (int position)
187 {
188 return ::sqlite3_column_double (_statement, position);
189 }
190
194 LPCSTR GetStringValue (int position)
195 {
196 return (LPCSTR)::sqlite3_column_text (_statement, position);
197 }
198
202 LPCTSTR GetString16Value (int position)
203 {
204 return (LPCTSTR)::sqlite3_column_text16 (_statement, position);
205 }
206
211 bool Finalize ()
212 {
214 _statement = nullptr;
215 return getResponse ();
216 }
217
218 protected:
221 };
222 }
223}
SqLite3操作クラス(Core)
SqLite3操作クラス(Engine)
SqLite3操作クラス(Core)
Definition: Core.h:19
bool getResponse()
各関数の戻り値判定共通
Definition: Core.h:29
int _lastError
SQLite3関数エラー値
Definition: Core.h:32
SqLite3操作クラス(Engine)
Definition: Engine.h:19
sqlite3 * GetEngine()
エンジン部を取得
Definition: Engine.h:96
SqLite3操作クラス(Statement)
Definition: Statement.h:20
LPCTSTR GetColumnType(int position)
カラムタイプの取得
Definition: Statement.h:162
sqlite3_stmt * _statement
ステートメント
Definition: Statement.h:220
bool Bind(int position, LPCSTR value)
パラメータのバインド処理
Definition: Statement.h:102
bool Bind(int position, LPCWSTR value)
パラメータのバインド処理
Definition: Statement.h:114
sqlite3_int64 GetInt64Value(int position)
行データの取得
Definition: Statement.h:178
double GetDoubleValue(int position)
行データの取得
Definition: Statement.h:186
LPCTSTR GetString16Value(int position)
行データの取得
Definition: Statement.h:202
bool Bind(int position, int value)
パラメータのバインド処理
Definition: Statement.h:66
Statement()
コンストラクタ
Definition: Statement.h:23
LPCTSTR GetColumnName(int position)
カラム名の取得
Definition: Statement.h:155
int GetColumns()
カラム数の取得
Definition: Statement.h:148
bool Bind(int position, sqlite3_int64 value)
パラメータのバインド処理
Definition: Statement.h:78
bool ResetBind()
バインドのリセット
Definition: Statement.h:136
bool Prepare(Engine engine, LPCTSTR lpctszSQL)
SQLステートメントの準備
Definition: Statement.h:42
bool Bind(int position)
パラメータのバインド処理
Definition: Statement.h:54
bool Finalize()
終了処理
Definition: Statement.h:211
bool Execute()
ステートメント実行
Definition: Statement.h:126
virtual ~Statement()
デストラクタ
Definition: Statement.h:30
int GetIntValue(int position)
行データの取得
Definition: Statement.h:170
bool Bind(int position, double value)
パラメータのバインド処理
Definition: Statement.h:90
LPCSTR GetStringValue(int position)
行データの取得
Definition: Statement.h:194
Definition: DBLibrary.h:12
sqlite_int64 sqlite3_int64
Definition: sqlite3.h:281
SQLITE_API const void * sqlite3_column_decltype16(sqlite3_stmt *, int)
SQLITE_API int sqlite3_bind_null(sqlite3_stmt *, int)
SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt)
SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *)
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt *, int, const void *, int, void(*)(void *))
SQLITE_API int sqlite3_bind_text(sqlite3_stmt *, int, const char *, int, void(*)(void *))
SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt)
SQLITE_API int sqlite3_bind_double(sqlite3_stmt *, int, double)
SQLITE_API int sqlite3_bind_int(sqlite3_stmt *, int, int)
SQLITE_API const void * sqlite3_column_text16(sqlite3_stmt *, int iCol)
SQLITE_API int sqlite3_step(sqlite3_stmt *)
SQLITE_API const void * sqlite3_column_name16(sqlite3_stmt *, int N)
SQLITE_API int sqlite3_prepare16(sqlite3 *db, const void *zSql, int nByte, sqlite3_stmt **ppStmt, const void **pzTail)
SQLITE_API const unsigned char * sqlite3_column_text(sqlite3_stmt *, int iCol)
struct sqlite3_stmt sqlite3_stmt
Definition: sqlite3.h:3703
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *, int, sqlite3_int64)