Adapt to c++utilities v5

This commit is contained in:
Martchus 2019-03-14 17:59:30 +01:00
parent aeb097a549
commit 533ecbef96
2 changed files with 10 additions and 10 deletions

View File

@ -29,7 +29,8 @@ set(META_VERSION_PATCH 3)
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
# find c++utilities
find_package(c++utilities 4.10.0 REQUIRED)
set(CONFIGURATION_PACKAGE_SUFFIX "" CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities")
find_package(c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.0.0 REQUIRED)
use_cpp_utilities()
# include modules to apply configuration

View File

@ -5,8 +5,8 @@
#include <c++utilities/application/argumentparser.h>
#include <c++utilities/application/failure.h>
#include <c++utilities/conversion/stringbuilder.h>
#include <c++utilities/conversion/stringconversion.h>
#include <c++utilities/io/catchiofailure.h>
#include <cstring>
#include <fstream>
@ -214,8 +214,9 @@ vector<Location> locationsFromFile(const string &path)
// prepare reading
fstream file;
file.open(path, ios_base::in);
if (!file)
IoUtilities::throwIoFailure(("Unable to open the file \"" + path + "\".").data());
if (!file) {
throw std::ios_base::failure("Unable to open the file \"" % path + "\".");
}
file.exceptions(ios_base::badbit);
string line;
vector<Location> locations;
@ -270,9 +271,8 @@ void printTrackLength(const string &filePath, bool circle)
vector<Location> locations(locationsFromFile(filePath));
printDistance(Location::trackLength(locations, circle));
cout << " (" << locations.size() << " trackpoints)";
} catch (...) {
const char *what = ::IoUtilities::catchIoFailure();
cout << "An IO failure occured when reading file from provided path: " << what << endl;
} catch (const std::ios_base::failure &failure) {
cout << "An IO failure occured when reading file from provided path: " << failure.what() << endl;
}
}
@ -333,8 +333,7 @@ void printMapsLink(const string &filePath)
} else {
throw Failure("At least one location is required to generate a link.");
}
} catch (...) {
const char *what = ::IoUtilities::catchIoFailure();
cout << "An IO failure occured when reading file from provided path: " << what << endl;
} catch (const std::ios_base::failure &failure) {
cout << "An IO failure occured when reading file from provided path: " << failure.what() << endl;
}
}