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

A class to specify a command-line option. More...

#include "cmdline_option.h"

Inheritance diagram for MR::App::Option:
MR::vector< Argument >

Public Member Functions

 Option ()
 
 Option (const char *name, const std::string &description)
 
Optionoperator+ (const Argument &arg)
 
 operator bool () const
 
Optionrequired ()
 specifies that the option is required More...
 
Optionallow_multiple ()
 specifies that multiple such options can be specified More...
 
bool is (const std::string &name) const
 
std::string syntax (int format) const
 
std::string usage () const
 
- Public Member Functions inherited from MR::vector< Argument >
 vector ()
 

Public Attributes

const char * id
 the option name More...
 
std::string desc
 the option description More...
 
ArgFlags flags
 option flags (AllowMultiple and/or Optional) More...
 

Detailed Description

A class to specify a command-line option.

Command-line options that are accepted by a particular command are specified as an array of Option objects, terminated with an empty Option (constructed using default parameters). Please refer to Command-line parsing for more information.

The list of options is provided using the OPTIONS macro, like this:

+ Option ("exact",
"do not use approximations when processing")
+ Option ("mask",
"only perform processing within the voxels contained in "
"the binary image specified")
+ Argument ("image").type_image_in()
+ Option ("regularisation",
"set the regularisation term")
+ Argument ("value").type_float (0.0, 1.0, 100.0)
Option ("dump",
"dump all intermediate values to file")
+ Argument ("file").type_file();
OptionList OPTIONS
the options accepted by the command

The example above specifies that the application accepts four options, in addition to the standard ones (see Command-line parsing for details). The first option is a simple switch: specifying '-exact' on the command line will cause the application to behave differently. The next options all expect an additional argument, supplied using the Argument class. Note that the description field of the Argument class is unused in this case. Multiple additional arguments can be specified in this way using the addition operator.

Options can also be specified as required (see required() function), or as multiple (see allow_multiple() function).

Definition at line 343 of file cmdline_option.h.

Constructor & Destructor Documentation

◆ Option() [1/2]

MR::App::Option::Option ( )
inline

Definition at line 345 of file cmdline_option.h.

◆ Option() [2/2]

MR::App::Option::Option ( const char *  name,
const std::string &  description 
)
inline

Definition at line 347 of file cmdline_option.h.

Member Function Documentation

◆ allow_multiple()

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

specifies that multiple such options can be specified

See required() for details.

Definition at line 385 of file cmdline_option.h.

◆ is()

bool MR::App::Option::is ( const std::string &  name) const
inline

Definition at line 390 of file cmdline_option.h.

◆ operator bool()

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

Definition at line 354 of file cmdline_option.h.

◆ operator+()

Option & MR::App::Option::operator+ ( const Argument arg)
inline

Definition at line 350 of file cmdline_option.h.

◆ required()

Option & MR::App::Option::required ( )
inline

specifies that the option is required

An option specified as required must be supplied on the command line. For example:

+ Option ("roi",
"the region of interest over which to perform the processing. "
"Multiple such regions can be specified")
.required()
.allow_multiple()
+ Argument ("image").type_image_in();

Definition at line 378 of file cmdline_option.h.

◆ syntax()

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

◆ usage()

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

Member Data Documentation

◆ desc

std::string MR::App::Option::desc

the option description

Definition at line 361 of file cmdline_option.h.

◆ flags

ArgFlags MR::App::Option::flags

option flags (AllowMultiple and/or Optional)

Definition at line 363 of file cmdline_option.h.

◆ id

const char* MR::App::Option::id

the option name

Definition at line 359 of file cmdline_option.h.


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