1 |
afaq |
1.1 |
#ifndef _ResultSet_hpp_included_
|
2 |
|
|
#define _ResultSet_hpp_included_
|
3 |
|
|
|
4 |
|
|
#include <string>
|
5 |
|
|
#include <vector>
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* A ResultSet Class
|
10 |
|
|
* This class holds all the data indexed by rows and columns that is returned by executing the sql queries.
|
11 |
|
|
* There are methods to retrive and set the data at any particular index. It also holds the column names of the columns fetched from the database.
|
12 |
|
|
*/
|
13 |
|
|
class ResultSet {
|
14 |
|
|
private:
|
15 |
|
|
int noOfCols;/* An integer to store the number of columns in this ResultSet */
|
16 |
|
|
int noOfRows;/* An integer to store the number of rows in this ResultSet */
|
17 |
|
|
std::vector<std::string> data; /*A vector of string to hold the data of the ResultSet */
|
18 |
|
|
std::vector<std::string> colName; /* A vector of string to hold colNames retuned from database */
|
19 |
|
|
typedef std::vector<std::string>::iterator ColIterator; /*Iterator for vector of colNames*/
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
public:
|
23 |
|
|
|
24 |
|
|
/**
|
25 |
|
|
* @param noOfRows an integer that represents the number of rows in the ResultSet.
|
26 |
|
|
* @param noOfCols an integer that represents the number of coloums in the ResultSet.
|
27 |
|
|
*/
|
28 |
|
|
|
29 |
|
|
ResultSet(int noOfRows, int noOfCols);
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
//Anzar is adding these three functions.
|
33 |
|
|
ResultSet();
|
34 |
|
|
void setNoOfRows(int);
|
35 |
|
|
void setNoOfCols(int);
|
36 |
|
|
/**
|
37 |
|
|
* A default destructor .
|
38 |
|
|
*/
|
39 |
|
|
~ResultSet();
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* This method is to fetch the data element at a particular index from the ResultSet.
|
43 |
|
|
* @param row an integer representing the row at which the data value has to be retrived.
|
44 |
|
|
* @param col an integer representing the column at which the data value has to be retrived.
|
45 |
|
|
* @return a string representing the actual value of the ResultSet at the given index.
|
46 |
|
|
*/
|
47 |
|
|
std::string ResultSet::getElement(int row, int col);
|
48 |
|
|
|
49 |
|
|
/*
|
50 |
|
|
* This method is to fetch colName at the give index
|
51 |
|
|
* @param index at which the colName needs to be fetched.
|
52 |
|
|
* @return a string representating the colName
|
53 |
|
|
*/
|
54 |
|
|
std::string ResultSet::getColName(int index);
|
55 |
|
|
void ResultSet::setColName(int index, std::string value);
|
56 |
|
|
/**
|
57 |
|
|
* This method is to add the data element inside the data vector of the ResultSet.
|
58 |
|
|
* @param value a string representing the actual value that has to be inserted.
|
59 |
|
|
*/
|
60 |
|
|
void ResultSet::addElement(std::string value);
|
61 |
|
|
|
62 |
|
|
/**
|
63 |
|
|
* This method is to add the colName in the colName vector of the ResultSet.
|
64 |
|
|
* @param value a string representing the actual name that has to be inserted.
|
65 |
|
|
*/
|
66 |
|
|
void ResultSet::addColName(std::string value);
|
67 |
|
|
|
68 |
|
|
/**
|
69 |
|
|
* This method is used to get the number of rows in this ResultSet.
|
70 |
|
|
* @return an integer representing the value of the number of rows.
|
71 |
|
|
*/
|
72 |
|
|
int getNoOfRows();
|
73 |
|
|
|
74 |
|
|
/**
|
75 |
|
|
* This method is used to get the number of columns in this ResultSet.
|
76 |
|
|
* @return an integer representing the value of the number of columns.
|
77 |
|
|
*/
|
78 |
|
|
int getNoOfCols();
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
/**
|
82 |
|
|
* This method is used to get the index of the colName inside the colName vector in this ResultSet.
|
83 |
|
|
* @param colNameIn a string representing the actual name of the coloumn for which index needs to be fetched.
|
84 |
|
|
* @return an integer representing the index of the colName in colName vector.
|
85 |
|
|
*/
|
86 |
|
|
int getColIndex(std::string colNameIn);
|
87 |
|
|
};
|
88 |
|
|
|
89 |
|
|
#endif
|
90 |
|
|
|