Skip to content

Commit

Permalink
bump cxxopts to v3 (major version upgrade) (#4541)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsnolde committed Feb 5, 2024
1 parent 82d8215 commit 5ce3aa7
Show file tree
Hide file tree
Showing 28 changed files with 45 additions and 38 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ CMakeLists.txt.user
/CMakeSettings.json
.idea
/.tidytmp
vcpkg*/

# documentation
site/
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CMakeLists.txt.user
/CMakeSettings.json
.idea
/.tidytmp
vcpkg*/

# python
.venv
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
* CHANGED: libvalhalla.pc generation to have finer controls; install third_party public headers; overhaul lots of CMake; remove conan support [#4516](https://github.com/valhalla/valhalla/pull/4516)
* CHANGED: refactored matrix code to include a base class for all matrix algorithms to prepare for second passes on matrix [#4535](https://github.com/valhalla/valhalla/pull/4535)
* ADDED: matrix second pass for connections not found in the first pass, analogous to /route [#4536](https://github.com/valhalla/valhalla/pull/4536)
* UPDATED: cxxopts to 3.1.1 [#4541](https://github.com/valhalla/valhalla/pull/4541)

## Release Date: 2023-05-11 Valhalla 3.4.0
* **Removed**
Expand Down
6 changes: 4 additions & 2 deletions src/argparse_utils.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <iostream>

#include <boost/property_tree/ptree.hpp>
#include <cxxopts.hpp>

Expand All @@ -21,7 +23,7 @@
* @param use_threads Whether this program multi-threads
*
* @returns true if the program should continue, false if we should EXIT_SUCCESS
* @throws cxxopts::OptionException Thrown if there's no valid configuration
* @throws cxxopts::exceptions::exception Thrown if there's no valid configuration
*/
bool parse_common_args(const std::string& program,
const cxxopts::Options& opts,
Expand All @@ -46,7 +48,7 @@ bool parse_common_args(const std::string& program,
filesystem::is_regular_file(result["config"].as<std::string>())) {
conf = valhalla::config(result["config"].as<std::string>());
} else {
throw cxxopts::OptionException("Configuration is required\n\n" + opts.help() + "\n\n");
throw cxxopts::exceptions::exception("Configuration is required\n\n" + opts.help() + "\n\n");
}

// configure logging
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_add_elevation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main(int argc, char** argv) {
std::cerr << "All tile files are invalid\n\n" << options.help() << "\n\n";
return EXIT_FAILURE;
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_add_landmarks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int main(int argc, char** argv) {
auto result = options.parse(argc, argv);
if (!parse_common_args(program, options, result, config, "mjolnir.logging", true))
return EXIT_SUCCESS;
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_add_predicted_traffic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ int main(int argc, char** argv) {
return false;
}
traffic_tile_dir = filesystem::path(result["traffic-tile-dir"].as<std::string>());
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_assign_speeds.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int main(int argc, char** argv) {
auto result = options.parse(argc, argv);
if (!parse_common_args(program, options, result, config, "mjolnir.logging", true))
return EXIT_SUCCESS;
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_benchmark_admins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ int main(int argc, char** argv) {
std::cout << "valhalla_benchmark_admins " << VALHALLA_VERSION << "\n";
return EXIT_SUCCESS;
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
4 changes: 2 additions & 2 deletions src/mjolnir/valhalla_build_admins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ int main(int argc, char** argv) {

// input files are positional
if (!result.count("input_files")) {
throw cxxopts::OptionException("Input file is required\n\n" + options.help());
throw cxxopts::exceptions::exception("Input file is required\n\n" + options.help());
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_build_connectivity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, char** argv) {
auto result = options.parse(argc, argv);
if (!parse_common_args(program, options, result, config, "mjolnir.logging"))
return EXIT_SUCCESS;
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
4 changes: 2 additions & 2 deletions src/mjolnir/valhalla_build_landmarks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ int main(int argc, char** argv) {

// input files are positional
if (!result.count("input_files")) {
throw cxxopts::OptionException("Input file is required\n\n" + options.help());
throw cxxopts::exceptions::exception("Input file is required\n\n" + options.help());
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_build_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ int main(int argc, char** argv) {
auto result = options.parse(argc, argv);
if (!parse_common_args(program, options, result, config, "mjolnir.logging", true))
return EXIT_SUCCESS;
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
10 changes: 5 additions & 5 deletions src/mjolnir/valhalla_build_tiles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,30 @@ int main(int argc, char** argv) {
start_stage = string_to_buildstage(result["start"].as<std::string>());
if (start_stage == BuildStage::kInvalid) {
list_stages();
throw cxxopts::OptionException("Invalid start stage, see above");
throw cxxopts::exceptions::exception("Invalid start stage, see above");
}
}
if (result.count("end")) {
end_stage = string_to_buildstage(result["end"].as<std::string>());
if (end_stage == BuildStage::kInvalid) {
list_stages();
throw cxxopts::OptionException("Invalid end stage, see above");
throw cxxopts::exceptions::exception("Invalid end stage, see above");
}
}
LOG_INFO("Start stage = " + to_string(start_stage) + " End stage = " + to_string(end_stage));

// Make sure start stage < end stage
if (static_cast<int>(start_stage) > static_cast<int>(end_stage)) {
list_stages();
throw cxxopts::OptionException(
throw cxxopts::exceptions::exception(
"Starting build stage is after ending build stage in pipeline, see above");
}

if (!result.count("input_files") && start_stage <= BuildStage::kParseNodes &&
end_stage >= BuildStage::kParseWays) {
throw cxxopts::OptionException("Input file is required\n\n" + options.help() + "\n\n");
throw cxxopts::exceptions::exception("Input file is required\n\n" + options.help() + "\n\n");
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_convert_transit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main(int argc, char** argv) {
onestoptests = valhalla::mjolnir::ParseTestFile(testfile);
std::sort(onestoptests.begin(), onestoptests.end());
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_ingest_transit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main(int argc, char** argv) {
auto result = options.parse(argc, argv);
if (!parse_common_args(program, options, result, config, "mjolnir.logging", true))
return EXIT_SUCCESS;
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
4 changes: 2 additions & 2 deletions src/mjolnir/valhalla_query_transit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ int main(int argc, char* argv[]) {
for (const auto& arg : std::vector<std::string>{"o_onestop_id", "o_lat", "o_lng"}) {
if (result.count(arg) == 0) {
const std::string msg = "The <" + arg + "> argument was not provided, but is mandatory\n\n";
throw cxxopts::OptionException(msg + options.help());
throw cxxopts::exceptions::exception(msg + options.help());
}
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_validate_transit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main(int argc, char** argv) {
auto result = options.parse(argc, argv);
if (!parse_common_args(program, options, result, config, "mjolnir.logging", true))
return EXIT_SUCCESS;
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/mjolnir/valhalla_ways_to_edges.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char** argv) {
if (!parse_common_args(program, options, result, config, "mjolnir.logging"))
return EXIT_SUCCESS;

} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/valhalla_benchmark_adjacency_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int main(int argc, char* argv[]) {
auto result = options.parse(argc, argv);
if (!parse_common_args(program, options, result, config, "mjolnir.logging"))
return EXIT_SUCCESS;
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
4 changes: 2 additions & 2 deletions src/valhalla_benchmark_loki.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS;

if (!result.count("input_files")) {
throw cxxopts::OptionException("Input file is required\n\n" + options.help());
throw cxxopts::exceptions::exception("Input file is required\n\n" + options.help());
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/valhalla_expand_bounding_box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(int argc, char** argv) {
std::cerr << options.help() << std::endl;
return EXIT_FAILURE;
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion src/valhalla_export_edges.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int main(int argc, char* argv[]) {
auto result = options.parse(argc, argv);
if (!parse_common_args(program, options, result, config, ""))
return EXIT_SUCCESS;
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
4 changes: 2 additions & 2 deletions src/valhalla_path_comparison.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ int main(int argc, char* argv[]) {
} else if (result.count("shape")) {
shape = result["shape"].as<std::string>();
} else {
throw cxxopts::OptionException(
throw cxxopts::exceptions::exception(
"The json parameter or shape parameter was not supplied but is required.\n\n" +
options.help());
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
5 changes: 3 additions & 2 deletions src/valhalla_run_isochrone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ int main(int argc, char* argv[]) {
return EXIT_SUCCESS;

if (!result.count("json")) {
throw cxxopts::OptionException("A JSON format request must be present.\n\n" + options.help());
throw cxxopts::exceptions::exception("A JSON format request must be present.\n\n" +
options.help());
}
json_str = result["json"].as<std::string>();

if (result.count("file")) {
filename = result["file"].as<std::string>();
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
5 changes: 3 additions & 2 deletions src/valhalla_run_matrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ int main(int argc, char* argv[]) {
return EXIT_SUCCESS;

if (!result.count("json")) {
throw cxxopts::OptionException("A JSON format request must be present.\n\n" + options.help());
throw cxxopts::exceptions::exception("A JSON format request must be present.\n\n" +
options.help());
}

json_str = result["json"].as<std::string>();
iterations = result["multi-run"].as<uint32_t>();
log_details = result["log-details"].as<bool>();
optimize = result["optimize"].as<bool>();
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down
4 changes: 2 additions & 2 deletions src/valhalla_run_route.cc
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ int main(int argc, char* argv[]) {
} else if (result.count("json")) {
json_str = result["json"].as<std::string>();
} else {
throw cxxopts::OptionException("Either json or json-file args must be set.");
throw cxxopts::exceptions::exception("Either json or json-file args must be set.");
}
} catch (cxxopts::OptionException& e) {
} catch (cxxopts::exceptions::exception& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
} catch (std::exception& e) {
Expand Down

0 comments on commit 5ce3aa7

Please sign in to comment.