argagg
|
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. | |
option_result & | operator[] (std::size_t index) |
Gets a single option parse result by index. | |
const option_result & | operator[] (std::size_t index) const |
Gets a single option result by index. | |
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. | |
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. | |
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. | |
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 | |
std::vector< option_result > | all |
All option parse results for this option. | |
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 332 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 809 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 819 of file argagg.hpp.
|
inline |
Gets the number of times the option shows up.
Definition at line 788 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 829 of file argagg.hpp.
|
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 843 of file argagg.hpp.
|
inline |
Gets a single option parse result by index.
Definition at line 795 of file argagg.hpp.
|
inline |
Gets a single option result by index.
Definition at line 802 of file argagg.hpp.
std::vector<option_result> argagg::option_results::all |
All option parse results for this option.
Definition at line 338 of file argagg.hpp.