TCmdOption< T > Class Template Reference

Templated version based on CCmdOptionValue for values that can be converted to and from strings by stream operators. More...

#include <mia/core/cmdparamoption.hh>

Inheritance diagram for TCmdOption< T >:
[legend]
Collaboration diagram for TCmdOption< T >:
[legend]

Public Member Functions

 TCmdOption (T &val, char short_opt, const char *long_opt, const char *long_help, const char *short_help, CCmdOptionFlags flags=CCmdOptionFlags::none)
 
- Public Member Functions inherited from CCmdOption
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...
 

Additional Inherited Members

- Protected Member Functions inherited from CCmdOption
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

template<typename T>
class TCmdOption< T >

Templated version based on CCmdOptionValue for values that can be converted to and from strings by stream operators.

Templated implementation of a command line option to hold a value of type T.

Template Parameters
Tvalue parameter, the type T has to support the operators "std::ostream& operator << (std::ostream& os, T x)" and "std::istream& operator >> (std::istream& os, T x)" must be defined. f the string passed to the option for translation can not be translation to a value of type T, the set_value method will throw a std::invalid_argument exception If T is of type template < typename R > std::vector < R >, the list of N values needs to be given like value1,value2,...,valueN.

Definition at line 49 of file cmdparamoption.hh.

Constructor & Destructor Documentation

◆ TCmdOption()

template<typename T >
TCmdOption< T >::TCmdOption ( T &  val,
char  short_opt,
const char *  long_opt,
const char *  long_help,
const char *  short_help,
CCmdOptionFlags  flags = CCmdOptionFlags::none 
)

Constructor of the command option

Parameters
[in,out]valvariable to hold the parsed option value - pass in the default value - exception: bool values always default to false
short_optshort option name (or 0)
long_optlong option name (must not be NULL)
long_helplong help string (must not be NULL)
short_helpshort help string
flagssupport options like required

Definition at line 317 of file cmdparamoption.hh.

References CCmdOption::do_get_long_help(), CCmdOption::is_required(), and CCmdOption::xmlhelp_set_attribute().


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