Data Structures | Typedefs | Enumerations | Functions
Command line and parameter parsing

These classes and functions relate to the parsing of the command line and the parameter parsing for plug-ins. More...

Data Structures

class  CHelpOption::Callback
 Interface for the callback to print the help assositated with the given option. More...
 
class  CCmdBoolOption
 The command line option that sets a flag to true when given. More...
 
class  CCmdFlagOption
 Command line option that translates a string to a set of flags. More...
 
class  CCmdOption
 The base class for all command line options. More...
 
class  CCmdOptionList
 The class to hold the list of options. More...
 
class  CCmdStringOption
 The command line option that expects a string. More...
 
class  CComplexOptionParser
 Parser for complex command line options. More...
 
class  CDictParameter< T >
 Dictionary paramater. More...
 
class  CHelpOption
 A command line option that will appear in the help group and exits the program after printing the help. More...
 
class  CParameter
 The base class for parameters used in complex options. More...
 
class  CParamList
 A class to hold a list of named parameters. More...
 
class  CParamOption
 command line option that handles a parameter More...
 
class  CPropertyFlagHolder
 This class holds a set of properties. More...
 
class  CSetParameter< T >
 A parameter that can only assume values out of a limited set. More...
 
class  CTParameter< T >
 Generic type of a complex paramter. More...
 
class  TCmdOption< T >
 Templated version based on CCmdOptionValue for values that can be converted to and from strings by stream operators. More...
 
class  TDelayedParameter< T >
 A parameter proxy object with a key to identify it. More...
 
class  TDictMap< T >
 A mapper from emums to string values. - usefull for names flags. More...
 
class  TFactoryParameter< F >
 A parameter that get's initialized by a factory to a shared or unique pointer. More...
 
class  TParameter< T >
 A parameter that can assume any value of the given value type. More...
 
class  TPluginHandlerHelpCallback< PluginHandler >
 Help callback to print the help for the given plug-in. More...
 
class  TRangeParameter< T >
 Scalar parameter with an expected value range. More...
 

Typedefs

typedef std::map< std::string,
std::string > 
CParsedOptions
 
typedef std::map
< EProgramDescriptionEntry,
const char * > 
SProgramDescription
 the map that holds a basic program description More...
 

Enumerations

enum  EProgramDescriptionEntry {
  pdi_group = 0, pdi_short = 1, pdi_description = 2, pdi_example_descr = 3,
  pdi_example_code = 4, pdi_author = 5
}
 program description entry identifiers More...
 

Functions

PCmdOption make_help_opt (const char *long_opt, char short_opt, const char *long_help, CHelpOption::Callback *cb)
 Create a command line help option. More...
 
template<typename T >
PCmdOption make_opt (T &value, const char *long_opt, char short_opt, const char *help, bool flags=false)
 Create a standard option that sets a value of the give type. More...
 
template<typename T , typename Tmin , typename Tmax >
PCmdOption make_opt (T &value, Tmin min, Tmax max, const char *long_opt, char short_opt, const char *help, bool flags=false)
 Create an option of a scalar value that is expecte to be within a given range. More...
 
template<typename T >
PCmdOption make_opt (std::vector< T > &value, const char *long_opt, char short_opt, const char *help, bool required=false)
 Create an option to set a vector of values,. More...
 
PCmdOption make_opt (bool &value, const char *long_opt, char short_opt, const char *help)
 Create an option that represents a flag. More...
 
template<typename T >
PCmdOption make_opt (T &value, const TDictMap< T > &map, const char *long_opt, char short_opt, const char *help)
 Create a table lookup option. More...
 
PCmdOption make_opt (int &value, const CFlagString &map, const char *long_opt, char short_opt, const char *long_help, const char *short_help, bool flags=false)
 Create a flag lookup option. More...
 
PCmdOption make_opt (std::string &value, const char *long_opt, char short_opt, const char *long_help, bool required=false, const CPluginHandlerBase *plugin_hint=NULL)
 Create an option to set a string. More...
 
