mCRL2
Loading...
Searching...
No Matches
xinput_tool.h
Go to the documentation of this file.
1// Author(s): Willem Rietdijk
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_XINPUT_TOOL_H
13#define MCRL2_UTILITIES_XINPUT_TOOL_H
14
16
17namespace mcrl2
18{
19
20namespace utilities
21{
22
23namespace tools
24{
25
27class xinput_tool: public tool
28{
29 protected:
31 std::vector<std::string> m_input_filenames;
32
33 // The minimum and maximum number of files
34 std::size_t min_input_files;
35 std::size_t max_input_files;
36
39 void check_positional_options(const command_line_parser& parser) override
40 {
41 if (max_input_files > 0 && max_input_files < parser.arguments.size())
42 {
43 parser.error("too many file arguments");
44 }
45 else if (min_input_files > parser.arguments.size())
46 {
47 parser.error("too few file arguments");
48 }
49 }
50
53 std::string synopsis() const override
54 {
55 return "[OPTION]... [INFILES]\n";
56 }
57
60 void parse_options(const command_line_parser& parser) override
61 {
62 tool::parse_options(parser);
63
64 // Read input filenames from the given arguments
65 for (auto& input : parser.arguments)
66 {
67 m_input_filenames.push_back(input);
68 }
69 }
70
72 std::string input_file_message() const
73 {
74 std::ostringstream out;
75 out << "Input read from ";
76 for (auto& filename : m_input_filenames)
77 {
78 out << "'" + filename + "', ";
79 }
80 return out.str();
81 }
82
84 std::string make_tool_description(const std::string& description) const
85 {
86 // return utilities::word_wrap_text(description + " If INFILE is not present, standard input is used.");
87 return description;
88 }
89
90 public:
92 xinput_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 uint16_t min = 0,
98 uint16_t max = 0
99 )
100 : tool(name, author, what_is, tool_description, known_issues)
101 {
102 min_input_files = min;
103 max_input_files = max;
104 }
105
107 const std::vector<std::string>& input_filenames() const
108 {
109 return m_input_filenames;
110 }
111
113 std::vector<std::string>& input_filenames()
114 {
115 return m_input_filenames;
116 }
117};
118
119} // namespace tools
120
121} // namespace utilities
122
123} // namespace mcrl2
124
125#endif // MCRL2_UTILITIES_XINPUT_TOOL_H
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 an x number of files as input.
Definition xinput_tool.h:28
std::vector< std::string > m_input_filenames
The input file names.
Definition xinput_tool.h:31
void check_positional_options(const command_line_parser &parser) override
Checks if the number of positional options is OK.
Definition xinput_tool.h:39
std::string make_tool_description(const std::string &description) const
Adds a message about input files to the given description.
Definition xinput_tool.h:84
const std::vector< std::string > & input_filenames() const
Returns a const reference to the input filenames.
std::string synopsis() const override
Returns the synopsis of the tool.
Definition xinput_tool.h:53
xinput_tool(const std::string &name, const std::string &author, const std::string &what_is, const std::string &tool_description, std::string known_issues="", uint16_t min=0, uint16_t max=0)
Constructor.
Definition xinput_tool.h:92
std::string input_file_message() const
Returns a message about the input filename.
Definition xinput_tool.h:72
void parse_options(const command_line_parser &parser) override
Parse non-standard options.
Definition xinput_tool.h:60
std::vector< std::string > & input_filenames()
Returns a reference to the input filenames.
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.