/* * 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* const* argv, FailureBehavior failure_behavior) { auto fail = [this, argv, failure_behavior] { if (failure_behavior == FailureBehavior::PrintUsage || failure_behavior == FailureBehavior::PrintUsageAndExit) print_usage(stderr, argv[0]); if (failure_behavior == FailureBehavior::Exit || failure_behavior == FailureBehavior::PrintUsageAndExit) exit(1); }; Vector