yat  0.10.4pre
Public Member Functions | Protected Member Functions
theplu::yat::utility::OptionArg< T > Class Template Reference

Option with argument. More...

#include </scratch/bob/jari/tmp/pristine/yat-0.10.x/yat/utility/OptionArg.h>

Inheritance diagram for theplu::yat::utility::OptionArg< T >:
theplu::yat::utility::Option

List of all members.

Public Member Functions

 OptionArg (CommandLine &cmd, std::string name, std::string desc, bool required=false)
 Constructor.
void print_arg (std::string arg)
value (void) const
void value (T v)
 set value
std::string description (void) const
void description (const std::string &description)
 set description
std::string long_name (void) const
void parse (std::vector< std::string >::iterator &, const std::vector< std::string >::iterator &)
 parsing the commandline
bool present (void) const
 Get if option was found in cmd.
std::string print (void)
 print help output
void reset (void)
 sets present to false
char short_name (void) const
void validate (void)
 Validate the Option.

Protected Member Functions

bool required (void) const
const CommandLinecmd (void) const

Detailed Description

template<typename T>
class theplu::yat::utility::OptionArg< T >

Option with argument.

If the option is present, argument is set during parsing. Supported formats are both gnu-style "--support-gnu=value", POSIX-like "--support-posix value", as well as shorter "-s value". The argument of an parameter is retrived by the value() function. The type T should be either a string or a type supported by function convert().


Constructor & Destructor Documentation

template<typename T>
theplu::yat::utility::OptionArg< T >::OptionArg ( CommandLine cmd,
std::string  name,
std::string  desc,
bool  required = false 
)
inline

Constructor.

Parameters:
cmdCommandline Option is associated with
namestring such as "help" for –help, "h" for -h or "h,help" for having both short and long option name
descstring used in help display
requiredIf true option must be found in commandline or exception is thrown in validation

Member Function Documentation

const CommandLine& theplu::yat::utility::Option::cmd ( void  ) const
protectedinherited
Returns:
const reference to CommandLine Option belongs to.
std::string theplu::yat::utility::Option::description ( void  ) const
inherited
Returns:
description
void theplu::yat::utility::Option::description ( const std::string &  description)
inherited

set description

Since:
New in yat 0.7
std::string theplu::yat::utility::Option::long_name ( void  ) const
inherited
Returns:
long name e.g. 'help' for –help option.
bool theplu::yat::utility::Option::present ( void  ) const
inherited

Get if option was found in cmd.

Returns:
true if option has been detected in parsing
std::string theplu::yat::utility::Option::print ( void  )
inherited

print help output

This function calls the four virtual private functions print1, print2, print3, and print4. This allows an inherited class to implement one (or several) of these functions and keep the default output of the others. The default behavior is that:

template<typename T>
void theplu::yat::utility::OptionArg< T >::print_arg ( std::string  arg)
inline
Parameters:
argstring to be used in help output such as `=TARGET' in `–target=TARGET'. See print3().
Since:
New in yat 0.5.
template<typename T>
bool theplu::yat::utility::OptionArg< T >::required ( void  ) const
inlineprotected
Returns:
true if Option is required, i.e., if Option is not found during parsing an exception will be thrown.
char theplu::yat::utility::Option::short_name ( void  ) const
inherited
Returns:
short name e.g. 'h' for -h option.
void theplu::yat::utility::Option::validate ( void  )
inherited

Validate the Option.

This function is called by CommandLine::parse() after all options have been detected and parsed (see Option::parse()).

template<typename T>
T theplu::yat::utility::OptionArg< T >::value ( void  ) const
inline
Returns:
value
template<typename T>
void theplu::yat::utility::OptionArg< T >::value ( v)
inline

set value

Since:
new in yat 0.5

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

Generated on Mon Nov 11 2013 09:41:46 for yat by  doxygen 1.8.1