RecipeDB/model/database/resulttable.h

50 lines
1.1 KiB
C
Raw Normal View History

#ifndef RESULTTABLE_H
#define RESULTTABLE_H
#include <vector>
#include <string>
#include "SQLite/sqlite3.h"
using namespace std;
/**
* @brief The ResultTable class is an object that contains the results of an SQL query, in string form.
*/
typedef vector<string> TableRow;
class ResultTable
{
public:
//Constructs an empty table.
ResultTable();
2018-03-03 07:48:55 +00:00
//Constructs a table with the original query saved.
ResultTable(string query);
//Gets all the data from the result set and stores it internally as strings.
void extractData(sqlite3_stmt* stmt);
//Stores the information from one row of a result set.
void processRow(sqlite3_stmt* stmt);
//Displays the data somewhat legibly.
void printData();
bool isEmpty();
string at(unsigned int row, unsigned int col);
int getReturnCode();
2018-03-03 07:48:55 +00:00
string getOriginalQuery();
unsigned int columnCount();
unsigned int rowCount();
vector<vector<string>> rows();
private:
vector<vector<string>> values;
int queryCode;
2018-03-03 07:48:55 +00:00
string originalQuery;
//Utility methods.
string convertToString(sqlite3_value* val);
bool isIndexValid(unsigned int row, unsigned int col);
};
#endif // RESULTTABLE_H