2018-02-02 12:27:57 +00:00
|
|
|
#ifndef DATABASE_H
|
|
|
|
#define DATABASE_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "SQLite/sqlite3.h"
|
2018-02-12 14:15:04 +00:00
|
|
|
#include "model/recipe/ingredients/ingredient.h"
|
2018-02-02 12:27:57 +00:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
class Database
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Database(string filename);
|
2018-02-12 13:24:11 +00:00
|
|
|
~Database();
|
2018-02-02 12:27:57 +00:00
|
|
|
|
|
|
|
void insertIngredient(Ingredient);
|
2018-02-12 13:24:11 +00:00
|
|
|
|
2018-02-02 12:27:57 +00:00
|
|
|
private:
|
2018-02-12 13:24:11 +00:00
|
|
|
//SQL Instance variables.
|
2018-02-02 12:27:57 +00:00
|
|
|
string filename;
|
|
|
|
sqlite3* db;
|
2018-02-12 13:24:11 +00:00
|
|
|
bool dbIsOpen;
|
2018-02-02 12:27:57 +00:00
|
|
|
int returnCode;
|
|
|
|
string sql;
|
|
|
|
char* errorMsg;
|
|
|
|
|
|
|
|
void openConnection();
|
2018-02-12 13:24:11 +00:00
|
|
|
void closeConnection();
|
|
|
|
//Guarantees that all tables from the schema exist.
|
|
|
|
void ensureTablesExist();
|
|
|
|
|
|
|
|
//Utility methods.
|
|
|
|
bool tableExists(string tableName);
|
2018-02-02 12:27:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DATABASE_H
|