Alternate e697dbe9c5997e35395fe158628dd8c5209481da
for Visual Studio 2022 and Windows 11.
読み取り中…
検索中…
一致する文字列を見つけられません
Engine.h
[詳解]
1
5
6#pragma once
7
8#include <Windows.h>
9#include "sqlite3.h"
10#include "Core.h"
11
12namespace alt
13{
14 namespace db
15 {
18 class Engine : public Core
19 {
20 public:
23 :Core ()
24 {
25 _engine = nullptr;
27 }
28
30 virtual ~Engine ()
31 {
32 if (_engine != nullptr) Close ();
33 }
34
36 LPCTSTR GetErrorMessage ()
37 {
38 return (LPCTSTR)::sqlite3_errmsg16 (_engine);
39 }
40
43 bool Create (LPCTSTR lpctszDBName)
44 {
45 _lastError = ::sqlite3_open16 (lpctszDBName, &_engine);
46 return getResponse ();
47 }
48
50 bool Close ()
51 {
53 _engine = nullptr;
54 return getResponse ();
55 }
56
59 bool Execute (LPCSTR lpcszSQL)
60 {
61 _lastError = ::sqlite3_exec (_engine, lpcszSQL, nullptr, nullptr, nullptr);
62 return getResponse ();
63 }
64
67 {
68 return Execute ("BEGIN;");
69 }
70
73 {
74 return Execute ("COMMIT;");
75 }
76
79 {
80 return Execute ("ROLLBACK;");
81 }
82
84 bool Vacuum ()
85 {
86 return Execute ("VACUUM;");
87 }
88
90 ULONGLONG GetLastRowID ()
91 {
92 return ::sqlite3_last_insert_rowid (_engine);
93 }
94
97 {
98 return _engine;
99 }
100
101 protected:
104 };
105 }
106}
SqLite3操作クラス(Core)
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
ULONGLONG GetLastRowID()
最後の実行時のROWIDを取得
Definition: Engine.h:90
LPCTSTR GetErrorMessage()
エラーメッセージの取得
Definition: Engine.h:36
sqlite3 * GetEngine()
エンジン部を取得
Definition: Engine.h:96
bool Vacuum()
空き領域の整理
Definition: Engine.h:84
bool Close()
DBファイルのクローズ
Definition: Engine.h:50
virtual ~Engine()
デストラクタ
Definition: Engine.h:30
Engine()
コンストラクタ
Definition: Engine.h:22
bool BeginTransaction()
トランザクション開始
Definition: Engine.h:66
bool RollbackTransaction()
トランザクションロールバック
Definition: Engine.h:78
sqlite3 * _engine
SQLite3コンテキスト
Definition: Engine.h:103
bool CommitTransaction()
トランザクションコミット
Definition: Engine.h:72
bool Create(LPCTSTR lpctszDBName)
DBファイルの作成・オープン
Definition: Engine.h:43
bool Execute(LPCSTR lpcszSQL)
SQLステートメント実行
Definition: Engine.h:59
Definition: DBLibrary.h:12
struct sqlite3 sqlite3
Definition: sqlite3.h:249
#define SQLITE_OK
Definition: sqlite3.h:425
SQLITE_API int sqlite3_exec(sqlite3 *, const char *sql, int(*callback)(void *, int, char **, char **), void *, char **errmsg)
SQLITE_API const void * sqlite3_errmsg16(sqlite3 *)
SQLITE_API int sqlite3_close(sqlite3 *)
SQLITE_API int sqlite3_open16(const void *filename, sqlite3 **ppDb)