blob: 7510408a48916b985809ea6ca3a18c8e6d0d55b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Helper Class for SQLite backed storage
#pragma once
#include <memory>
#include <SQLiteCpp/SQLiteCpp.h>
class CompiledSQL
{
public:
CompiledSQL(SQLite::Database& db);
void init(const std::string& stmt);
// index 1-based as in SQLite
template<typename T>
void bind(int index, T value)
{
m_stmt->bind(index, value);
}
bool execute();
// index 0-based as in SQLite
template<typename T>
T getColumn(const int index)
{
return m_stmt->getColumn(index);
}
private:
std::shared_ptr<SQLite::Statement> m_stmt;
SQLite::Database& m_db;
bool m_isSelect; // In SQLite, SELECT statements will be handled w/ executeStep(), others w/ exec()
};
|