Developer documentation
Version 3.0.3-105-gd3941f44
MR::App::Argument Class Reference

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
 
Argumentoptional ()
 specifies that the argument is optional More...
 
Argumentallow_multiple ()
 specifies that multiple such arguments can be specified More...
 
Argumenttype_text ()
 specifies that the argument should be a text string More...
 
Argumenttype_image_in ()
 specifies that the argument should be an input image More...
 
Argumenttype_image_out ()
 specifies that the argument should be an output image More...
 
Argumenttype_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...
 
Argumenttype_bool ()
 specifies that the argument should be a boolean More...
 
Argumenttype_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...
 
Argumenttype_choice (const char *const *choices)
 specifies that the argument should be selected from a predefined list More...
 
Argumenttype_file_in ()
 specifies that the argument should be an input file More...
 
Argumenttype_file_out ()
 specifies that the argument should be an output file More...
 
Argumenttype_directory_in ()
 specifies that the argument should be an input directory More...
 
Argumenttype_directory_out ()
 specifies that the argument should be an output directory More...
 
Argumenttype_sequence_int ()
 specifies that the argument should be a sequence of comma-separated integer values More...
 
Argumenttype_sequence_float ()
 specifies that the argument should be a sequence of comma-separated floating-point values. More...
 
Argumenttype_tracks_in ()
 specifies that the argument should be an input tracks file More...
 
Argumenttype_tracks_out ()
 specifies that the argument should be an output tracks file More...
 
Argumenttype_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...
 

Detailed Description

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:

+ Argument ("input", "the input image")
.type_image_in()
+ Argument ("parameter",
"the parameter to use during processing. Allowed values are "
"between 0 and 10 (default = 1).")
.type_float (0.0, 10.0)
+ Argument ("output", "the output image")
.type_image_out();
Argument(const char *name=nullptr, std::string description=std::string())
constructor
ArgumentList ARGUMENTS
the arguments expected by the command

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.

Constructor & Destructor Documentation

◆ Argument()

MR::App::Argument::Argument ( const char *  name = nullptr,
std::string  description = std::string() 
)
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.

Member Function Documentation

◆ allow_multiple()

Argument & MR::App::Argument::allow_multiple ( )
inline

specifies that multiple such arguments can be specified

See optional() for details.

Definition at line 160 of file cmdline_option.h.

◆ operator bool()

MR::App::Argument::operator bool ( ) const
inline

Definition at line 138 of file cmdline_option.h.

◆ optional()

Argument & MR::App::Argument::optional ( )
inline

specifies that the argument is optional

For example:

+ Argument ("input", "the input image")
.type_image_in()
.optional()
.allow_multiple();
Note
Only one argument can be specified as optional and/or multiple.

Definition at line 153 of file cmdline_option.h.

◆ syntax()

std::string MR::App::Argument::syntax ( int  format) const

◆ type_bool()

Argument & MR::App::Argument::type_bool ( )
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.

◆ type_choice()

Argument & MR::App::Argument::type_choice ( const char *const *  choices)
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:

const char* mode_list [] = { "standard", "pedantic", "approx", nullptr };
+ Argument ("mode", "the mode of operation")
.type_choice (mode_list);
Note
Each string in the list must be supplied in lowercase.

Definition at line 226 of file cmdline_option.h.

◆ type_directory_in()

Argument & MR::App::Argument::type_directory_in ( )
inline

specifies that the argument should be an input directory

Definition at line 248 of file cmdline_option.h.

◆ type_directory_out()

Argument & MR::App::Argument::type_directory_out ( )
inline

specifies that the argument should be an output directory

Definition at line 255 of file cmdline_option.h.

◆ type_file_in()

Argument & MR::App::Argument::type_file_in ( )
inline

specifies that the argument should be an input file

Definition at line 234 of file cmdline_option.h.

◆ type_file_out()

Argument & MR::App::Argument::type_file_out ( )
inline

specifies that the argument should be an output file

Definition at line 241 of file cmdline_option.h.

◆ type_float()

Argument & MR::App::Argument::type_float ( const default_type  min = -std::numeric_limits<default_type>::infinity(),
const default_type  max = std::numeric_limits<default_type>::infinity() 
)
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.

◆ type_image_in()

Argument & MR::App::Argument::type_image_in ( )
inline

specifies that the argument should be an input image

Definition at line 173 of file cmdline_option.h.

◆ type_image_out()

Argument & MR::App::Argument::type_image_out ( )
inline

specifies that the argument should be an output image

Definition at line 180 of file cmdline_option.h.

◆ type_integer()

Argument & MR::App::Argument::type_integer ( const int64_t  min = std::numeric_limits<int64_t>::min(),
const int64_t  max = std::numeric_limits<int64_t>::max() 
)
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.

◆ type_sequence_float()

Argument & MR::App::Argument::type_sequence_float ( )
inline

specifies that the argument should be a sequence of comma-separated floating-point values.

Definition at line 269 of file cmdline_option.h.

◆ type_sequence_int()

Argument & MR::App::Argument::type_sequence_int ( )
inline

specifies that the argument should be a sequence of comma-separated integer values

Definition at line 262 of file cmdline_option.h.

◆ type_text()

Argument & MR::App::Argument::type_text ( )
inline

specifies that the argument should be a text string

Definition at line 166 of file cmdline_option.h.

◆ type_tracks_in()

Argument & MR::App::Argument::type_tracks_in ( )
inline

specifies that the argument should be an input tracks file

Definition at line 276 of file cmdline_option.h.

◆ type_tracks_out()

Argument & MR::App::Argument::type_tracks_out ( )
inline

specifies that the argument should be an output tracks file

Definition at line 283 of file cmdline_option.h.

◆ type_various()

Argument & MR::App::Argument::type_various ( )
inline

specifies that the argument could be one of various types

Definition at line 290 of file cmdline_option.h.

◆ usage()

std::string MR::App::Argument::usage ( ) const

Member Data Documentation

◆ choices

const char* const* MR::App::Argument::choices

Definition at line 128 of file cmdline_option.h.

◆ desc

std::string MR::App::Argument::desc

the argument description

Definition at line 120 of file cmdline_option.h.

◆ 

struct { ... } MR::App::Argument::f

◆ flags

ArgFlags MR::App::Argument::flags

the argument flags (AllowMultiple & Optional)

Definition at line 124 of file cmdline_option.h.

◆ 

struct { ... } MR::App::Argument::i

◆ id

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

◆ max [1/2]

int64_t MR::App::Argument::max

Definition at line 130 of file cmdline_option.h.

◆ max [2/2]

default_type MR::App::Argument::max

Definition at line 133 of file cmdline_option.h.

◆ min [1/2]

int64_t MR::App::Argument::min

Definition at line 130 of file cmdline_option.h.

◆ min [2/2]

default_type MR::App::Argument::min

Definition at line 133 of file cmdline_option.h.

◆ type

ArgType MR::App::Argument::type

the argument type

Definition at line 122 of file cmdline_option.h.


The documentation for this class was generated from the following file: