WebFramework v3.0.12
Web framework for C++.
Loading...
Searching...
No Matches
SQLiteDatabase.h
1#pragma once
2
3#include "Import/WebFrameworkCore.h"
4
5#include <sqlite3.h>
6
7#ifndef __LINUX__
8#pragma push_macro("max")
9
10#undef max
11#endif
12
13namespace std
14{
15 template<>
16 struct default_delete<sqlite3>
17 {
18 void operator ()(sqlite3* ptr) const
19 {
20 sqlite3_close(ptr);
21 }
22 };
23}
24
25namespace framework
26{
27 namespace sqlite
28 {
29 class SQLiteDatabaseModel;
30
35 class WEB_FRAMEWORK_API SQLiteDatabase
36 {
37 private:
38 std::string databaseName;
39 std::unique_ptr<sqlite3> db;
40
41 private:
42 sqlite3* operator * ();
43
44 public:
45 SQLiteDatabase(std::string_view databaseName);
46
47 SQLiteDatabase(SQLiteDatabase&& other) noexcept = default;
48
53
57 SQLiteDatabase& operator = (const SQLiteDatabase&) = delete;
58
63 SQLiteDatabase& operator = (SQLiteDatabase&& other) noexcept = default;
64
69 const std::string& getDatabaseName() const;
70
74 void close();
75
80 bool isOpen() const;
81
86 const sqlite3* const operator * () const;
87
88 ~SQLiteDatabase() = default;
89
90 public:
91 friend class SQLiteDatabaseModel;
92 };
93 }
94}
95
96#ifndef __LINUX__
97#pragma pop_macro("max")
98#endif
Wrapper class for sqlite3 library.
SQLiteDatabase(const SQLiteDatabase &)=delete
Can't copy connection handle from another database.
Providing SELECT, INSERT, UPDATE, DELETE or raw queries for SQLiteDatabase.