argagg: argagg::option_result Struct Reference

argagg

Loading...
Searching...
No Matches
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>
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.
template<typename T>
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.
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.
bool | operator! () const
| Explicitly define a unary not operator that wraps the implicit boolean conversion specialization in case the compiler can't do it automatically.

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

## 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 264 of file argagg.hpp.

## Member Function Documentation

## ◆ as() [1/2]

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 736 of file argagg.hpp.

## ◆ as() [2/2]

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 747 of file argagg.hpp.

## ◆ operator T()

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 767 of file argagg.hpp.

## ◆ operator!()

bool argagg::option_result::operator! | ( |  | ) | const
| inline

Explicitly define a unary not operator that wraps the implicit boolean conversion specialization in case the compiler can't do it automatically.

Definition at line 781 of file argagg.hpp.

## Member Data Documentation

## ◆ arg

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 271 of file argagg.hpp.

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

- /tmp/pkg/src/argagg-0.4.7/include/argagg/argagg.hpp