template<typename T >
PCmdOption make_opt (T &value, const std::set< T > &valid_set, const char *long_opt, char short_opt, const char *help, bool required=false)
 Create an oüption that only takes values from a pre-defined set. More...
 
template<typename T >
PCmdOption make_opt (typename std::shared_ptr< T > &value, const char *default_value, const char *long_opt, char short_opt, const char *help, bool required=false)
 Create a command line option that creates uses a factory to create an object based on the given description. More...
 
template<typename T >
PCmdOption make_opt (typename std::unique_ptr< T > &value, const char *default_value, const char *long_opt, char short_opt, const char *help, bool required=false)
 Create a command line option that creates uses a factory to create an object based on the given description. More...
 
template<typename T >
CParametermake_param (std::shared_ptr< T > &value, const std::string &init, bool required, const char *descr)
 create a factory parameter that initializes to a std::shared_ptr More...
 
template<typename T >
CParametermake_param (std::unique_ptr< T > &value, const std::string &init, bool required, const char *descr)
 create a factory parameter that initializes to a std::unique_ptr More...
 

Detailed Description

These classes and functions relate to the parsing of the command line and the parameter parsing for plug-ins.

Typedef Documentation

typedef std::map<std::string, std::string> CParsedOptions

a map of parsed options as pairs key:value pairs

Definition at line 37 of file optionparser.hh.

typedef std::map<EProgramDescriptionEntry, const char *> SProgramDescription

the map that holds a basic program description

Map of strings to provied information about the program The following values should be provied: (1) the program section, (2) A short description of the program - this will become the whatis entry in the man page, (3) A long description of the program (4) A text describing an example usage (5) The actual exampel call without the program name. This information is used by the auto-help system to create man-pages and a cross-referenced help of all the programs.

Definition at line 83 of file cmdlineparser.hh.

Enumeration Type Documentation

program description entry identifiers

These enumerates identify the parts of the program description

Enumerator
pdi_group 
pdi_short 
pdi_description 
pdi_example_descr 
pdi_example_code 
pdi_author 

Definition at line 58 of file cmdlineparser.hh.

Function Documentation

PCmdOption make_help_opt ( const char *  long_opt,
char  short_opt,
const char *  long_help,
CHelpOption::Callback cb 
)

Create a command line help option.

Create a command line hoption that is used to print out some help.

Parameters
long_optlong option name
short_optshort option char, set to 0 of none givn
long_helpthe help string for thie option
cba call back that us used to write the help
template<typename T >
PCmdOption make_opt ( T &  value,
const char *  long_opt,
char  short_opt,
const char *  help,
bool  flags = false 
)

Create a standard option that sets a value of the give type.

Create a standard option that translates a string given on the command line into a value. The translation back-end is implemented with CTParameter.

Template Parameters
Tthe type of thevalue, it must support to be read from (operator >>) and written (operator << ) to a stream, as the back-end uses these opterator to translate.
Parameters
[in,out]valueat input the default value, at output the parsed value if it was given.
short_optshort option name (or 0)
long_optlong option name (must not be NULL)
helplong help string (must not be NULL)
flagsadd flags like whether the optionis required to be set
Returns
the option warped into a boost::shared_ptr

Definition at line 593 of file cmdlineparser.hh.

template<typename T , typename Tmin , typename Tmax >
PCmdOption make_opt ( T &  value,
Tmin  min,
Tmax  max,
const char *  long_opt,
char  short_opt,
const char *  help,
bool  flags = false 
)

Create an option of a scalar value that is expecte to be within a given range.

If the given value does not fit into the range it will be adjusted accordingly

Template Parameters
Ttype of the value to be parsed, supported are float, double, long, int, short, unsigned long, unsigned int, unsigned short.
Tmintype of the given minmum of the range, a conversion to type T must exist
Tmaxtype of the given maximum of the range, a conversion to type T must exist
Parameters
valuevalue variable to hold the parsed option value - pass in the default value -
minstart of the value range the option can be set to
maxend of the value range the option can be set to
short_optshort option name (or 0)
long_optlong option name (must not be NULL)
helplong help string (must not be NULL)
flagsadd flags like whether the optionis required to be set
Returns
the option warped into a boost::shared_ptr

