mCRL2
Loading...
Searching...
No Matches
input_output_tool.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_UTILITIES_INPUT_OUTPUT_TOOL_H
13#define MCRL2_UTILITIES_INPUT_OUTPUT_TOOL_H
14
16
17namespace mcrl2
18{
19
20namespace utilities
21{
22
23namespace tools
24{
25
29{
30 protected:
32 std::string m_output_filename;
33
36 void check_positional_options(const command_line_parser& parser)
37 {
38 if (2 < parser.arguments.size())
39 {
40 parser.error("too many file arguments");
41 }
42 }
43
46 std::string synopsis() const
47 {
48 return "[OPTION]... [INFILE [OUTFILE]]\n";
49 }
50
53 void parse_options(const command_line_parser& parser)
54 {
56 if (1 < parser.arguments.size())
57 {
58 m_output_filename = parser.arguments[1];
59 }
60 }
61
63 std::string output_file_message() const
64 {
65 std::ostringstream out;
66 out << "Output written to " << ((m_output_filename.empty())? "standard output" : ("'" + m_output_filename + "'"));
67 return out.str();
68 }
69
71 std::string make_tool_description(const std::string& description) const
72 {
73 // return utilities::word_wrap_text(description + " If INFILE is not present, standard input is used. If OUTFILE is not present, standard output is used.");
74 return description + " If INFILE is not present, standard input is used. If OUTFILE is not present, standard output is used.";
75 }
76
77 public:
79 input_output_tool(const std::string& name,
80 const std::string& author,
81 const std::string& what_is,
82 const std::string& tool_description,
83 std::string known_issues = ""
84 )
85 : input_tool(name, author, what_is, tool_description, known_issues)
86 {
87 }
88
90 const std::string& output_filename() const
91 {
92 return m_output_filename;
93 }
94
96 std::string& output_filename()
97 {
98 return m_output_filename;
99 }
100};
101
102} // namespace tools
103
104} // namespace utilities
105
106} // namespace mcrl2
107
108#endif // MCRL2_UTILITIES_INPUT_OUTPUT_TOOL_H
Base class for tools that take a file as input, and write the results to a file.
std::string make_tool_description(const std::string &description) const
Adds a message about input and output files to the given description.
void check_positional_options(const command_line_parser &parser)
Checks if the number of positional options is OK.
std::string & output_filename()
Returns a reference to the output filename.
void parse_options(const command_line_parser &parser)
Parse non-standard options.
std::string m_output_filename
The output file name.
input_output_tool(const std::string &name, const std::string &author, const std::string &what_is, const std::string &tool_description, std::string known_issues="")
Constructor.
std::string synopsis() const
Returns the synopsis of the tool.
std::string output_file_message() const
Returns a message about the output filename.
const std::string & output_filename() const
Returns a const reference to the output filename.
Base class for tools that take a file as input.
Definition input_tool.h:28
void parse_options(const command_line_parser &parser) override
Parse non-standard options.
Definition input_tool.h:52
Base class for tools that take a file as input.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72