Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
testcomponents/CommandLineOptions.hxx
Go to the documentation of this file.
1// This code was generated by CLI, a command line interface
2// compiler for C++.
3//
4
5#ifndef COMMAND_LINE_OPTIONS_HXX
6#define COMMAND_LINE_OPTIONS_HXX
7
8#include <iosfwd>
9#include <string>
10#include <exception>
11
12namespace cli
13{
14 class unknown_mode
15 {
16 public:
17 enum value
18 {
19 skip,
20 stop,
21 fail
22 };
23
25
26 operator value () const
27 {
28 return v_;
29 }
30
31 private:
32 value v_;
33 };
34
35 // Exceptions.
36 //
37
38 class exception: public std::exception
39 {
40 public:
41 virtual void
42 print (std::ostream&) const = 0;
43 };
44
45 std::ostream&
46 operator<< (std::ostream&, const exception&);
47
48 class unknown_option: public exception
49 {
50 public:
51
52 ~unknown_option () throw () override;
53
55
56 const std::string&
57 option () const;
58
59 void
60 print (std::ostream&) const override;
61
62 const char*
63 what () const throw () override;
64
65 private:
66 std::string option_;
67 };
68
69 class unknown_argument: public exception
70 {
71 public:
72
73 ~unknown_argument () throw () override;
74
75 unknown_argument (std::string argument);
76
77 const std::string&
78 argument () const;
79
80 void
81 print (std::ostream&) const override;
82
83 const char*
84 what () const throw () override;
85
86 private:
87 std::string argument_;
88 };
89
90 class missing_value: public exception
91 {
92 public:
93
94 ~missing_value () throw () override;
95
97
98 const std::string&
99 option () const;
100
101 void
102 print (std::ostream&) const override;
103
104 const char*
105 what () const throw () override;
106
107 private:
108 std::string option_;
109 };
110
111 class invalid_value: public exception
112 {
113 public:
114
115 ~invalid_value () throw () override;
116
118 std::string value);
119
120 const std::string&
121 option () const;
122
123 const std::string&
124 value () const;
125
126 void
127 print (std::ostream&) const override;
128
129 const char*
130 what () const throw () override;
131
132 private:
133 std::string option_;
134 std::string value_;
135 };
136
137 class eos_reached: public exception
138 {
139 public:
140 void
141 print (std::ostream&) const override;
142
143 const char*
144 what () const throw () override;
145 };
146
147 class scanner
148 {
149 public:
150 virtual
152
153 virtual bool
154 more () = 0;
155
156 virtual const char*
157 peek () = 0;
158
159 virtual const char*
160 next () = 0;
161
162 virtual void
163 skip () = 0;
164 };
165
166 class argv_scanner: public scanner
167 {
168 public:
169 argv_scanner (int& argc, char** argv, bool erase = false);
170 argv_scanner (int start, int& argc, char** argv, bool erase = false);
171
172 int
173 end () const;
174
175 bool
176 more () override;
177
178 const char*
179 peek () override;
180
181 const char*
182 next () override;
183
184 void
185 skip () override;
186
187 private:
188 int i_;
189 int& argc_;
190 char** argv_;
191 bool erase_;
192 };
193}
194
195#include <string>
196
197class options
198{
199 public:
200
201 options (int& argc,
202 char** argv,
203 bool erase = false,
206
207 options (int start,
208 int& argc,
209 char** argv,
210 bool erase = false,
213
214 options (int& argc,
215 char** argv,
216 int& end,
217 bool erase = false,
220
221 options (int start,
222 int& argc,
223 char** argv,
224 int& end,
225 bool erase = false,
228
232
233 // Option accessors.
234 //
235
236 const bool&
237 help () const;
238
239 const std::string&
240 component () const;
241
242 const std::string&
243 input () const;
244
245 const std::string&
246 level () const;
247
248 const std::string&
249 output_dir () const;
250
251 // Print usage information.
252 //
253 static void
254 print_usage (::std::ostream&);
255
256 private:
257 void
258 _parse (::cli::scanner&,
259 ::cli::unknown_mode option,
260 ::cli::unknown_mode argument);
261
262 public:
263 bool help_;
264 std::string component_;
265 std::string input_;
266 std::string level_;
267 std::string output_dir_;
268};
269
270#include "CommandLineOptions.ixx"
271
272#endif // COMMAND_LINE_OPTIONS_HXX
Definition actionstatemachine/CommandLineOptions.hxx:167
const char * next() override
argv_scanner(int start, int &argc, char **argv, bool erase=false)
void skip() override
int end() const
argv_scanner(int &argc, char **argv, bool erase=false)
const char * peek() override
bool more() override
Definition actionstatemachine/CommandLineOptions.hxx:138
void print(std::ostream &) const override
const char * what() const override
Definition actionstatemachine/CommandLineOptions.hxx:39
virtual void print(std::ostream &) const =0
Definition actionstatemachine/CommandLineOptions.hxx:112
~invalid_value() override
Definition actionstatemachine/CommandLineOptions.hxx:91
~missing_value() override
Definition actionstatemachine/CommandLineOptions.hxx:148
virtual bool more()=0
virtual const char * peek()=0
virtual void skip()=0
virtual const char * next()=0
virtual ~scanner()
Definition actionstatemachine/CommandLineOptions.hxx:70
~unknown_argument() override
Definition actionstatemachine/CommandLineOptions.hxx:15
value
Definition actionstatemachine/CommandLineOptions.hxx:18
@ stop
Definition actionstatemachine/CommandLineOptions.hxx:20
@ fail
Definition actionstatemachine/CommandLineOptions.hxx:21
@ skip
Definition actionstatemachine/CommandLineOptions.hxx:19
unknown_mode(value v)
Definition actionstatemachine/CommandLineOptions.hxx:49
~unknown_option() override
const std::string & option() const
Definition actionstatemachine/CommandLineOptions.ixx:37
const char * what() const override
Definition actionstatemachine/CommandLineOptions.cxx:29
void print(std::ostream &) const override
Definition actionstatemachine/CommandLineOptions.cxx:23
Definition actionstatemachine/CommandLineOptions.hxx:198
std::string level_
Definition testcomponents/CommandLineOptions.hxx:266
options(int start, int &argc, char **argv, int &end, bool erase=false, ::cli::unknown_mode option=::cli::unknown_mode::fail, ::cli::unknown_mode argument=::cli::unknown_mode::stop)
const bool & help() const
static void print_usage(::std::ostream &)
options(int &argc, char **argv, bool erase=false, ::cli::unknown_mode option=::cli::unknown_mode::fail, ::cli::unknown_mode argument=::cli::unknown_mode::stop)
const std::string & output_dir() const
options(int &argc, char **argv, int &end, bool erase=false, ::cli::unknown_mode option=::cli::unknown_mode::fail, ::cli::unknown_mode argument=::cli::unknown_mode::stop)
const std::string & component() const
options(int start, int &argc, char **argv, bool erase=false, ::cli::unknown_mode option=::cli::unknown_mode::fail, ::cli::unknown_mode argument=::cli::unknown_mode::stop)
options(::cli::scanner &, ::cli::unknown_mode option=::cli::unknown_mode::fail, ::cli::unknown_mode argument=::cli::unknown_mode::stop)
const std::string & input() const
Definition actionstatemachine/CommandLineOptions.cxx:15
std::ostream & operator<<(std::ostream &, const exception &)
Definition actionstatemachine/CommandLineOptions.ixx:22
STL namespace.