RecipeDB/model/database/database.h

39 lines
673 B
C
Raw Normal View History

#ifndef DATABASE_H
#define DATABASE_H
#include <string>
#include <vector>
#include "SQLite/sqlite3.h"
#include "model/recipe/ingredients/ingredient.h"
using namespace std;
class Database
{
public:
Database(string filename);
2018-02-12 13:24:11 +00:00
~Database();
void insertIngredient(Ingredient);
2018-02-12 13:24:11 +00:00
private:
2018-02-12 13:24:11 +00:00
//SQL Instance variables.
string filename;
sqlite3* db;
2018-02-12 13:24:11 +00:00
bool dbIsOpen;
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);
};
#endif // DATABASE_H