CCmdOptionList Class Reference

The class to hold the list of options. More...

#include <mia/core/cmdlineparser.hh>

Public Types

enum  EHelpRequested {
  hr_no = 0, hr_help, hr_help_xml, hr_usage,
  hr_version, hr_copyright, hr_selftest
}
 

Public Member Functions

void add (PCmdOption opt)
 
void add (const std::string &group, PCmdOption opt)
 
void add_selftest (int &test_result, CSelftestCallback *callback)
 
 CCmdOptionList (const SProgramDescription &description)
 
const std::vector< std::string > & get_remaining () const
 
CHistoryRecord get_values () const
 
EHelpRequested parse (size_t argc, char *args[], const std::string &additional_type, const CPluginHandlerBase *additional_help=NULL) __attribute__((warn_unused_result))
 
EHelpRequested parse (size_t argc, const char *args[], const std::string &additional_type, const CPluginHandlerBase *additional_help=NULL) __attribute__((warn_unused_result))
 
EHelpRequested parse (size_t argc, char *args[]) __attribute__((warn_unused_result))
 
EHelpRequested parse (size_t argc, const char *args[]) __attribute__((warn_unused_result))
 
void set_group (const std::string &group)
 
void set_logstream (std::ostream &os)
 
void set_stdout_is_result ()
 
 ~CCmdOptionList ()
 cleanup More...
 

Detailed Description

The class to hold the list of options.

This class holds all the user defined and default command line option, handles the parsing and the printing of help.

Todo:
the whole command line option class structure needs a code cleanup

Definition at line 126 of file cmdlineparser.hh.

Member Enumeration Documentation

◆ EHelpRequested

This enum describes the type of help information that has been requested

Enumerator
hr_no 

no help has been requested

hr_help 

standard help output has been requested

hr_help_xml 

XML-formatted help has been requested

hr_usage 

a short usage description has been requested

hr_version 

The version information has been requested

hr_copyright 

The long copyright information has been requested

hr_selftest 

The selftest was run

Definition at line 132 of file cmdlineparser.hh.

Constructor & Destructor Documentation

◆ CCmdOptionList()

CCmdOptionList::CCmdOptionList ( const SProgramDescription description)

Constructor creates the options list and adds some defaut options like –help, –verbose, –copyright, and –usage

Parameters
descriptiongive a description of the program

◆ ~CCmdOptionList()

CCmdOptionList::~CCmdOptionList ( )

cleanup

Member Function Documentation

◆ add() [1/2]

void CCmdOptionList::add ( PCmdOption  opt)

add a new option to the option list

Parameters
optthe option to add

◆ add() [2/2]

void CCmdOptionList::add ( const std::string &  group,
PCmdOption  opt 
)

Add a new option to an option group

Parameters
groupoption group to add this option to
optthe option to add

◆ add_selftest()

void CCmdOptionList::add_selftest ( int &  test_result,
CSelftestCallback callback 
)

Add a selftest option.

The selftest option runs the given self test and then exists. Additional parameters given on the command line are ignored. The option is set within the group Test and provides the long optionb name –selftest.

Parameters
[out]test_resultstores the result returned by running by running the test suite
callbackthe test functor that must have CSelftestCallback as a base class

◆ get_remaining()

const std::vector<std::string>& CCmdOptionList::get_remaining ( ) const
Returns
a vector of the remaining arguments

◆ get_values()

CHistoryRecord CCmdOptionList::get_values ( ) const
Returns
the values of all arguments as a history record to support tracking of changes on data worked on by mia

◆ parse() [1/4]

EHelpRequested CCmdOptionList::parse ( size_t  argc,
char *  args[],
const std::string &  additional_type,
const CPluginHandlerBase additional_help = NULL 
)

the work routine, can take the arguemnts straight from main This version parses the command line and allows for additional arguments that can be read by get_remaining().

Parameters
argcnumber of arguments
argsarray of arguments strings
additional_typewill is a help string to describe the type of free parameters
additional_helpIf you use a plug-in handler to process the free parameters then pass the pointer to the according plug-in handler here, so that the help system can create proper documentation

◆ parse() [2/4]

EHelpRequested CCmdOptionList::parse ( size_t  argc,
const char *  args[],
const std::string &  additional_type,
const CPluginHandlerBase additional_help = NULL 
)

the work routine, can take the arguemnts straight from main This version parses the command line and allows for additional arguments that can be read by get_remaining().

Parameters
argcnumber of arguments
argsarray of arguments strings
additional_typewill is a help string to describe the type of free parameters
additional_helpIf you use a plug-in handler to process the free parameters then pass the pointer to the according plug-in handler here, so that the help system can create proper documentation

◆ parse() [3/4]

EHelpRequested CCmdOptionList::parse ( size_t  argc,
char *  args[] 
)

the work routine, can take the arguemnts straight from main This version parses doesn't allow additional parameters.

Parameters
argcnumber of arguments
argsarray of arguments strings

◆ parse() [4/4]

EHelpRequested CCmdOptionList::parse ( size_t  argc,
const char *  args[] 
)

the work routine, can take the arguemnts straight from main This version parses doesn't allow additional parameters.

Parameters
argcnumber of arguments
argsarray of arguments strings

◆ set_group()

void CCmdOptionList::set_group ( const std::string &  group)

Set the option group to add subsequent options to

Parameters
group

◆ set_logstream()

void CCmdOptionList::set_logstream ( std::ostream &  os)

Set the output stream for help/usage messages

Parameters
osnew output stream

◆ set_stdout_is_result()

void CCmdOptionList::set_stdout_is_result ( )

This function sets a flag that indicates that data written to stdout is an actual result


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