cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
default_main.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
20#pragma once
21
22#include <cstdlib>
23#include <exception>
24#include <iostream>
25
26#include <lyra/cli.hpp>
27
31
32namespace stat_bench {
33namespace impl {
34
42inline auto default_main(int argc, const char** argv) noexcept -> int {
43 try {
45 parser.parse_cli(argc, argv);
46 if (parser.config().show_help) {
47 std::cout << parser.cli()
48 << std::endl; // NOLINT(performance-avoid-endl)
49 return EXIT_SUCCESS;
50 }
52 runner.run();
53 return EXIT_SUCCESS;
54 } catch (const std::exception& e) {
55 std::cerr << "Error: " << e.what()
56 << std::endl; // NOLINT(performance-avoid-endl)
57 return EXIT_FAILURE;
58 }
59}
60
61} // namespace impl
62} // namespace stat_bench
63
67#define STAT_BENCH_IMPL_DEFAULT_MAIN \
68 auto main(int argc, const char** argv) -> int { \
69 return ::stat_bench::impl::default_main(argc, argv); \
70 }
Class to parse command line arguments.
auto config() -> const Config &
Get the configuration.
auto cli() -> lyra::cli &
Access to the command line interface definition.
void parse_cli(int argc, const char **argv)
Parse command line arguments.
Class of runners of benchmarks.
Definition runner.h:39
Definition of CommandLineParser class.
Definition of Runner class.
Namespace of internal implementation.
auto default_main(int argc, const char **argv) noexcept -> int
Default main function.
Namespace of classes to run benchmarks.
Namespace of stat_bench source codes.
Definition of Runner class.