diff --git a/siteupdate/cplusplus/classes/GraphGeneration/HighwayGraph.cpp b/siteupdate/cplusplus/classes/GraphGeneration/HighwayGraph.cpp index 5a25f03b..0faf6eb6 100644 --- a/siteupdate/cplusplus/classes/GraphGeneration/HighwayGraph.cpp +++ b/siteupdate/cplusplus/classes/GraphGeneration/HighwayGraph.cpp @@ -337,9 +337,9 @@ class HighwayGraph void write_subgraphs_tmg( std::vector &graph_vector, std::string path, size_t graphnum, unsigned int threadnum, WaypointQuadtree *qt, ElapsedTime *et) { unsigned int cv_count, tv_count; - std::ofstream simplefile((path+graph_vector[graphnum].filename()).data()); - std::ofstream collapfile((path+graph_vector[graphnum+1].filename()).data()); - std::ofstream travelfile((path+graph_vector[graphnum+2].filename()).data()); + std::ofstream simplefile(path+graph_vector[graphnum].filename()); + std::ofstream collapfile(path+graph_vector[graphnum+1].filename()); + std::ofstream travelfile(path+graph_vector[graphnum+2].filename()); std::unordered_set mv; std::unordered_set mse, mce, mte; std::list traveler_lists; diff --git a/siteupdate/cplusplus/classes/HighwaySystem.cpp b/siteupdate/cplusplus/classes/HighwaySystem.cpp index 42a338d3..45e137dc 100644 --- a/siteupdate/cplusplus/classes/HighwaySystem.cpp +++ b/siteupdate/cplusplus/classes/HighwaySystem.cpp @@ -33,7 +33,6 @@ class HighwaySystem std::list> &countries, std::unordered_map ®ion_hash) { char *c_country = 0; - std::string filename; std::ifstream file; // parse systems.csv line @@ -56,9 +55,8 @@ class HighwaySystem delete[] c_line; // read chopped routes CSV - filename = path+"/"+systemname+".csv"; - file.open(filename.data()); - if (!file) el.add_error("Could not open " + filename); + file.open(path+"/"+systemname+".csv"); + if (!file) el.add_error("Could not open "+path+"/"+systemname+".csv"); else { getline(file, line); // ignore header line while(getline(file, line)) { if (line.back() == 0x0D) line.erase(line.end()-1); // trim DOS newlines @@ -69,9 +67,8 @@ class HighwaySystem file.close(); // read connected routes CSV - filename = path+"/"+systemname+"_con.csv"; - file.open(filename.data()); - if (!file) el.add_error("Could not open " + filename); + file.open(path+"/"+systemname+"_con.csv"); + if (!file) el.add_error("Could not open "+path+"/"+systemname+"_con.csv"); else { getline(file, line); // ignore header line while(getline(file, line)) { if (line.back() == 0x0D) line.erase(line.end()-1); // trim DOS newlines diff --git a/siteupdate/cplusplus/classes/Route/Route.cpp b/siteupdate/cplusplus/classes/Route/Route.cpp index f0ac48ed..75eaaf92 100644 --- a/siteupdate/cplusplus/classes/Route/Route.cpp +++ b/siteupdate/cplusplus/classes/Route/Route.cpp @@ -197,7 +197,7 @@ void Route::write_nmp_merged(std::string filename) filename += "/" + system->systemname; mkdir(filename.data(), 0777); filename += "/" + root + ".wpt"; - std::ofstream wptfile(filename.data()); + std::ofstream wptfile(filename); char fstr[12]; for (Waypoint *w : point_list) { wptfile << w->label << ' '; diff --git a/siteupdate/cplusplus/classes/Route/read_wpt.cpp b/siteupdate/cplusplus/classes/Route/read_wpt.cpp index a4ba7acd..2929b823 100644 --- a/siteupdate/cplusplus/classes/Route/read_wpt.cpp +++ b/siteupdate/cplusplus/classes/Route/read_wpt.cpp @@ -10,7 +10,7 @@ void Route::read_wpt all_wpt_files->erase(filename); awf_mtx.unlock(); std::vector lines; - std::ifstream file(filename.data()); + std::ifstream file(filename); if (!file) { el->add_error("Could not open " + filename); file.close(); diff --git a/siteupdate/cplusplus/classes/TravelerList/TravelerList.cpp b/siteupdate/cplusplus/classes/TravelerList/TravelerList.cpp index a206d6b1..af2f23f4 100644 --- a/siteupdate/cplusplus/classes/TravelerList/TravelerList.cpp +++ b/siteupdate/cplusplus/classes/TravelerList/TravelerList.cpp @@ -38,16 +38,14 @@ class TravelerList traveler_num = new unsigned int[args->numthreads]; // deleted on termination of program traveler_name = travname.substr(0, travname.size()-5); // strip ".list" from end of travname - std::string filename = args->logfilepath+"/users/"+traveler_name+".log"; - std::ofstream log(filename.data()); + std::ofstream log(args->logfilepath+"/users/"+traveler_name+".log"); std::ofstream splist; - if (args->splitregionpath != "") splist.open((args->splitregionpath+"/list_files/"+travname).data()); + if (args->splitregionpath != "") splist.open(args->splitregionpath+"/list_files/"+travname); time_t StartTime = time(0); log << "Log file created at: " << ctime(&StartTime); - filename = args->userlistfilepath+"/"+travname; std::vector lines; std::vector endlines; - std::ifstream file(filename.data()); + std::ifstream file(args->userlistfilepath+"/"+travname); // we can't getline here because it only allows one delimiter, and we need two; '\r' and '\n'. // at least one .list file contains newlines using only '\r' (0x0D): // https://github.com/TravelMapping/UserData/blob/6309036c44102eb3325d49515b32c5eef3b3cb1e/list_files/whopperman.list diff --git a/siteupdate/cplusplus/classes/TravelerList/userlog.cpp b/siteupdate/cplusplus/classes/TravelerList/userlog.cpp index f1f0e014..1ea1417e 100644 --- a/siteupdate/cplusplus/classes/TravelerList/userlog.cpp +++ b/siteupdate/cplusplus/classes/TravelerList/userlog.cpp @@ -7,8 +7,7 @@ void userlog ) { char fstr[112]; std::cout << "." << std::flush; - std::string filename = path+traveler_name+".log"; - std::ofstream log(filename.data(), std::ios::app); + std::ofstream log(path+traveler_name+".log", std::ios::app); log << "Clinched Highway Statistics\n"; log << "Overall in active systems: " << format_clinched_mi(active_only_miles(), total_active_only_miles) << '\n'; log << "Overall in active+preview systems: " << format_clinched_mi(active_preview_miles(), total_active_preview_miles) << '\n'; diff --git a/siteupdate/cplusplus/functions/concurrency_detection.cpp b/siteupdate/cplusplus/functions/concurrency_detection.cpp index 3c8dfb80..612f021d 100644 --- a/siteupdate/cplusplus/functions/concurrency_detection.cpp +++ b/siteupdate/cplusplus/functions/concurrency_detection.cpp @@ -1,8 +1,7 @@ // concurrency detection -- will augment our structure with list of concurrent // segments with each segment (that has a concurrency) cout << et.et() << "Concurrent segment detection." << flush; -filename = args.logfilepath+"/concurrencies.log"; -ofstream concurrencyfile(filename.data()); +ofstream concurrencyfile(args.logfilepath+"/concurrencies.log"); timestamp = time(0); concurrencyfile << "Log file created at: " << ctime(×tamp); for (HighwaySystem *h : highway_systems) @@ -49,7 +48,7 @@ if (args.splitregion != "") { for (HighwaySystem *h : highway_systems) { if (splitsystems.find(h->systemname) == splitsystems.end()) continue; ofstream fralog; - if (args.splitregionpath != "") fralog.open((args.splitregionpath + "/logs/" + h->systemname + "-concurrencies.log").data()); + if (args.splitregionpath != "") fralog.open(args.splitregionpath + "/logs/" + h->systemname + "-concurrencies.log"); for (Route &r : h->route_list) { if (r.region->code.substr(0, args.splitregion.size()) != args.splitregion) continue; for (HighwaySegment *s : r.segment_list) diff --git a/siteupdate/cplusplus/functions/graph_generation.cpp b/siteupdate/cplusplus/functions/graph_generation.cpp index 879daa27..02b3e0d6 100644 --- a/siteupdate/cplusplus/functions/graph_generation.cpp +++ b/siteupdate/cplusplus/functions/graph_generation.cpp @@ -4,8 +4,7 @@ cout << et.et() << "Setting up for graphs of highway data." << endl; HighwayGraph graph_data(all_waypoints, highway_systems, datacheckerrors, args.numthreads, et); cout << et.et() << "Writing graph waypoint simplification log." << endl; -filename = args.logfilepath + "/waypointsimplification.log"; -ofstream wslogfile(filename.data()); +ofstream wslogfile(args.logfilepath + "/waypointsimplification.log"); for (string line : graph_data.waypoint_naming_log) wslogfile << line << '\n'; wslogfile.close(); diff --git a/siteupdate/cplusplus/functions/sql_file.cpp b/siteupdate/cplusplus/functions/sql_file.cpp index 7f159062..e5f30d35 100644 --- a/siteupdate/cplusplus/functions/sql_file.cpp +++ b/siteupdate/cplusplus/functions/sql_file.cpp @@ -12,7 +12,7 @@ void sqlfile1 ){ // Once all data is read in and processed, create a .sql file that will // create all of the DB tables to be used by other parts of the project - std::ofstream sqlfile((args->databasename+".sql").data()); + std::ofstream sqlfile(args->databasename+".sql"); // Note: removed "USE" line, DB name must be specified on the mysql command line // we have to drop tables in the right order to avoid foreign key errors @@ -363,7 +363,7 @@ void sqlfile2 std::vector *graph_vector, DatacheckEntryList *datacheckerrors ) - { std::ofstream sqlfile((args->databasename+".sql").data(), std::ios::app); + { std::ofstream sqlfile(args->databasename+".sql", std::ios::app); // datacheck errors into the db #ifndef threading_enabled diff --git a/siteupdate/cplusplus/functions/subgraphs/area.cpp b/siteupdate/cplusplus/functions/subgraphs/area.cpp index f89c9612..81ab6215 100644 --- a/siteupdate/cplusplus/functions/subgraphs/area.cpp +++ b/siteupdate/cplusplus/functions/subgraphs/area.cpp @@ -2,8 +2,7 @@ #ifndef threading_enabled cout << et.et() << "Creating area data graphs." << endl; #endif -filename = args.highwaydatapath+"/graphs/areagraphs.csv"; -file.open(filename.data()); +file.open(args.highwaydatapath+"/graphs/areagraphs.csv"); getline(file, line); // ignore header line list area_list; while (getline(file, line)) diff --git a/siteupdate/cplusplus/functions/subgraphs/multiregion.cpp b/siteupdate/cplusplus/functions/subgraphs/multiregion.cpp index a6e0bc44..b2ffcf80 100644 --- a/siteupdate/cplusplus/functions/subgraphs/multiregion.cpp +++ b/siteupdate/cplusplus/functions/subgraphs/multiregion.cpp @@ -2,8 +2,7 @@ #ifndef threading_enabled cout << et.et() << "Creating multiregion graphs." << endl; #endif -filename = args.highwaydatapath+"/graphs/multiregion.csv"; -file.open(filename.data()); +file.open(args.highwaydatapath+"/graphs/multiregion.csv"); getline(file, line); // ignore header line // add entries to graph_vector diff --git a/siteupdate/cplusplus/functions/subgraphs/multisystem.cpp b/siteupdate/cplusplus/functions/subgraphs/multisystem.cpp index 3a053cd7..dda9e76b 100644 --- a/siteupdate/cplusplus/functions/subgraphs/multisystem.cpp +++ b/siteupdate/cplusplus/functions/subgraphs/multisystem.cpp @@ -2,8 +2,7 @@ #ifndef threading_enabled cout << et.et() << "Creating multisystem graphs." << endl; #endif -filename = args.highwaydatapath+"/graphs/multisystem.csv"; -file.open(filename.data()); +file.open(args.highwaydatapath+"/graphs/multisystem.csv"); getline(file, line); // ignore header line // add entries to graph_vector diff --git a/siteupdate/cplusplus/functions/subgraphs/system.cpp b/siteupdate/cplusplus/functions/subgraphs/system.cpp index 58445997..85528d5f 100644 --- a/siteupdate/cplusplus/functions/subgraphs/system.cpp +++ b/siteupdate/cplusplus/functions/subgraphs/system.cpp @@ -5,8 +5,7 @@ cout << et.et() << "Creating system data graphs." << endl; // We will create graph data and a graph file for only a few interesting // systems, as many are not useful on their own HighwaySystem *h; -filename = args.highwaydatapath+"/graphs/systemgraphs.csv"; -file.open(filename.data()); +file.open( args.highwaydatapath+"/graphs/systemgraphs.csv"); getline(file, line); // ignore header line // add entries to graph_vector diff --git a/siteupdate/cplusplus/siteupdate.cpp b/siteupdate/cplusplus/siteupdate.cpp index 0905351e..18a8989f 100644 --- a/siteupdate/cplusplus/siteupdate.cpp +++ b/siteupdate/cplusplus/siteupdate.cpp @@ -89,7 +89,7 @@ using namespace std; int main(int argc, char *argv[]) { ifstream file; - string filename, line; + string line; mutex list_mtx, log_mtx, strtok_mtx; time_t timestamp; @@ -131,9 +131,8 @@ int main(int argc, char *argv[]) // continents list> continents; - filename = args.highwaydatapath+"/continents.csv"; - file.open(filename.data()); - if (!file) el.add_error("Could not open " + filename); + file.open(args.highwaydatapath+"/continents.csv"); + if (!file) el.add_error("Could not open "+args.highwaydatapath+"/continents.csv"); else { getline(file, line); // ignore header line while(getline(file, line)) { if (line.back() == 0x0D) line.erase(line.end()-1); // trim DOS newlines @@ -155,9 +154,8 @@ int main(int argc, char *argv[]) // countries list> countries; - filename = args.highwaydatapath+"/countries.csv"; - file.open(filename.data()); - if (!file) el.add_error("Could not open " + filename); + file.open(args.highwaydatapath+"/countries.csv"); + if (!file) el.add_error("Could not open "+args.highwaydatapath+"/countries.csv"); else { getline(file, line); // ignore header line while(getline(file, line)) { if (line.back() == 0x0D) line.erase(line.end()-1); // trim DOS newlines @@ -180,9 +178,8 @@ int main(int argc, char *argv[]) //regions list all_regions; unordered_map region_hash; - filename = args.highwaydatapath+"/regions.csv"; - file.open(filename.data()); - if (!file) el.add_error("Could not open " + filename); + file.open(args.highwaydatapath+"/regions.csv"); + if (!file) el.add_error("Could not open "+args.highwaydatapath+"/regions.csv"); else { getline(file, line); // ignore header line while(getline(file, line)) { Region rg(line, countries, continents, el); @@ -195,9 +192,8 @@ int main(int argc, char *argv[]) // Create a list of HighwaySystem objects, one per system in systems.csv file list highway_systems; cout << et.et() << "Reading systems list in " << args.highwaydatapath+"/"+args.systemsfile << "." << endl; - filename = args.highwaydatapath+"/"+args.systemsfile; - file.open(filename.data()); - if (!file) el.add_error("Could not open " + filename); + file.open(args.highwaydatapath+"/"+args.systemsfile); + if (!file) el.add_error("Could not open "+args.highwaydatapath+"/"+args.systemsfile); else { getline(file, line); // ignore header line list ignoring; while(getline(file, line)) @@ -328,9 +324,8 @@ int main(int argc, char *argv[]) //#include "debug/qt_and_colocate_check.cpp" cout << et.et() << "Finding unprocessed wpt files." << endl; - filename = args.logfilepath+"/unprocessedwpts.log"; if (all_wpt_files.size()) - { ofstream unprocessedfile(filename.data()); + { ofstream unprocessedfile(args.logfilepath+"/unprocessedwpts.log"); cout << all_wpt_files.size() << " .wpt files in " << args.highwaydatapath + "/hwy_data not processed, see unprocessedwpts.log." << endl; for (const string &f : all_wpt_files) unprocessedfile << strstr(f.data(), "hwy_data") << '\n'; unprocessedfile.close(); @@ -343,8 +338,7 @@ int main(int argc, char *argv[]) // read in fp file list nmpfplist; - filename = args.highwaydatapath+"/nmpfps.log"; - file.open(filename.data()); + file.open(args.highwaydatapath+"/nmpfps.log"); while (getline(file, line)) { while (line.back() == 0x0D || line.back() == ' ') line.erase(line.end()-1); // trim DOS newlines & whitespace if (line.size()) nmpfplist.push_back(line); @@ -352,10 +346,8 @@ int main(int argc, char *argv[]) file.close(); list nmploglines; - filename = args.logfilepath+"/nearmisspoints.log"; - ofstream nmplog(filename.data()); - filename = args.logfilepath+"/tm-master.nmp"; - ofstream nmpnmp(filename.data()); + ofstream nmplog(args.logfilepath+"/nearmisspoints.log"); + ofstream nmpnmp(args.logfilepath+"/tm-master.nmp"); for (Waypoint *w : all_waypoints.point_list()) w->nmplogs(nmpfplist, nmpnmp, nmploglines); nmpnmp.close(); @@ -366,8 +358,7 @@ int main(int argc, char *argv[]) nmplog.close(); // report any unmatched nmpfps.log entries - filename = args.logfilepath+"/nmpfpsunmatched.log"; - ofstream nmpfpsunmatchedfile(filename.data()); + ofstream nmpfpsunmatchedfile(args.logfilepath+"/nmpfpsunmatched.log"); for (string &line : nmpfplist) nmpfpsunmatchedfile << line << '\n'; nmpfpsunmatchedfile.close(); @@ -439,8 +430,7 @@ int main(int argc, char *argv[]) // just going to drop this into the DB later anyway list> updates; cout << et.et() << "Reading updates file." << endl; - filename = args.highwaydatapath+"/updates.csv"; - file.open(filename.data()); + file.open(args.highwaydatapath+"/updates.csv"); getline(file, line); // ignore header line while (getline(file, line)) { if (line.back() == 0x0D) line.erase(line.end()-1); // trim DOS newlines @@ -498,8 +488,7 @@ int main(int argc, char *argv[]) // anyway list> systemupdates; cout << et.et() << "Reading systemupdates file." << endl; - filename = args.highwaydatapath+"/systemupdates.csv"; - file.open(filename.data()); + file.open(args.highwaydatapath+"/systemupdates.csv"); getline(file, line); // ignore header line while (getline(file, line)) { if (line.back() == 0x0D) line.erase(line.end()-1); // trim DOS newlines @@ -555,8 +544,7 @@ int main(int argc, char *argv[]) // write log file for points in use -- might be more useful in the DB later, // or maybe in another format cout << et.et() << "Writing points in use log." << endl; - filename = args.logfilepath+"/pointsinuse.log"; - ofstream inusefile(filename.data()); + ofstream inusefile(args.logfilepath+"/pointsinuse.log"); timestamp = time(0); inusefile << "Log file created at: " << ctime(×tamp); for (HighwaySystem *h : highway_systems) @@ -573,8 +561,7 @@ int main(int argc, char *argv[]) // write log file for alt labels not in use cout << et.et() << "Writing unused alt labels log." << endl; - filename = args.logfilepath+"/unusedaltlabels.log"; - ofstream unusedfile(filename.data()); + ofstream unusedfile(args.logfilepath+"/unusedaltlabels.log"); timestamp = time(0); unusedfile << "Log file created at: " << ctime(×tamp); unsigned int total_unused_alt_labels = 0; @@ -620,8 +607,7 @@ int main(int argc, char *argv[]) cout << "!\n"; concurrencyfile.close(); - /*filename = args.logfilepath+"/concurrent_travelers_sanity_check.log"; - ofstream sanetravfile(filename.data()); + /*ofstream sanetravfile(args.logfilepath+"/concurrent_travelers_sanity_check.log"); for (HighwaySystem *h : highway_systems) for (Route &r : h->route_list) for (HighwaySegment *s : r.segment_list) @@ -656,8 +642,7 @@ int main(int argc, char *argv[]) cout << et.et() << "Writing highway data stats log file (highwaydatastats.log)." << endl; char fstr[112]; - filename = args.logfilepath+"/highwaydatastats.log"; - ofstream hdstatsfile(filename); + ofstream hdstatsfile(args.logfilepath+"/highwaydatastats.log"); timestamp = time(0); hdstatsfile << "Travel Mapping highway mileage as of " << ctime(×tamp); @@ -749,8 +734,7 @@ int main(int argc, char *argv[]) double total_mi; // first, overall per traveler by region, both active only and active+preview - filename = args.csvstatfilepath + "/allbyregionactiveonly.csv"; - ofstream allfile(filename.data()); + ofstream allfile(args.csvstatfilepath + "/allbyregionactiveonly.csv"); allfile << "Traveler,Total"; std::list regions; total_mi = 0; @@ -788,8 +772,7 @@ int main(int argc, char *argv[]) allfile.close(); // active+preview - filename = args.csvstatfilepath + "/allbyregionactivepreview.csv"; - allfile.open(filename.data()); + allfile.open(args.csvstatfilepath + "/allbyregionactivepreview.csv"); allfile << "Traveler,Total"; regions.clear(); total_mi = 0; @@ -828,8 +811,7 @@ int main(int argc, char *argv[]) // now, a file for each system, again per traveler by region for (HighwaySystem *h : highway_systems) - { filename = args.csvstatfilepath + "/" + h->systemname + "-all.csv"; - ofstream sysfile(filename.data()); + { ofstream sysfile(args.csvstatfilepath + "/" + h->systemname + "-all.csv"); sysfile << "Traveler,Total"; regions.clear(); total_mi = 0; @@ -867,8 +849,7 @@ int main(int argc, char *argv[]) // read in the datacheck false positives list cout << et.et() << "Reading datacheckfps.csv." << endl; - filename = args.highwaydatapath+"/datacheckfps.csv"; - file.open(filename.data()); + file.open(args.highwaydatapath+"/datacheckfps.csv"); getline(file, line); // ignore header line list> datacheckfps; //FIXME try implementing as an unordered_multiset; see if speed increases unordered_set datacheck_always_error @@ -963,8 +944,7 @@ int main(int argc, char *argv[]) // now mark false positives datacheckerrors->entries.sort(); cout << et.et() << "Marking datacheck false positives." << flush; - filename = args.logfilepath+"/nearmatchfps.log"; - ofstream fpfile(filename.data()); + ofstream fpfile(args.logfilepath+"/nearmatchfps.log"); timestamp = time(0); fpfile << "Log file created at: " << ctime(×tamp); unsigned int counter = 0; @@ -994,8 +974,7 @@ int main(int argc, char *argv[]) // write log of unmatched false positives from the datacheckfps.csv cout << et.et() << "Writing log of unmatched datacheck FP entries." << endl; - filename = args.logfilepath+"/unmatchedfps.log"; - fpfile.open(filename.data()); + fpfile.open(args.logfilepath+"/unmatchedfps.log"); timestamp = time(0); fpfile << "Log file created at: " << ctime(×tamp); if (datacheckfps.empty()) fpfile << "No unmatched FP entries.\n"; @@ -1005,8 +984,7 @@ int main(int argc, char *argv[]) // datacheck.log file cout << et.et() << "Writing datacheck.log" << endl; - filename = args.logfilepath + "/datacheck.log"; - ofstream logfile(filename.data()); + ofstream logfile(args.logfilepath + "/datacheck.log"); timestamp = time(0); logfile << "Log file created at: " << ctime(×tamp); logfile << "Datacheck errors that have been flagged as false positives are not included.\n";