39 lines
711 B
C++
39 lines
711 B
C++
#ifndef DATABASE_HPP_
|
|
#define DATABASE_HPP_
|
|
|
|
#include <string>
|
|
#include <map>
|
|
#include <sqlite3.h>
|
|
|
|
|
|
class DatabaseError {};
|
|
|
|
typedef std::map<std::string, std::string> result_t;
|
|
|
|
// resource management class
|
|
class PreparedStatement {
|
|
public:
|
|
friend class DatabaseHandle;
|
|
|
|
~PreparedStatement();
|
|
result_t next();
|
|
private:
|
|
PreparedStatement(sqlite3 *dbh, const std::string& statement);
|
|
sqlite3_stmt *stmt;
|
|
};
|
|
|
|
|
|
// resource management class
|
|
class DatabaseHandle {
|
|
public:
|
|
DatabaseHandle(const std::string& filename);
|
|
~DatabaseHandle();
|
|
sqlite3 *getHandle() { return dbh; }
|
|
PreparedStatement prepareStatement(const std::string& statement);
|
|
private:
|
|
sqlite3 *dbh;
|
|
};
|
|
|
|
|
|
#endif /* DATABASE_HPP_ */
|