final_project/Interface.cpp
// currently does not check for dupes nor does it check for sane scores

currently does not check for dupes nor does it check for sane scores
currently does not check for dupes nor does it check for sane scores
void import_grades(const std::string& filename, std::vector<Grade>& grades){
        std::ifstream ifs(filename);
        if (!ifs){
            std::cout << "Could not open file \"" << filename << "\".\n"
                << "Make sure file exists and is readable\n";
        }
        int i = 0;
        while(ifs){
            std::regex expression(R"(^(.+)\t(\d+|\d+\.\d+)\t(\d+|\d+\.\d+))");
            std::smatch matches;
            std::string line;
            std::getline(ifs, line);
            if(std::regex_search(line, matches, expression)){
                std::string title = matches[1].str();
                double max_score = std::stod(matches[2].str());
                double score = std::stod(matches[3].str());
                grades.emplace_back(title, score, max_score, "none\n");
                ++i;
            }
        }
        std::cout << i << " assignments imported.\n";
    }
void import_grades ( const std :: string & filename , std :: vector < Grade > & grades ) { std :: ifstream ifs ( filename ) ; if ( ! ifs ) { std :: cout << " \" " << filename << " \" \n " << " \n " ; } int i = 0 ; while ( ifs ) { std :: regex expression ( R" ( ^(.+)\t(\d+|\d+\.\d+)\t(\d+|\d+\.\d+) ) " ) ; std :: smatch matches ; std :: string line ; std :: getline ( ifs , line ) ; if ( std :: regex_search ( line , matches , expression ) ) { std :: string title = matches [ 1 ] . str ( ) ; double max_score = std :: stod ( matches [ 2 ] . str ( ) ) ; double score = std :: stod ( matches [ 3 ] . str ( ) ) ; grades . emplace_back ( title , score , max_score , " \n " ) ; ++ i ; } } std :: cout << i << " \n " ; }
currently does not check for dupes nor does it check for sane scores
currently does not check for dupes nor does it check for sane scores
// using regex here saves us a lot of input checking
 //std::regex expression("^(.+)\\t(\\d+|\\d+\\.\\d+)\\t(\\d+|\\d+\\.\\d+)$");
 // Expression matches beginning of the line
 // plus any character up to a tab character
 // plus one+ digits or one+ digits plus a dot and another one+ digits
 // followed by a tab character
 // plus one+ digits or one+ digits plus a dot and another one+ digits
 // EOL match ('$') does not seem to work.
 // This looks to be an issue with the compiler
 // (both GCC 9.3.0 and Clang7) itself.
 // https://stackoverflow.com/questions/61195222/stdregexmultiline-does-not-exist
 // Viewing the header files confirms this.
 // Note that the multiline feature may not actually help solve the EOL issue.
 // This expression is good enough;
 // it will just silently ignore extra trailing data.
 // It also (conveniently) ignores negative values
