/*
 * DatabaseDriver.h
 *
 *  Created on: Jan 14, 2014
 *      Author: Stephan Krynauw
 *      Email:  stephan@kses.net
 */

#ifndef SQLITE3DRIVER_H_
#define SQLITE3DRIVER_H_

#include <stdio.h>
#include <sqlite3.h>
#include <string.h>
#include <vector>
#include "DatabaseDriver.h"

using namespace std;
class sqlite3Driver : public DatabaseDriver {
public:
	//openInMemory specifies whether the database should be opened in memory
	//createIfNotExist specifies whether the database should be created if it doesn't exist
	sqlite3Driver(const char* _DatabaseName, bool openInMemory,char** errString, bool createIfNotExist);
	TableData* execSelectSQL(char* sql, const TableData* origTableData,char** errString);
	int execOtherSQL(char* sql,char** errString);
	int execOtherSQL(char** sql, vector<TableData*>* dataVect,char** errString);
	int execSchemaCheck(TableData* tableData,char** errString);
	virtual ~sqlite3Driver();

private:
	int loadOrSaveDb(sqlite3 *pInMemory, const char *zFilename, int isSave);
	char* DatabaseName;
	sqlite3* Database;
	bool inMemory;
};

#endif /* SQLITE3DRIVER_H_ */
