lintel 0.2.0
Loading...
Searching...
No Matches
Connection.h
Go to the documentation of this file.
1#ifndef LINTEL_SQLITE_CONNECTION_H
2#define LINTEL_SQLITE_CONNECTION_H
3
4#include <sqlite3.h>
5
6#include <map>
7#include <memory>
8#include <string>
9
13
14namespace lintel {
15namespace sqlite {
16 class Transaction;
17
18 class Statement;
19
21
22 class Notify;
23
24 class Cursor;
25
30 {
31 private:
32 sqlite3 *m_db;
33
34 friend class Transaction;
35
36 friend class Statement;
37
38 friend class PreparedStatement;
39
40 friend class Notify;
41
42 friend class Cursor;
43
44 std::map<std::string, sqlite3_stmt *> m_preparedStatements;
45
46 private:
52 [[nodiscard]] std::shared_ptr<Result> execute(const std::string &statement) const;
53
60 [[nodiscard]] std::shared_ptr<Result> executeParameters(const std::string &statement,
62
68 void applyPragmas(const std::string &connectionInfo);
69
76 std::shared_ptr<Result> prepareStatement(const std::string &queryName, const std::string &query);
77
84 [[nodiscard]] std::shared_ptr<Result> executePreparedStatement(const std::string &queryName,
86
91 void finalizePreparedStatement(const std::string &queryName);
92
101 static int callBack(void *funcPtr, int argc, char **argv, char **column);
102
104 [[nodiscard]] std::string getErrorMessage() const;
105
106 public:
111 explicit Connection(const std::string &connectionInfo);
112
117 explicit Connection(const std::shared_ptr<DatabaseConnectionEntry> &connectionEntry);
118
119 Connection(Connection &connection) = delete;
120
129 [[nodiscard]] bool isHealthy() const;
130
133 };
134}// namespace sqlite
135
136}// namespace lintel
137#endif// LINTEL_SQLITE_CONNECTION_H
Definition Parameter.h:42
Definition Connection.h:30
Connection(const std::string &connectionInfo)
Connection(Connection &connection)=delete
Connection(const std::shared_ptr< DatabaseConnectionEntry > &connectionEntry)
Definition Cursor.h:28
Definition Notify.h:15
Definition PreparedStatement.h:17
Definition Statement.h:12
Definition Transaction.h:15
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9