argagg

Public Member Functions | Public Attributes | List of all members
argagg::option_results Struct Reference

Represents multiple option parse results for a single option. If treated as a single parse result it defaults to the last parse result. Note that an instance of this struct is always created even if no option results are parsed for a given definition. In that case it will simply be empty. More...

`#include <argagg.hpp>`

## Public Member Functions
std::size_t | count () const
| Gets the number of times the option shows up. More...
option_result & | operator[] (std::size_t index)
| Gets a single option parse result by index. More...
const option_result & | operator[] (std::size_t index) const
| Gets a single option result by index. More...
template<typename T >
T | as () const
| Converts the argument parsed for the LAST option parse result for the parent definition to the provided type. For example, if this was for "-f 1 -f 2 -f 3" then calling this method for an integer type will return 3. If there are no option parse results then a std::out_of_range exception is thrown. Any exceptions thrown by option_result::as() are not handled. More...
template<typename T >
T | as (const T &t) const
| Converts the argument parsed for the LAST option parse result for the parent definition to the provided type. For example, if this was for "-f 1 -f 2 -f 3" then calling this method for an integer type will return 3. If there are no option parse results then the provided default value is returned instead. More...
template<typename T >
| operator T () const
| Since we have the option_results::as() API we might as well alias it as an implicit conversion operator. This performs implicit conversion using the option_results::as() method. More...

## Public Attributes
std::vector< option_result > | all
| All option parse results for this option. More...

## Detailed Description

Represents multiple option parse results for a single option. If treated as a single parse result it defaults to the last parse result. Note that an instance of this struct is always created even if no option results are parsed for a given definition. In that case it will simply be empty.

To check if the associated option showed up at all simply use the implicit boolean conversion or check if count() is greater than zero.

Definition at line 239 of file argagg.hpp.

## Member Function Documentation

## ◆ as() [1/2]

template<typename T >

T argagg::option_results::as

Converts the argument parsed for the LAST option parse result for the parent definition to the provided type. For example, if this was for "-f 1 -f 2 -f 3" then calling this method for an integer type will return 3. If there are no option parse results then a std::out_of_range exception is thrown. Any exceptions thrown by option_result::as() are not handled.

Definition at line 719 of file argagg.hpp.

## ◆ as() [2/2]

template<typename T >

T argagg::option_results::as | ( | const T & | t | ) | const

Converts the argument parsed for the LAST option parse result for the parent definition to the provided type. For example, if this was for "-f 1 -f 2 -f 3" then calling this method for an integer type will return 3. If there are no option parse results then the provided default value is returned instead.

Definition at line 729 of file argagg.hpp.

## ◆ count()

std::size_t argagg::option_results::count | ( |  | ) | const
| inline

Gets the number of times the option shows up.

Definition at line 698 of file argagg.hpp.

## ◆ operator T()

template<typename T >

argagg::option_results::operator T

Since we have the option_results::as() API we might as well alias it as an implicit conversion operator. This performs implicit conversion using the option_results::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 739 of file argagg.hpp.

## ◆ operator[]() [1/2]

option_result & argagg::option_results::operator[] | ( | std::size_t | index | ) |
| inline

Gets a single option parse result by index.

Definition at line 705 of file argagg.hpp.

## ◆ operator[]() [2/2]

const option_result & argagg::option_results::operator[] | ( | std::size_t | index | ) | const
| inline

Gets a single option result by index.

Definition at line 712 of file argagg.hpp.

## Member Data Documentation

## ◆ all

std::vector<option_result> argagg::option_results::all

All option parse results for this option.

Definition at line 245 of file argagg.hpp.

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

- /usr/src/slapt-src/development/argagg/argagg-0.4.6/include/argagg/argagg.hpp