1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
void select(std::string table, std:: string attribute, std::string value){
/****students table****/
if (table == "students"){
//initializing iterators
std::list<std::string>::iterator id_column_iterator = Students::id_column.begin(); /*****this is line 66 as per output dialog******/
std::list<std::string>::iterator first_name_iterator = Students::first_name.begin();
std::list<std::string>::iterator last_name_iterator = Students::last_name.begin();
//iterating through row values until a match is found in a method similar to table print functions
do{
if(attribute == "id" && *id_column_iterator == "value")
std::cout << *id_column_iterator << "," << *first_name_iterator << "," << *last_name_iterator << "\n";
else if(attribute == "first" && *first_name_iterator == "value")
std::cout << *id_column_iterator << "," << *first_name_iterator << "," << *last_name_iterator << "\n";
else if(attribute == "last" && *last_name_iterator == "value")
std::cout << *id_column_iterator << "," << *first_name_iterator << "," << *last_name_iterator << "\n";
++id_column_iterator;
++first_name_iterator;
++last_name_iterator;
}while (id_column_iterator != Students::id_column.end());
}/**end students table**/
/****grades table****/
else if (table == "grades"){
//initializing iterators
std::list<std::string>::iterator grades_column_iterator = Grades::grades_column.begin();/****this is line 89****/
std::list<std::string>::iterator id_column_iterator = Grades::id_column.begin();
std::list<std::string>::iterator year_column_iterator = Grades::year_column.begin();
std::list<std::string>::iterator term_column_iterator = Grades::term_column.begin();
//iterating through row values until a match is found in a method similar to table print functions
do{
if(attribute == "id" && *id_column_iterator == "value")
std::cout << *id_column_iterator << "," << *term_column_iterator << "," << *year_column_iterator << "," << *grades_column_iterator;
else if(attribute == "term" && *term_column_iterator == "value")
std::cout << *id_column_iterator << "," << *term_column_iterator << "," << *year_column_iterator << "," << *grades_column_iterator;
else if(attribute == "year" && *year_column_iterator == "value")
std::cout << *id_column_iterator << "," << *term_column_iterator << "," << *year_column_iterator << "," << *grades_column_iterator;
else if(attribute == "grades" && *grades_column_iterator == "value")
std::cout << *id_column_iterator << "," << *term_column_iterator << "," << *year_column_iterator << "," << *grades_column_iterator;
++id_column_iterator;
++grades_column_iterator;
++term_column_iterator;
++year_column_iterator;
}while (id_column_iterator != Grades::id_column.end());
}/**end grades table**/
else
std::cout << "Error! " << attribute << " should be \"students\" or \"grades\" \n";
}
|