A class to specify a command-line argument. More...
#include "cmdline_option.h"
Public Member Functions | |
Argument (const char *name=nullptr, std::string description=std::string()) | |
constructor More... | |
operator bool () const | |
Argument & | optional () |
specifies that the argument is optional More... | |
Argument & | allow_multiple () |
specifies that multiple such arguments can be specified More... | |
Argument & | type_text () |
specifies that the argument should be a text string More... | |
Argument & | type_image_in () |
specifies that the argument should be an input image More... | |
Argument & | type_image_out () |
specifies that the argument should be an output image More... | |
Argument & | type_integer (const int64_t min=std::numeric_limits< int64_t >::min(), const int64_t max=std::numeric_limits< int64_t >::max()) |
specifies that the argument should be an integer More... | |
Argument & | type_bool () |
specifies that the argument should be a boolean More... | |
Argument & | type_float (const default_type min=-std::numeric_limits< default_type >::infinity(), const default_type max=std::numeric_limits< default_type >::infinity()) |
specifies that the argument should be a floating-point value More... | |
Argument & | type_choice (const char *const *choices) |
specifies that the argument should be selected from a predefined list More... | |
Argument & | type_file_in () |
specifies that the argument should be an input file More... | |
Argument & | type_file_out () |
specifies that the argument should be an output file More... | |
Argument & | type_directory_in () |
specifies that the argument should be an input directory More... | |
Argument & | type_directory_out () |
specifies that the argument should be an output directory More... | |
Argument & | type_sequence_int () |
specifies that the argument should be a sequence of comma-separated integer values More... | |
Argument & | type_sequence_float () |
specifies that the argument should be a sequence of comma-separated floating-point values. More... | |
Argument & | type_tracks_in () |
specifies that the argument should be an input tracks file More... | |
Argument & | type_tracks_out () |
specifies that the argument should be an output tracks file More... | |
Argument & | type_various () |
specifies that the argument could be one of various types More... | |
std::string | syntax (int format) const |
std::string | usage () const |
Public Attributes | |
const char * | id |
the argument name More... | |
std::string | desc |
the argument description More... | |
ArgType | type |
the argument type More... | |
ArgFlags | flags |
the argument flags (AllowMultiple & Optional) More... | |
union { | |
const char *const * choices | |
struct { | |
int64_t min | |
int64_t max | |
} i | |
struct { | |
default_type min | |
default_type max | |
} f | |
} | limits |
a structure to store the various parameters of the Argument More... | |
A class to specify a command-line argument.
Command-line arguments that are accepted by a particular command are specified as a vector of Arguments objects. Please refer to Command-line parsing for more information.
The list of arguments is provided by adding to the ARGUMENTS vector, like this:
The example above specifies that the application expects exactly 3 arguments, with the first one being an existing image to be used as input, the second one being a floating-point value, and the last one being an image to be created and used as output.
There are a number of types that the argument can be specified as. The argument can also be specified as optional (see optional() function), or as multiple (see allow_multiple() function). Note that in this case only one such argument can be optional and/or multiple, since more than one such argument would lead to ambiguities when parsing the command-line.
Definition at line 105 of file cmdline_option.h.
|
inline |
constructor
this is used to construct a command-line argument object, with a name and description. If default arguments are used, the object corresponds to the end-of-list specifier, as detailed in Command-line parsing.
Definition at line 111 of file cmdline_option.h.
|
inline |
specifies that multiple such arguments can be specified
See optional() for details.
Definition at line 160 of file cmdline_option.h.
|
inline |
Definition at line 138 of file cmdline_option.h.
|
inline |
specifies that the argument is optional
For example:
Definition at line 153 of file cmdline_option.h.
std::string MR::App::Argument::syntax | ( | int | format | ) | const |
|
inline |
specifies that the argument should be a boolean
Valid responses are 0,no,false or any non-zero integer, yes, true.
Definition at line 198 of file cmdline_option.h.
|
inline |
specifies that the argument should be selected from a predefined list
The list of allowed values must be specified as a nullptr-terminated list of C strings. Here is an example usage:
Definition at line 226 of file cmdline_option.h.
|
inline |
specifies that the argument should be an input directory
Definition at line 248 of file cmdline_option.h.
|
inline |
specifies that the argument should be an output directory
Definition at line 255 of file cmdline_option.h.
|
inline |
specifies that the argument should be an input file
Definition at line 234 of file cmdline_option.h.
|
inline |
specifies that the argument should be an output file
Definition at line 241 of file cmdline_option.h.
|
inline |
specifies that the argument should be a floating-point value
if desired, a range of allowed values can be specified.
Definition at line 206 of file cmdline_option.h.
|
inline |
specifies that the argument should be an input image
Definition at line 173 of file cmdline_option.h.
|
inline |
specifies that the argument should be an output image
Definition at line 180 of file cmdline_option.h.
|
inline |
specifies that the argument should be an integer
if desired, a range of allowed values can be specified.
Definition at line 188 of file cmdline_option.h.
|
inline |
specifies that the argument should be a sequence of comma-separated floating-point values.
Definition at line 269 of file cmdline_option.h.
|
inline |
specifies that the argument should be a sequence of comma-separated integer values
Definition at line 262 of file cmdline_option.h.
|
inline |
specifies that the argument should be a text string
Definition at line 166 of file cmdline_option.h.
|
inline |
specifies that the argument should be an input tracks file
Definition at line 276 of file cmdline_option.h.
|
inline |
specifies that the argument should be an output tracks file
Definition at line 283 of file cmdline_option.h.
|
inline |
specifies that the argument could be one of various types
Definition at line 290 of file cmdline_option.h.
std::string MR::App::Argument::usage | ( | ) | const |
const char* const* MR::App::Argument::choices |
Definition at line 128 of file cmdline_option.h.
std::string MR::App::Argument::desc |
the argument description
Definition at line 120 of file cmdline_option.h.
struct { ... } MR::App::Argument::f |
ArgFlags MR::App::Argument::flags |
the argument flags (AllowMultiple & Optional)
Definition at line 124 of file cmdline_option.h.
struct { ... } MR::App::Argument::i |
const char* MR::App::Argument::id |
the argument name
Definition at line 118 of file cmdline_option.h.
union { ... } MR::App::Argument::limits |
a structure to store the various parameters of the Argument
int64_t MR::App::Argument::max |
Definition at line 130 of file cmdline_option.h.
default_type MR::App::Argument::max |
Definition at line 133 of file cmdline_option.h.
int64_t MR::App::Argument::min |
Definition at line 130 of file cmdline_option.h.
default_type MR::App::Argument::min |
Definition at line 133 of file cmdline_option.h.
ArgType MR::App::Argument::type |
the argument type
Definition at line 122 of file cmdline_option.h.