/* * Copyright (c) 2020, Sergey Bugaev * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include static constexpr bool isnan(double __x) { return __builtin_isnan(__x); } static Optional convert_to_double(const char* s) { char* p; double v = strtod(s, &p); if (isnan(v) || p == s) return {}; return v; } namespace Core { ArgsParser::ArgsParser() { add_option(m_show_help, "Display this message", "help", 0); } bool ArgsParser::parse(int argc, char** argv, bool exit_on_failure) { auto print_usage_and_exit = [this, argv, exit_on_failure] { print_usage(stderr, argv[0]); if (exit_on_failure) exit(1); }; Vector