mCRL2
Loading...
Searching...
No Matches
input_output_output_tool.h
Go to the documentation of this file.
1// Author(s): Maurice Laveaux
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//
9
10#ifndef MCRL2_UTILITIES_INPUT_INPUT_OUTPUT_TOOL_H
11#define MCRL2_UTILITIES_INPUT_INPUT_OUTPUT_TOOL_H
12
14
15namespace mcrl2
16{
17
18namespace utilities
19{
20
21namespace tools
22{
23
27{
28protected:
30 std::string m_input_filename;
31
33 std::string m_output_filename1;
34 std::string m_output_filename2;
35
38 void check_positional_options(const command_line_parser& parser)
39 {
40 if (3 < parser.arguments.size())
41 {
42 parser.error("too many file arguments");
43 }
44 }
45
47 std::string synopsis() const
48 {
49 return "[OPTION]... [INFILE] OUTFILE1 OUTFILE2\n";
50 }
51
54 void parse_options(const command_line_parser& parser)
55 {
56 tool::parse_options(parser);
57
58 if (parser.arguments.size() < 2)
59 {
60 parser.error("This tool requires at least two output filenames.");
61 }
62
63 // Take the input filename if there are at least three file arguments.
64 std::size_t index = 0;
65 if (parser.arguments.size() >= 3)
66 {
67 m_input_filename = parser.arguments[index];
68 ++index;
69 }
70
71 m_output_filename1 = parser.arguments[index];
72 ++index;
73 m_output_filename2 = parser.arguments[index];
74 }
75
77 std::string output_file_message() const
78 {
79 std::ostringstream out;
80 out << "Output written to " << m_output_filename1 << " and " << m_output_filename2;
81 return out.str();
82 }
83
85 std::string make_tool_description(const std::string& description) const
86 {
87 return description + " If INFILE is not present, standard input is used.";
88 }
89
90public:
92 input_output_output_tool(const std::string& name,
93 const std::string& author,
94 const std::string& what_is,
95 const std::string& tool_description,
96 std::string known_issues = ""
97 )
98 : tool(name, author, what_is, tool_description, known_issues)
99 {}
100
102 const std::string& input_filename() const { return m_input_filename; }
103 std::string& input_filename() { return m_input_filename; }
104
106 const std::string& output_filename1() const { return m_output_filename1; }
107 std::string& output_filename1() { return m_output_filename1; }
108
110 const std::string& output_filename2() const { return m_output_filename2; }
111 std::string& output_filename2() { return m_output_filename2; }
112};
113
114} // namespace tools
115
116} // namespace utilities
117
118} // namespace mcrl2
119
120#endif // MCRL2_UTILITIES_INPUT_INPUT_OUTPUT_TOOL_H
Base class for tools that optionally takes one file as input, and writes the results to two output fi...
input_output_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.
const std::string & output_filename2() const
Returns a const reference to the second output filename.
std::string output_file_message() const
Returns a message about the output filename.
std::string make_tool_description(const std::string &description) const
Adds a message about input and output files to the given description.
const std::string & input_filename() const
Returns a const reference to the input filename.
std::string synopsis() const
Returns the synopsis of the tool.
const std::string & output_filename1() const
Returns a const reference to the first output filename.
void parse_options(const command_line_parser &parser)
Parse non-standard options.
void check_positional_options(const command_line_parser &parser)
Checks if the number of positional options is OK.
Base class for command line tools. as result.
Definition tool.h:39
virtual void parse_options(const command_line_parser &parser)
Parse non-standard options.
Definition tool.h:76
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