childprot/Database.hpp

39 lines
711 B
C++
Raw Normal View History

2013-03-27 20:07:19 +01:00
#ifndef DATABASE_HPP_
#define DATABASE_HPP_
#include <string>
2013-03-27 23:09:15 +01:00
#include <map>
2013-03-27 20:07:19 +01:00
#include <sqlite3.h>
class DatabaseError {};
2013-03-27 23:09:15 +01:00
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;
};
2013-03-27 20:07:19 +01:00
// resource management class
class DatabaseHandle {
public:
DatabaseHandle(const std::string& filename);
~DatabaseHandle();
sqlite3 *getHandle() { return dbh; }
2013-03-27 23:09:15 +01:00
PreparedStatement prepareStatement(const std::string& statement);
2013-03-27 20:07:19 +01:00
private:
sqlite3 *dbh;
};
#endif /* DATABASE_HPP_ */