Adapt to c++utilities v5
This commit is contained in:
parent
aeb097a549
commit
533ecbef96
|
@ -29,7 +29,8 @@ set(META_VERSION_PATCH 3)
|
||||||
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
|
||||||
|
|
||||||
# find c++utilities
|
# 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()
|
use_cpp_utilities()
|
||||||
|
|
||||||
# include modules to apply configuration
|
# include modules to apply configuration
|
||||||
|
|
17
main.cpp
17
main.cpp
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
#include <c++utilities/application/argumentparser.h>
|
#include <c++utilities/application/argumentparser.h>
|
||||||
#include <c++utilities/application/failure.h>
|
#include <c++utilities/application/failure.h>
|
||||||
|
#include <c++utilities/conversion/stringbuilder.h>
|
||||||
#include <c++utilities/conversion/stringconversion.h>
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
#include <c++utilities/io/catchiofailure.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -214,8 +214,9 @@ vector<Location> locationsFromFile(const string &path)
|
||||||
// prepare reading
|
// prepare reading
|
||||||
fstream file;
|
fstream file;
|
||||||
file.open(path, ios_base::in);
|
file.open(path, ios_base::in);
|
||||||
if (!file)
|
if (!file) {
|
||||||
IoUtilities::throwIoFailure(("Unable to open the file \"" + path + "\".").data());
|
throw std::ios_base::failure("Unable to open the file \"" % path + "\".");
|
||||||
|
}
|
||||||
file.exceptions(ios_base::badbit);
|
file.exceptions(ios_base::badbit);
|
||||||
string line;
|
string line;
|
||||||
vector<Location> locations;
|
vector<Location> locations;
|
||||||
|
@ -270,9 +271,8 @@ void printTrackLength(const string &filePath, bool circle)
|
||||||
vector<Location> locations(locationsFromFile(filePath));
|
vector<Location> locations(locationsFromFile(filePath));
|
||||||
printDistance(Location::trackLength(locations, circle));
|
printDistance(Location::trackLength(locations, circle));
|
||||||
cout << " (" << locations.size() << " trackpoints)";
|
cout << " (" << locations.size() << " trackpoints)";
|
||||||
} catch (...) {
|
} catch (const std::ios_base::failure &failure) {
|
||||||
const char *what = ::IoUtilities::catchIoFailure();
|
cout << "An IO failure occured when reading file from provided path: " << failure.what() << endl;
|
||||||
cout << "An IO failure occured when reading file from provided path: " << what << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,8 +333,7 @@ void printMapsLink(const string &filePath)
|
||||||
} else {
|
} else {
|
||||||
throw Failure("At least one location is required to generate a link.");
|
throw Failure("At least one location is required to generate a link.");
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (const std::ios_base::failure &failure) {
|
||||||
const char *what = ::IoUtilities::catchIoFailure();
|
cout << "An IO failure occured when reading file from provided path: " << failure.what() << endl;
|
||||||
cout << "An IO failure occured when reading file from provided path: " << what << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue