From 245a5f680393eaec263b629deea4b83033daa518 Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 10 Jun 2019 22:44:05 +0200 Subject: [PATCH] Adapt to changes in c++utilities --- angle.cpp | 9 ++++----- location.cpp | 15 +++++++-------- main.cpp | 11 +++++------ 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/angle.cpp b/angle.cpp index e003816..5e319b4 100644 --- a/angle.cpp +++ b/angle.cpp @@ -1,6 +1,6 @@ #include "./angle.h" -#include +#include #include #include @@ -13,8 +13,7 @@ #endif using namespace std; -using namespace ApplicationUtilities; -using namespace ConversionUtilities; +using namespace CppUtilities; Angle::Angle() : m_val(0) @@ -46,14 +45,14 @@ Angle::Angle(const string &value, AngularMeasure measure) if (mpos == string::npos) m_val += stringToNumber(value); else if (mpos >= (value.length() - 1)) - throw Failure("excepted minutes after ':' in " + value); + throw ParseError("excepted minutes after ':' in " + value); else { m_val += stringToNumber(value.substr(0, mpos)); spos = value.find(':', mpos + 1); if (spos == string::npos) m_val += stringToNumber(value.substr(mpos + 1)) / 60.0; else if (spos >= (value.length() - 1)) - throw Failure("excepted seconds after second ':'' in " + value); + throw ParseError("excepted seconds after second ':'' in " + value); else m_val += (stringToNumber(value.substr(mpos + 1, spos - mpos - 1)) / 60.0) + (stringToNumber(value.substr(spos + 1)) / 3600.0); diff --git a/location.cpp b/location.cpp index 85cc5d9..c4dbc7b 100644 --- a/location.cpp +++ b/location.cpp @@ -1,6 +1,6 @@ #include "./location.h" -#include +#include #include #include @@ -8,8 +8,7 @@ #include using namespace std; -using namespace ApplicationUtilities; -using namespace ConversionUtilities; +using namespace CppUtilities; // WGS84 Parameters #define WGS84_A 6378137.0 // major axis @@ -54,11 +53,11 @@ Location::Location(const string &latitudeAndLongitude, Angle::AngularMeasure mea { string::size_type dpos = latitudeAndLongitude.find(','); if (dpos == string::npos) - throw Failure("Pair of coordinates (latitude and longitude) required."); + throw ParseError("Pair of coordinates (latitude and longitude) required."); else if (dpos >= (latitudeAndLongitude.length() - 1)) - throw Failure("No second longitude following after comma."); + throw ParseError("No second longitude following after comma."); else if (latitudeAndLongitude.find(',', dpos + 1) != string::npos) - throw Failure("More then 2 coordinates given."); + throw ParseError("More then 2 coordinates given."); m_lat = Angle(latitudeAndLongitude.substr(0, dpos), measure); m_lon = Angle(latitudeAndLongitude.substr(dpos + 1), measure); } @@ -199,7 +198,7 @@ Location Location::midpoint(const Location &location1, const Location &location2 double Location::trackLength(const std::vector &track, bool circle) { if (track.size() < 2) - throw Failure("At least two locations are required to calculate a distance."); + throw ParseError("At least two locations are required to calculate a distance."); const Location *location1 = &track.at(0); const Location *location2 = &track.at(1); @@ -288,7 +287,7 @@ void Location::setValueByProvidedUtmWgs4Coordinates(const string &utmWgs4Coordin return; } } - throw Failure("UTM coordinates incomplete."); + throw ParseError("UTM coordinates incomplete."); } void Location::setValueByProvidedUtmWgs4Coordinates(int zone, char zoneDesignator, double easting, double northing) diff --git a/main.cpp b/main.cpp index 5290001..d6cf8a7 100644 --- a/main.cpp +++ b/main.cpp @@ -4,7 +4,7 @@ #include "resources/config.h" #include -#include +#include #include #include @@ -13,8 +13,7 @@ #include using namespace std; -using namespace ConversionUtilities; -using namespace ApplicationUtilities; +using namespace CppUtilities; Angle::AngularMeasure inputAngularMeasure = Angle::AngularMeasure::Degree; Angle::OutputForm outputFormForAngles = Angle::OutputForm::Degrees; @@ -103,7 +102,7 @@ int main(int argc, char *argv[]) Argument version("version", 'v', "Shows the version of this application."); argparser.setMainArguments({ &help, &convert, &distance, &trackLength, &bearing, &fbearing, &midpoint, &destination, &gmapsLink, &inputAngularMeasureArg, &outputFormForAnglesArg, &inputSystemForLocationsArg, &outputSystemForLocationsArg, &version }); - argparser.parseArgsOrExit(argc, argv); + argparser.parseArgs(argc, argv); if (inputAngularMeasureArg.isPresent()) { const char *inputFormat = inputAngularMeasureArg.values().front(); @@ -186,7 +185,7 @@ int main(int argc, char *argv[]) cerr << "The provided numbers couldn't be parsed correctly." << endl; cerr << endl; printAngleFormatInfo(cerr); - } catch (const Failure &ex) { + } catch (const ParseError &ex) { cerr << "The provided locations/coordinates couldn't be parsed correctly: " << ex.what() << endl; cerr << endl; printAngleFormatInfo(cerr); @@ -331,7 +330,7 @@ void printMapsLink(const string &filePath) } cout << "&mra=mi&mrsp=2&sz=16&z=16"; } else { - throw Failure("At least one location is required to generate a link."); + throw ParseError("At least one location is required to generate a link."); } } catch (const std::ios_base::failure &failure) { cout << "An IO failure occured when reading file from provided path: " << failure.what() << endl;