Definition at line 617 of file cmdlineparser.hh.

template<typename T >
PCmdOption make_opt ( std::vector< T > &  value,
const char *  long_opt,
char  short_opt,
const char *  help,
bool  required = false 
)

Create an option to set a vector of values,.

The parameters on the command line will be separated by ',' and without spaces (or protected from the shell by usinh "". If the vetcor comes with a pre-allocated size, then the numer of given values must correspond to this size, Otherwise the size of the vector is deducted from the given command line parameter,.

Template Parameters
Ttype of the value hold by the vector
Parameters
[in,out]valueat input: if not empty, number of expected values and their defaults, at output: the values given on the command line
long_optlong option name (must not be NULL)
short_optshort option name (or 0)
helphelp string (must not be NULL)
requiredset to true if the option is required to be set
Remarks
be aware that localization of the decimal separator of floating point values is not supported, it is always the full stop ".".

Definition at line 642 of file cmdlineparser.hh.

PCmdOption make_opt ( bool &  value,
const char *  long_opt,
char  short_opt,
const char *  help 
)

Create an option that represents a flag.

It is always assumed to be not set if the according option is not given at the command line

Parameters
[out]valuethe boolean that carries the result
long_optlong option name (must not be NULL)
short_optshort option name (or 0)
helphelp string (must not be NULL)
Returns
the option warped into a boost::shared_ptr
template<typename T >
PCmdOption make_opt ( T &  value,
const TDictMap< T > &  map,
const char *  long_opt,
char  short_opt,
const char *  help 
)

Create a table lookup option.

Create an option that uses a table to translate between the string given on the command line and the actual value.

Template Parameters
Tthe type of the value
Parameters
[in,out]valuevariable to hold the parsed and translated option value. At entry, the value must be set to a valid dictionary entry.
mapthe lookup table for the option
long_optlong option name (must not be NULL)
short_optshort option name (or 0)
helphelp string (must not be NULL)
Returns
the option warped into a boost::shared_ptr

Definition at line 680 of file cmdlineparser.hh.

PCmdOption make_opt ( int &  value,
const CFlagString map,
const char *  long_opt,
char  short_opt,
const char *  long_help,
const char *  short_help,
bool  flags = false 
)

Create a flag lookup option.

Parameters
[in,out]valueat input it holds the default value, at output, if the command line option was givem this value is replaced by the parsed and translated option value,
mapthe lookup table for the option flags
long_optlong option name (must not be NULL)
short_optshort option name (or 0)
long_helplong help string (must not be NULL)
short_helpshort help string
flagsadd flags like whether the optionis required to be set
Returns
the option warped into a boost::shared_ptr
Remarks
Probably unnecessary
PCmdOption make_opt ( std::string &  value,
const char *  long_opt,
char  short_opt,
const char *  long_help,
bool  required = false,
const CPluginHandlerBase plugin_hint = NULL 
)

Create an option to set a string.

Create an option that holds a string

Parameters
[in,out]valueat input it holds the default value, at output, if the command line option was givem this value is replaced by the parsed and translated option value,
long_optlong option name (must not be NULL)
short_optshort option name (or 0)
long_helplong help string (must not be NULL)
requiredset to true if the option is required to be set
plugin_hintif the string will later be used to create an object by using plug-in then pass a pointer to the corresponding plug-in handler to give a hint the help system about this connection.
Returns
the option warped into a boost::shared_ptr
template<typename T >
PCmdOption make_opt ( T &  value,
const std::set< T > &  valid_set,
const char *  long_opt,
char  short_opt,
const char *  help,
bool  required = false 
)

Create an oüption that only takes values from a pre-defined set.

Create an option that can only take values from a given set.

Template Parameters
Tthe type of the value to be set
Parameters
[in,out]valueat input it holds the default value, at output, if the command line option was givem this value is replaced by the parsed and translated option value,
valid_setthe set of allowed values
long_optlong option name (must not be NULL)
short_optshort option name (or 0)
helplong help string (must not be NULL)
requiredset true if the optionis required to be set
Returns
the option warped into a boost::shared_ptr

Definition at line 746 of file cmdlineparser.hh.

template<typename T >
PCmdOption make_opt ( typename std::shared_ptr< T > &  value,
const char *  default_value,
const char *  long_opt,
char  short_opt,
const char *  help,
bool  required = false 
)

Create a command line option that creates uses a factory to create an object based on the given description.

Create a command line option that creates uses a factory to create the value based on the command line arguments given,

Template Parameters
Tthe non-pointer type of the value
Parameters
[out]valueat output, if the command line option was givem this value is replaced by the parsed and translated option value. If not given but the default_values was given then this default initializer is used to create the actual value. If no default value was givem and the option is not given at the command line, then the value is not touched.
default_valuedefault value if parameter is not given
long_optlong option name
short_optshort option char, set to 0 of none givn
helpthe help string for thie option
requiredset true if the optionis required to be set
Remarks
although passing in an initialized pointer and and empty default_value would act like the the initializer string was used for the pointer, it is better to pass an empty shared pointer in order to avoid unnecessary initializations of the pointer is later overwritten.

Definition at line 776 of file cmdlineparser.hh.

template<typename T >
PCmdOption make_opt ( typename std::unique_ptr< T > &  value,
const char *  default_value,
const char *  long_opt,
char  short_opt,
const char *  help,
bool  required = false 
)

Create a command line option that creates uses a factory to create an object based on the given description.

Create a command line option that uses a TFactoryPluginHandler to create the actual value hold by a std::unique_ptr.

Template Parameters
Tthe non-pointer type of the value
Parameters
[out]valueat output, if the command line option was given this value is replaced by the parsed and translated option value. If not given but the default_values was given then this default initializer is used to create the actual value.
default_valuedefault value if parameter is not given
long_optlong option name
short_optshort option char, set to 0 of none givn
helpthe help string for thie option
requiredset true if the optionis required to be set
Remarks
although passing in an initialized pointer and and empty default_value would act like the the initializer string was used for the pointer, it is better to pass an empty shared pointer in order to avoid unnecessary initializations of the pointer is later overwritten.

Definition at line 803 of file cmdlineparser.hh.

template<typename T >
CParameter* make_param ( std::shared_ptr< T > &  value,
const std::string &  init,
bool  required,
const char *  descr 
)

create a factory parameter that initializes to a std::shared_ptr

Creates a TFactoryParameter accurding to the given parameters. The advantage over calling the TactoryParameter cunstructor is, that type deduction is done automatically.

Template Parameters
thetype of the factory created parameter value
Parameters
valuethe shared_ptr value to be set through this parameter. Best is to pass an empty shared pointer and leave the initialization to the parameter handling
initthe default initialization string for the parameter, pass "" if there is no default.
requiredset to true if the user must set this parameter
descra help description of the parameter

Definition at line 445 of file parameter.hh.

Referenced by TWatershedFilterPlugin< dim >::TWatershedFilterPlugin().

template<typename T >
CParameter* make_param ( std::unique_ptr< T > &  value,
const std::string &  init,
bool  required,
const char *  descr 
)

create a factory parameter that initializes to a std::unique_ptr

Creates a TFactoryParameter accurding to the given parameters. The advantage over calling the TactoryParameter cunstructor is that type deduction is done automatically.

Template Parameters
thetype of the factory created parameter value
Parameters
valuethe unique_ptr value to be set through this parameter. Best is to pass an empty unique pointer and leave the initialization to the parameter handling
initthe default initialization string for the parameter, pass "" if there is no default.
requiredset to true if the user must set this parameter
descra help description of the parameter

Definition at line 467 of file parameter.hh.