CCmdOption Class Referenceabstract

The base class for all command line options. More...

#include <mia/core/cmdoption.hh>

Inheritance diagram for CCmdOption:
[legend]

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ CCmdOption()

CCmdOption::CCmdOption ( char  short_opt,
const char *  long_opt,
const char *  long_help,
const char *  short_help,
CCmdOptionFlags  flags 
)

The constructor

Parameters
short_optthe short option character
long_optthe long option name
long_helpa long help string
short_helphelp to print out when only usage information is requested
flagsadd certain CCmdOptionFlags to the option

◆ ~CCmdOption()

virtual CCmdOption::~CCmdOption ( )
virtual

ensure virtual destruction

Member Function Documentation

◆ add_option()

void CCmdOption::add_option ( CShortoptionMap sm,
CLongoptionMap lm 
)

Add this option to the given option maps

Parameters
sma CShortoptionMap to add this option to
lma CLongoptionMap to add this option to

◆ add_option_xml()

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

Parameters
[in,out]parentthe parent xml node to which to add documentation
[in,out]handler_mapthe map of possibely recoursively called plug-in handlers

◆ clear_required()

void CCmdOption::clear_required ( )
protected

clear the "required" flag

◆ do_get_long_help()

virtual void CCmdOption::do_get_long_help ( std::ostream &  os) const
protectedvirtual

write the long help string to a stream

Parameters
osthe output stream

Referenced by TCmdOption< T >::TCmdOption(), and TRepeatableCmdOption< T >::TRepeatableCmdOption().

◆ get_long_help()

void CCmdOption::get_long_help ( std::ostream &  os) const

Print the long option name of the option to an output stream

Parameters
osthe output stream

◆ get_long_help_xml()

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

Parameters
parentthe parent xml node to which to add documentation
[in,out]handler_mapthe map of possibely recoursively called plug-in handlers
Returns
the text relate to the help
Remarks
the text should probably be added to the parent node instead.

◆ get_long_option()

const char* CCmdOption::get_long_option ( ) const
Returns
the long name of the option

◆ get_needed_args()

size_t CCmdOption::get_needed_args ( ) const
Returns
how many arguments after the option argument on the command line will be used by this option

◆ get_opt_help()

void CCmdOption::get_opt_help ( std::ostream &  os) const

Print the help of the option to an output stream

Parameters
osthe output stream

◆ get_short_option()

char CCmdOption::get_short_option ( ) const
Returns
the long name of the option

◆ get_value_as_string()

const std::string CCmdOption::get_value_as_string ( ) const
Returns
the options value as string

◆ has_flag()

bool CCmdOption::has_flag ( CCmdOptionFlags  test_flags) const
protected

Referenced by make_opt().

◆ is_required()

bool CCmdOption::is_required ( ) const
Returns
true if the option is a required option and hasn't been set

Referenced by TCmdOption< T >::TCmdOption(), and TRepeatableCmdOption< T >::TRepeatableCmdOption().

◆ long_help()

const char* CCmdOption::long_help ( ) const
Returns
the long help string

Referenced by make_opt().

◆ post_set()

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

◆ print_short_help()

void CCmdOption::print_short_help ( std::ostream &  os) const

Print the short help of the option to an output stream

Parameters
osthe output stream

◆ set_value()

void CCmdOption::set_value ( const char *  str_value)

Set the value of the option parameter based on the input string

Parameters
str_valuethe string value to be vonverted to the option value

◆ write_value()

void CCmdOption::write_value ( std::ostream &  os) const

Writes out the value of the option to an output stream

Parameters
osthe output stream to write this options value to

◆ xmlhelp_set_attribute()

void CCmdOption::xmlhelp_set_attribute ( CXMLElement node,
const char *  name,
const std::string &  value 
) const
protected

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