blob: 923be8302f7400572f797acf62145b8e5b50c44e (
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
|
// 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);
template<typename T>
void bind(int index, T value)
{
m_stmt->bind(index, value);
}
bool execute();
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()
};
|