diff --git a/simdata/include/simdata.h b/simdata/include/simdata.h index df04645..9170e86 100644 --- a/simdata/include/simdata.h +++ b/simdata/include/simdata.h @@ -20,10 +20,10 @@ namespace germanairlinesva_simdata void makeAirport( const std::string &kind, - std::ifstream *infile, + std::ifstream &infile, std::map, std::vector>> - *airports, - std::ofstream *logfile); + &airports, + std::ofstream &logfile); void makeGate15(std::vector *gates, std::vector fields); void makeRunway(std::vector *runways, std::vector fields); diff --git a/simdata/simdata.cpp b/simdata/simdata.cpp index d77667a..2bc7396 100644 --- a/simdata/simdata.cpp +++ b/simdata/simdata.cpp @@ -27,7 +27,7 @@ namespace germanairlinesva_simdata // Default logfile << " " << defaultFile << std::endl; - makeAirport("DEFAULT", &base, &airports, &logfile); + makeAirport("DEFAULT", base, airports, logfile); base.close(); std::string line; @@ -47,7 +47,7 @@ namespace germanairlinesva_simdata std::ifstream pack(path); if (pack.good()) { logfile << " " << path << std::endl; - makeAirport("CUSTOM", &pack, &airports, &logfile); + makeAirport("CUSTOM", pack, airports, logfile); pack.close(); } else { pack.close(); @@ -66,10 +66,10 @@ namespace germanairlinesva_simdata void makeAirport( const std::string &kind, - std::ifstream *infile, + std::ifstream &infile, std::map, std::vector>> - *airports, - std::ofstream *logfile) + &airports, + std::ofstream &logfile) { std::string line; std::string *currentIcao = nullptr; @@ -79,7 +79,7 @@ namespace germanairlinesva_simdata int apCount = 0; int validCount = 0; - while (std::getline(*infile, line)) { + while (std::getline(infile, line)) { std::vector fields = germanairlinesva_util::split(line, ' '); fields = germanairlinesva_util::select_T( fields, @@ -91,54 +91,52 @@ namespace germanairlinesva_simdata // Write to file if ICAO is valid, and we have gates and runways if (currentIcao != nullptr && !tmpRunways.empty() && !tmpGates.empty()) { - (*airports)[*currentIcao] = {tmpGates, tmpRunways}; + airports[*currentIcao] = {tmpGates, tmpRunways}; validCount += 1; - *logfile << "\t " << *currentIcao << " committed" - << std::endl; + logfile << "\t " << *currentIcao << " committed" << std::endl; } else if (currentIcao != nullptr) { - *logfile << "\t " << *currentIcao - << " had no gates or runways" << std::endl; + logfile << "\t " << *currentIcao << " had no gates or runways" + << std::endl; } tmpGates = std::vector(); tmpRunways = std::vector(); currentIcao = new std::string(fields[4]); apCount += 1; - *logfile << "\t<" << kind << "> " << line << std::endl; + logfile << "\t<" << kind << "> " << line << std::endl; } else if (currentIcao != nullptr && fields[0] == "15") { makeGate15(&tmpGates, fields); - *logfile << "\t\t " << line << std::endl; + logfile << "\t\t " << line << std::endl; } else if (fields[0] == "16" || fields[0] == "17") { // Write to file if ICAO is valid, and we have gates and runways if (currentIcao != nullptr && !tmpRunways.empty() && !tmpGates.empty()) { - (*airports)[*currentIcao] = {tmpGates, tmpRunways}; + airports[*currentIcao] = {tmpGates, tmpRunways}; validCount += 1; - *logfile << "\t " << *currentIcao << " committed" - << std::endl; + logfile << "\t " << *currentIcao << " committed" << std::endl; } else if (currentIcao != nullptr) { - *logfile << "\t " << *currentIcao - << " had no gates or runways" << std::endl; + logfile << "\t " << *currentIcao << " had no gates or runways" + << std::endl; } tmpGates = std::vector(); tmpRunways = std::vector(); currentIcao = nullptr; - *logfile << "\t<" << kind << " SKIPPED> " << line << std::endl; + logfile << "\t<" << kind << " SKIPPED> " << line << std::endl; } else if (currentIcao != nullptr && fields[0] == "100") { makeRunway(&tmpRunways, fields); - *logfile << "\t\t " << line << std::endl; + logfile << "\t\t " << line << std::endl; } else if (currentIcao != nullptr && fields[0] == "1300") { makeGate1300(&tmpGates, fields); - *logfile << "\t\t " << line << std::endl; + logfile << "\t\t " << line << std::endl; } } if (currentIcao != nullptr && !tmpRunways.empty() && !tmpGates.empty()) { - (*airports)[*currentIcao] = {tmpGates, tmpRunways}; + airports[*currentIcao] = {tmpGates, tmpRunways}; validCount += 1; - *logfile << "\t " << *currentIcao << " committed" << std::endl; + logfile << "\t " << *currentIcao << " committed" << std::endl; } - *logfile << " " << apCount << " airports found, of which " - << validCount << " are valid" << std::endl; + logfile << " " << apCount << " airports found, of which " + << validCount << " are valid" << std::endl; } void makeGate15(std::vector *gates, std::vector fields) diff --git a/utilities/include/util.hpp b/utilities/include/util.hpp index c7791ed..d6093db 100644 --- a/utilities/include/util.hpp +++ b/utilities/include/util.hpp @@ -105,18 +105,16 @@ namespace germanairlinesva_util nullptr, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { - std::stringstream debug_msg; - debug_msg << "CryptAcquireContext returned with error " << GetLastError(); - toLog(debug_msg.str()); + toLog("CryptAcquireContext returned with error " + + std::to_string(GetLastError())); CloseHandle(hFile); return 1; } if (!CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash)) { - std::stringstream debug_msg; - debug_msg << "CryptCreateHash returned with error " << GetLastError(); - toLog(debug_msg.str()); + toLog("CryptCreateHash returned with error " + + std::to_string(GetLastError())); CloseHandle(hFile); CryptReleaseContext(hProv, 0); @@ -129,9 +127,8 @@ namespace germanairlinesva_util } if (!CryptHashData(hHash, rgbFile, cbRead, 0)) { - std::stringstream debug_msg; - debug_msg << "CryptHashData returned with error " << GetLastError(); - toLog(debug_msg.str()); + toLog("CryptHashData returned with error " + + std::to_string(GetLastError())); CryptReleaseContext(hProv, 0); CryptDestroyHash(hHash); @@ -141,9 +138,7 @@ namespace germanairlinesva_util } if (!bResult) { - std::stringstream debug_msg; - debug_msg << "ReadFile returned with error " << GetLastError(); - toLog(debug_msg.str()); + toLog("ReadFile returned with error " + std::to_string(GetLastError())); CryptReleaseContext(hProv, 0); CryptDestroyHash(hHash); @@ -155,9 +150,8 @@ namespace germanairlinesva_util if (CryptGetHashParam(hHash, HP_HASHVAL, rgbHash, &cbHash, 0)) { to_hex((char *)rgbHash, lastHash); } else { - std::stringstream debug_msg; - debug_msg << "CryptGetHashParam returned with error " << GetLastError(); - toLog(debug_msg.str()); + toLog("CryptGetHashParam returned with error " + + std::to_string(GetLastError())); } CryptDestroyHash(hHash); diff --git a/websocket/include/websocket.h b/websocket/include/websocket.h index 124828f..a124b46 100644 --- a/websocket/include/websocket.h +++ b/websocket/include/websocket.h @@ -33,8 +33,8 @@ namespace germanairlinesva_websocket public: Websocket(std::string host, - std::string user, - std::function toLog); + std::string user, + std::function toLog); ~Websocket(); void onClientMessageCallback(const ix::WebSocketMessagePtr &msg); void sendData(data &d);