Public Member Functions | Static Public Attributes | Protected Member Functions
CCmdOption Class Referenceabstract

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

#include <mia/core/cmdoption.hh>

Inheritance diagram for CCmdOption:
CCmdBoolOption CCmdFlagOption CCmdStringOption CHelpOption CParamOption TCmdOption< T >

Public Member Functions

void add_option (CShortoptionMap &sm, CLongoptionMap &lm)
 
 CCmdOption (char short_opt, const char *long_opt, const char *long_help, const char *short_help, bool required)
 
void get_long_help (std::ostream &os) const
 
std::string get_long_help_xml (xmlpp::Element &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...
 

Static Public Attributes

static const bool not_required
 readability constant to show that an option is not required More...
 
static const bool required
 readability constant to show that an option is required More...
 

Protected Member Functions

void clear_required ()
 clear the "required" flag More...
 
virtual void do_get_long_help (std::ostream &os) 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 ( char  short_opt,
const char *  long_opt,
const char *  long_help,
const char *  short_help,
bool  required 
)

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
requiredset to true if the option must be set by the user
virtual CCmdOption::~CCmdOption ( )
virtual

ensure virtual destruction

Member Function Documentation

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
void CCmdOption::clear_required ( )
protected

clear the "required" flag

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

write the long help string to a stream

Parameters
osthe output stream
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
std::string CCmdOption::get_long_help_xml ( xmlpp::Element &  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.
const char* CCmdOption::get_long_option ( ) const
Returns
the long name of the option
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
void CCmdOption::get_opt_help ( std::ostream &  os) const

Print the help of the option to an output stream

Parameters
osthe output stream
char CCmdOption::get_short_option ( ) const
Returns
the long name of the option
const std::string CCmdOption::get_value_as_string ( ) const
Returns
the options value as string
bool CCmdOption::is_required ( ) const
Returns
true if the option is a required option and hasn't been set
const char* CCmdOption::long_help ( ) const
Returns
the long help string
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

Parameters
osthe output stream
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
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

Field Documentation

const bool CCmdOption::not_required
static

readability constant to show that an option is not required

Definition at line 54 of file cmdoption.hh.

const bool CCmdOption::required
static

readability constant to show that an option is required

Definition at line 57 of file cmdoption.hh.


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