35 lines
718 B
C++
35 lines
718 B
C++
#ifndef __DATABASE_H__
|
|
#define __DATABASE_H__
|
|
|
|
#include "sqlite3.h"
|
|
#include <string>
|
|
#include <optional>
|
|
#include <set>
|
|
#include <map>
|
|
|
|
class Database {
|
|
|
|
public:
|
|
Database();
|
|
~Database();
|
|
|
|
bool open();
|
|
bool exec(const char* sqlQuery);
|
|
bool exec(const std::string& sqlQuery);
|
|
|
|
/// returns true if the sql statment returns at least one row
|
|
std::optional<int64_t> getInt(const char* sql);
|
|
|
|
std::optional<int64_t> insert(const char* sql);
|
|
|
|
std::set<std::string> getStrSet(const std::string& sql);
|
|
|
|
std::map<std::string, std::string> getStrMap(const std::string& sql);
|
|
|
|
private:
|
|
sqlite3_stmt* prepareStmt(const std::string& sql);
|
|
|
|
sqlite3* m_db;
|
|
};
|
|
|
|
#endif // __DATABASE_H__
|