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... | |
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.
T argagg::option_results::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.
Definition at line 719 of file argagg.hpp.
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.
|
inline |
Gets the number of times the option shows up.
Definition at line 698 of file argagg.hpp.
argagg::option_results::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.
Definition at line 739 of file argagg.hpp.
|
inline |
Gets a single option parse result by index.
Definition at line 705 of file argagg.hpp.
|
inline |
Gets a single option result by index.
Definition at line 712 of file argagg.hpp.
std::vector<option_result> argagg::option_results::all |
All option parse results for this option.
Definition at line 245 of file argagg.hpp.