argagg
 All Classes Namespaces Files Functions Variables Macros Pages
Public Member Functions | Public Attributes | List of all members
argagg::option_result Struct Reference

Represents a single option parse result. More...

#include <argagg.hpp>

Public Member Functions

template<typename T >
as () const
 Converts the argument parsed for this single option instance into the given type using the type matched conversion function argagg::convert::arg(). If there was not an argument parsed for this single option instance then a argagg::option_lacks_argument_error exception is thrown. The specific conversion function may throw other exceptions. More...
 
template<typename T >
as (const T &t) const
 Converts the argument parsed for this single option instance into the given type using the type matched conversion function argagg::convert::arg(). If there was not an argument parsed for this single option instance then the provided default value is returned instead. If the conversion function throws an exception then it is ignored and the default value is returned. More...
 
template<typename T >
 operator T () const
 Since we have the argagg::option_result::as() API we might as well alias it as an implicit conversion operator. This performs implicit conversion using the argagg::option_result::as() method. More...
 

Public Attributes

const char * arg
 Argument parsed for this single option. If no argument was parsed this will be set to nullptr. More...
 

Detailed Description

Represents a single option parse result.

You can check if this has an argument by using the implicit boolean conversion.

Definition at line 178 of file argagg.hpp.

Member Function Documentation

template<typename T >
T argagg::option_result::as ( ) const

Converts the argument parsed for this single option instance into the given type using the type matched conversion function argagg::convert::arg(). If there was not an argument parsed for this single option instance then a argagg::option_lacks_argument_error exception is thrown. The specific conversion function may throw other exceptions.

Definition at line 653 of file argagg.hpp.

template<typename T >
T argagg::option_result::as ( const T &  t) const

Converts the argument parsed for this single option instance into the given type using the type matched conversion function argagg::convert::arg(). If there was not an argument parsed for this single option instance then the provided default value is returned instead. If the conversion function throws an exception then it is ignored and the default value is returned.

Definition at line 664 of file argagg.hpp.

template<typename T >
argagg::option_result::operator T ( ) const

Since we have the argagg::option_result::as() API we might as well alias it as an implicit conversion operator. This performs implicit conversion using the argagg::option_result::as() method.

Note
An implicit boolean conversion specialization exists which returns false if there is no argument for this single option instance and true otherwise. This specialization DOES NOT convert the argument to a bool. If you need to convert the argument to a bool then use the as() API.

Definition at line 684 of file argagg.hpp.

Member Data Documentation

const char* argagg::option_result::arg

Argument parsed for this single option. If no argument was parsed this will be set to nullptr.

Definition at line 185 of file argagg.hpp.


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