parse command-line arguments.
More...
#include <vul_arg.h>
|
| | vul_arg (char const *option_string=nullptr, char const *helpstring=nullptr, T default_value=T()) |
| | Construct a vul_arg<T> with command-line switch and default value. More...
|
| |
| | vul_arg (vul_arg_info_list &l, char const *option_string=nullptr, char const *helpstring=nullptr, T default_value=T()) |
| | As above, but add the arg to the list l, on which parse() can be called later. More...
|
| |
| | vul_arg (char const *option_string, char const *helpstring, required_option_type) |
| | Dummy parameter to be passed during construction. It sets a flag as required. More...
|
| |
| | vul_arg (vul_arg_info_list &l, char const *option_string, char const *helpstring, required_option_type) |
| | As above, but add the arg to the list l, on which parse() can be called later. More...
|
| |
| T & | operator() () |
| | return the arg's current value, whether the default or the one from the command line. More...
|
| |
| T const & | operator() () const |
| |
| int | parse (char **argv) override |
| | returns number of args chomped, or -1 on failure. More...
|
| |
| std::ostream & | print_value (std::ostream &s) override |
| | print. More...
|
| |
| char const * | option () |
| |
| char const * | help () |
| |
| bool | set () const |
| | Returns true if arg was set on the command line. More...
|
| |
|
| T | value_ |
| |
| char const * | type_ |
| | Static text describing type of option (e.g. bool or double). More...
|
| |
template<class T>
class vul_arg< T >
parse command-line arguments.
Definition at line 29 of file vul_arg.h.
◆ vul_arg() [1/4]
template<class T>
| vul_arg< T >::vul_arg |
( |
char const * |
option_string = nullptr, |
|
|
char const * |
helpstring = nullptr, |
|
|
T |
default_value = T() |
|
) |
| |
|
inline |
Construct a vul_arg<T> with command-line switch and default value.
Command line switch option_string, and default value default_value. Add this argument to the global list of arguments that vul_arg_base::parse() uses when it eventually gets the command line.
If option_string is null, then the argument is assigned to the first plain word in the command line (warning: this causes problems for T=char *, but that just means that you have to have a help string if you want a default... good)
Definition at line 148 of file vul_arg.h.
◆ vul_arg() [2/4]
As above, but add the arg to the list l, on which parse() can be called later.
Definition at line 156 of file vul_arg.h.
◆ vul_arg() [3/4]
Dummy parameter to be passed during construction. It sets a flag as required.
Construct a vul_arg<T> that user must set in command line. Note that a default value does not make sense. Add this argument to the global list of arguments that vul_arg_base::parse() uses when it eventually gets the command line.
As in the previous constructors, if option_string is null, then the argument is assigned to the first plain word in the command line. However, this constructor adds a new option, allowing us to declare a non-null flag, which can appears anywhere, and that is REQUIRED.
Note that the parameters are not optional. This interface has been chosen to ensure backward compatibility. \seealso is_required
Definition at line 176 of file vul_arg.h.
◆ vul_arg() [4/4]
As above, but add the arg to the list l, on which parse() can be called later.
Definition at line 183 of file vul_arg.h.
◆ add_to_current()
◆ display_usage()
| void vul_arg_base::display_usage |
( |
char const * |
msg = nullptr | ) |
|
|
staticinherited |
◆ display_usage_and_exit()
| void vul_arg_base::display_usage_and_exit |
( |
char const * |
msg = nullptr | ) |
|
|
staticinherited |
◆ help()
| char const * vul_arg_base::help |
( |
| ) |
|
|
inherited |
◆ include_deprecated()
Add another vul_arg_info_list to the current one.
This allows for the inclusion of different sets of arguments into the main program, from different libraries.
Definition at line 84 of file vul_arg.cxx.
◆ operator()() [1/2]
return the arg's current value, whether the default or the one from the command line.
Definition at line 191 of file vul_arg.h.
◆ operator()() [2/2]
template<class T>
| T const& vul_arg< T >::operator() |
( |
| ) |
const |
|
inline |
◆ option()
| char const * vul_arg_base::option |
( |
| ) |
|
|
inherited |
◆ parse()
template<class T>
| int vul_arg< T >::parse |
( |
char ** |
argv | ) |
|
|
inlineoverridevirtual |
◆ parse_deprecated()
| void vul_arg_base::parse_deprecated |
( |
int & |
argc, |
|
|
char **& |
argv, |
|
|
bool |
warn_about_unrecognized_arguments = true |
|
) |
| |
|
staticinherited |
The main static method.
Definition at line 96 of file vul_arg.cxx.
◆ print_value()
template<class T>
| std::ostream& vul_arg< T >::print_value |
( |
std::ostream & |
s | ) |
|
|
inlineoverridevirtual |
◆ set()
| bool vul_arg_base::set |
( |
| ) |
const |
|
inherited |
Returns true if arg was set on the command line.
Definition at line 72 of file vul_arg.cxx.
◆ set_help_description()
| void vul_arg_base::set_help_description |
( |
char const * |
str | ) |
|
|
staticinherited |
◆ set_help_option()
| void vul_arg_base::set_help_option |
( |
char const * |
str | ) |
|
|
staticinherited |
◆ set_help_precis()
| void vul_arg_base::set_help_precis |
( |
char const * |
str | ) |
|
|
staticinherited |
◆ settype()
◆ help_
| std::string vul_arg_base::help_ |
|
protectedinherited |
Description of argument.
Definition at line 77 of file vul_arg.h.
◆ is_required
◆ option_
| std::string vul_arg_base::option_ |
|
protectedinherited |
Option flag including "-" or "--".
Definition at line 75 of file vul_arg.h.
◆ required_
| bool vul_arg_base::required_ |
|
protectedinherited |
if true, this flag must be set on command line.
Definition at line 73 of file vul_arg.h.
◆ set_
After parsing, true iff value was set on command line.
Definition at line 71 of file vul_arg.h.
◆ type_
| char const* vul_arg_base::type_ |
|
inherited |
Static text describing type of option (e.g. bool or double).
Definition at line 68 of file vul_arg.h.
◆ value_
The documentation for this class was generated from the following file: