mCRL2
Loading...
Searching...
No Matches
input_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_TOOL_H
13#define MCRL2_UTILITIES_INPUT_TOOL_H
14
16
17namespace mcrl2
18{
19
20namespace utilities
21{
22
23namespace tools
24{
25
27class input_tool: public tool
28{
29 protected:
31 std::string m_input_filename;
32
35 void check_positional_options(const command_line_parser& parser) override
36 {
37 if (1 < parser.arguments.size())
38 {
39 parser.error("too many file arguments");
40 }
41 }
42
45 std::string synopsis() const override
46 {
47 return "[OPTION]... [INFILE]\n";
48 }
49
52 void parse_options(const command_line_parser& parser) override
53 {
54 tool::parse_options(parser);
55 if (0 < parser.arguments.size())
56 {
57 m_input_filename = parser.arguments[0];
58 }
59 }
60
62 std::string input_file_message() const
63 {
64 std::ostringstream out;
65 out << "Input read from " << ((m_input_filename.empty())? "standard input" : ("'" + m_input_filename + "'"));
66 return out.str();
67 }
68
70 std::string make_tool_description(const std::string& description) const
71 {
72 // return utilities::word_wrap_text(description + " If INFILE is not present, standard input is used.");
73 return description + " If INFILE is not present, standard input is used.";
74 }
75
76 public:
78 input_tool(const std::string& name,
79 const std::string& author,
80 const std::string& what_is,
81 const std::string& tool_description,
82 std::string known_issues = ""
83 )
84 : tool(name, author, what_is, tool_description, known_issues)
85 {
86 }
87
89 const std::string& input_filename() const
90 {
91 return m_input_filename;
92 }
93
95 std::string& input_filename()
96 {
97 return m_input_filename;
98 }
99};
100
101} // namespace tools
102
103} // namespace utilities
104
105} // namespace mcrl2
106
107#endif // MCRL2_UTILITIES_INPUT_TOOL_H
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
const std::string & input_filename() const
Returns a const reference to the input filename.
Definition input_tool.h:89
std::string make_tool_description(const std::string &description) const
Adds a message about input files to the given description.
Definition input_tool.h:70
std::string m_input_filename
The input file name.
Definition input_tool.h:31
std::string input_file_message() const
Returns a message about the input filename.
Definition input_tool.h:62
input_tool(const std::string &name, const std::string &author, const std::string &what_is, const std::string &tool_description, std::string known_issues="")
Constructor.
Definition input_tool.h:78
void check_positional_options(const command_line_parser &parser) override
Checks if the number of positional options is OK.
Definition input_tool.h:35
std::string synopsis() const override
Returns the synopsis of the tool.
Definition input_tool.h:45
std::string & input_filename()
Returns a reference to the input filename.
Definition input_tool.h:95
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
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
add your file description here.