2018-03-01 16:19:13 +00:00
|
|
|
#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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
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);
|
2018-03-01 16:19:13 +00:00
|
|
|
|
|
|
|
//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 valueAt(unsigned int row, unsigned int col);
|
2018-03-03 07:38:32 +00:00
|
|
|
int getReturnCode();
|
2018-03-03 07:48:55 +00:00
|
|
|
string getOriginalQuery();
|
2018-03-01 16:19:13 +00:00
|
|
|
unsigned int columnCount();
|
|
|
|
unsigned int rowCount();
|
|
|
|
private:
|
|
|
|
vector<vector<string>> values;
|
2018-03-03 07:38:32 +00:00
|
|
|
int queryCode;
|
2018-03-03 07:48:55 +00:00
|
|
|
string originalQuery;
|
2018-03-01 16:19:13 +00:00
|
|
|
|
|
|
|
//Utility methods.
|
|
|
|
string convertToString(sqlite3_value* val);
|
|
|
|
bool isIndexValid(unsigned int row, unsigned int col);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RESULTTABLE_H
|