The base class for all command line options. More...
#include <mia/core/cmdoption.hh>
Public Member Functions | |
void | add_option (CShortoptionMap &sm, CLongoptionMap &lm) |
void | add_option_xml (CXMLElement &parent, HandlerHelpMap &handler_map) const |
CCmdOption (char short_opt, const char *long_opt, const char *long_help, const char *short_help, CCmdOptionFlags flags) | |
void | get_long_help (std::ostream &os) const |
std::string | get_long_help_xml (CXMLElement &parent, HandlerHelpMap &handler_map) const |
const char * | get_long_option () const |
size_t | get_needed_args () const |
void | get_opt_help (std::ostream &os) const |
char | get_short_option () const |
const std::string | get_value_as_string () const |
bool | is_required () const |
const char * | long_help () const |
void | post_set () |
void | print_short_help (std::ostream &os) const |
void | set_value (const char *str_value) |
void | write_value (std::ostream &os) const |
virtual | ~CCmdOption () |
ensure virtual destruction More... | |
Protected Member Functions | |
void | clear_required () |
clear the "required" flag More... | |
virtual void | do_get_long_help (std::ostream &os) const |
bool | has_flag (CCmdOptionFlags test_flags) const |
void | xmlhelp_set_attribute (CXMLElement &node, const char *name, const std::string &value) const |
The base class for all command line options.
The base class of all possible command line options. It defines the interface of the options as well as some basic functionality to create help strings.
Definition at line 50 of file cmdoption.hh.
CCmdOption::CCmdOption | ( | char | short_opt, |
const char * | long_opt, | ||
const char * | long_help, | ||
const char * | short_help, | ||
CCmdOptionFlags | flags | ||
) |
The constructor
short_opt | the short option character |
long_opt | the long option name |
long_help | a long help string |
short_help | help to print out when only usage information is requested |
flags | add certain CCmdOptionFlags to the option |
|
virtual |
ensure virtual destruction
void CCmdOption::add_option | ( | CShortoptionMap & | sm, |
CLongoptionMap & | lm | ||
) |
Add this option to the given option maps
sm | a CShortoptionMap to add this option to |
lm | a CLongoptionMap to add this option to |
void CCmdOption::add_option_xml | ( | CXMLElement & | parent, |
HandlerHelpMap & | handler_map | ||
) | const |
Adds the option description to the given parent node and adds used plug-in handlers to the helper map
[in,out] | parent | the parent xml node to which to add documentation |
[in,out] | handler_map | the map of possibely recoursively called plug-in handlers |
|
protected |
clear the "required" flag
|
protectedvirtual |
write the long help string to a stream
os | the output stream |
Referenced by TCmdOption< T >::TCmdOption(), and TRepeatableCmdOption< T >::TRepeatableCmdOption().
void CCmdOption::get_long_help | ( | std::ostream & | os | ) | const |
Print the long option name of the option to an output stream
os | the output stream |
std::string CCmdOption::get_long_help_xml | ( | CXMLElement & | parent, |
HandlerHelpMap & | handler_map | ||
) | const |
Returns help string tailered for the XML help creation system and adds used plug-in handlers to the helper map
parent | the parent xml node to which to add documentation | |
[in,out] | handler_map | the map of possibely recoursively called plug-in handlers |
const char* CCmdOption::get_long_option | ( | ) | const |
size_t CCmdOption::get_needed_args | ( | ) | const |
void CCmdOption::get_opt_help | ( | std::ostream & | os | ) | const |
Print the help of the option to an output stream
os | the output stream |
char CCmdOption::get_short_option | ( | ) | const |
const std::string CCmdOption::get_value_as_string | ( | ) | const |
|
protected |
Referenced by make_opt().
bool CCmdOption::is_required | ( | ) | const |
Referenced by TCmdOption< T >::TCmdOption(), and TRepeatableCmdOption< T >::TRepeatableCmdOption().
const char* CCmdOption::long_help | ( | ) | const |
Referenced by make_opt().
void CCmdOption::post_set | ( | ) |
This function must be called after the parameter was set through a string in order to handle complex initialization like done for factory based command line parameters
void CCmdOption::print_short_help | ( | std::ostream & | os | ) | const |
Print the short help of the option to an output stream
os | the output stream |
void CCmdOption::set_value | ( | const char * | str_value | ) |
Set the value of the option parameter based on the input string
str_value | the string value to be vonverted to the option value |
void CCmdOption::write_value | ( | std::ostream & | os | ) | const |
Writes out the value of the option to an output stream
os | the output stream to write this options value to |
|
protected |
Referenced by TCmdOption< T >::TCmdOption(), and TRepeatableCmdOption< T >::TRepeatableCmdOption().