12#ifndef MCRL2_UTILITIES_TOOL_H
13#define MCRL2_UTILITIES_TOOL_H
15#include "mcrl2/utilities/logger.h"
17#include "mcrl2/utilities/command_line_interface.h"
18#include "mcrl2/utilities/execution_timer.h"
19#include "mcrl2/utilities/platform.h"
21#ifdef MCRL2_PLATFORM_WINDOWS
63 desc.add_option(
"timings", make_optional_argument<std::string>(
"FILE",
""),
64 "append timing measurements to FILE. Measurements are written to "
65 "standard error if no FILE is provided");
72 if (parser.options.count(
"timings") > 0)
75 log::logger::set_report_time_info();
76 m_timing_filename = parser.option_argument(
"timings");
91 if (parser.options.count(
"quiet"))
93 if (parser.options.count(
"debug"))
95 parser.error(
"options -q/--quiet and -d/--debug cannot be used together\n");
97 if (parser.options.count(
"verbose"))
99 parser.error(
"options -q/--quiet and -v/--verbose cannot be used together\n");
102#ifndef MCRL2_TOOL_CLASSES_NO_CORE
103 if (parser.options.count(
"quiet"))
105 log::logger::set_reporting_level(log::log_level_t::quiet);
107 if (parser.options.count(
"verbose"))
109 log::logger::set_reporting_level(log::log_level_t::verbose);
111 if (parser.options.count(
"debug"))
113 log::logger::set_reporting_level(log::log_level_t::debug);
115 if (parser.options.count(
"log-level"))
117 log::logger::set_reporting_level(log::log_level_from_string(parser.option_argument(
"log-level")));
135 return "[OPTION]...\n";
141 const std::string& author,
142 const std::string& what_is,
143 const std::string& tool_description,
144 std::string known_issues =
""
165 return m_timing_filename;
181#ifdef MCRL2_PLATFORM_WINDOWS
186 if (_fileno(stdin) >= 0 && _setmode(_fileno(stdin), _O_BINARY) == -1)
188 throw std::runtime_error(
"Cannot set stdin to binary mode");
193 interface_description clinterface(argv[0], m_name, m_author, m_what_is, synopsis(), m_tool_description, m_known_issues);
209 m_timer = execution_timer(m_name, timing_filename());
230 catch (mcrl2::runtime_error& e)
232 mCRL2log(mcrl2::log::log_level_t::error) << e.what() << std::endl;
234 catch (std::exception& e)
236 mCRL2log(mcrl2::log::log_level_t::error) << e.what() << std::endl;
Main parsing component for command line strings as well as interface to the results of parsing....
bool continue_execution() const
Whether main program execution should continue.
void check_no_duplicate_arguments() const
Checks that all arguments are passed at most once.
Simple timer to time the CPU time used by a piece of code.
void report()
Write all timing information that has been recorded.
Command line interface description component.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.