//build Presentations void BuildPresentation(string input) { //get the name of the file fileName = input; //start stream of object ifstream fileStream(fileName.c_str(), ios::in | ios::binary); //start keeping track of column ColIndex colIndex; columnNumber = 0; //FIRST ROW FOR COLUMNS //get first row fileStream >> ws; getline(fileStream, firstRow); //seperate first row istringstream firstRowStream(firstRow); //now put in first rows value and put into struct while (getline(firstRowStream, columnName, ',')) { //compare column name to variable, if a column appears, put in relevant //erase "\n\r" from the string, this only applies if the column is at the very end of the line, but it messes upt it reading it columnName.erase(columnName.find_last_not_of("\n\r") + 1); //name if (columnName == "Member Name") { colIndex.name_loc = columnNumber; } //domain else if (columnName == "Primary Domain") { colIndex.domain_loc = columnNumber; } //research role else if (columnName == "Role") { colIndex.role_loc = columnNumber; } //research role else if (columnName == "Title") //there is also Short Title { colIndex.title_loc = columnNumber; } //presentation type else if (columnName == "Type") { colIndex.type_loc = columnNumber; } //Presentation Date else if (columnName == "Date") { colIndex.date_loc = columnNumber; } //take note of column number, starts at 0 columnNumber++; } //SEND RAW ROW AND STRUCT collndex TO rowObject TO MAKE ROW THAT WILL BE PUT IN DICTIONARY //use member name as dictionary string temp; //Builder object PresentationRowBuilder Builder; presentationsDictionary = new multimap<string, Pres_rowObject>(); int count = 0; //attributes for checking for duplicates multimap<string, Pres_rowObject>::iterator check; bool existAlready = false; //get raw row and put into temp // go until carriage return while (getline(fileStream, temp, '\r')) { //erase the new lines in the line temp.erase(std::remove(temp.begin(), temp.end(), '\n'), temp.end()); //make new object and insert into map Pres_rowObject holder = Builder.buildRow(temp, colIndex); if (holder.errorFlag == false) { existAlready = false; //find if holder has already entry //duplicate check check = presentationsDictionary->find(holder.name); while (check != presentationsDictionary->end()) { //check if holder already exists //by type, role, title, and date if (check->second.name == holder.name && check->second.type == holder.type && check->second.role == holder.role && check->second.title == holder.title && check->second.date == holder.date) { //confirm that this is a duplicate existAlready = true; count++; } check++; } //if there is no duplicate, add it in to the map if (existAlready == false) { presentationsDictionary->insert(pair<string, Pres_rowObject>(holder.name, holder)); count++; existAlready = false; } } else if (holder.errorFlag == true) { addPresError(count, holder); count++; } } }
//build Presentations //status: unfinished, needs right objects void BuildPresentation(string input) { //get the name of the file fileName = input; //start stream of object ifstream fileStream(fileName.c_str(), ios::in | ios::binary); //start keeping track of column ColIndex colIndex; columnNumber = 0; //FIRST ROW FOR COLUMNS //get first row fileStream >> ws; getline(fileStream, firstRow); //seperate first row istringstream firstRowStream(firstRow); //now put in first rows value and put into struct while (getline(firstRowStream, columnName, ',')) { //compare column name to variable, if a column appears, put in relevant //erase "\n\r" from the string, this only applies if the column is at the very end of the line, but it messes upt it reading it columnName.erase(columnName.find_last_not_of("\n\r") + 1); //name if (columnName == "Member Name") { colIndex.name_loc = columnNumber; } //domain else if (columnName == "Primary Domain") { colIndex.domain_loc = columnNumber; } //research role else if (columnName == "Role") { colIndex.role_loc = columnNumber; } //research role else if (columnName == "Title") //there is also Short Title { colIndex.title_loc = columnNumber; } //presentation type else if (columnName == "Type") { colIndex.type_loc = columnNumber; } //Presentation Date else if (columnName == "Date") { colIndex.date_loc = columnNumber; } //take note of column number, starts at 1 columnNumber++; } //SEND RAW ROW AND STRUCT collndex TO rowObject TO MAKE ROW THAT WILL BE PUT IN DICTIONARY //use member name as dictionary string temp; //Builder object PresentationRowBuilder Builder; presentationsDictionary = new multimap<string, Pres_rowObject>(); //get raw row and put into temp // go until carriage return while (getline(fileStream, temp, '\r')) { //erase the new lines in the line temp.erase(std::remove(temp.begin(), temp.end(), '\n'), temp.end()); //make new object and insert into map Pres_rowObject holder = Builder.buildRow(temp, colIndex); if (holder.errorFlag == false) { presentationsDictionary->insert(pair<string, Pres_rowObject>(holder.name, holder)); } else { } } }