![]() |
PIDUINO
|
Value option with optional default value. More...
#include <popl.h>
Public Member Functions | |
Value (const std::string &short_name, const std::string &long_name, const std::string &description) | |
Value implementation /////////////////////////////////. | |
Value (const std::string &short_name, const std::string &long_name, const std::string &description, const T &default_val, T *assign_to=nullptr) | |
size_t | count () const override |
bool | is_set () const override |
void | assign_to (T *var) |
void | set_value (const T &value) |
T | value (size_t idx=0) const |
void | set_default (const T &value) |
bool | has_default () const |
T | get_default () const |
bool | get_default (std::ostream &out) const override |
Argument | argument_type () const override |
char | short_name () const |
std::string | long_name () const |
std::string | name (OptionName what_name, bool with_hypen=false) const |
std::string | description () const |
void | set_attribute (const Attribute &attribute) |
Attribute | attribute () const |
Protected Member Functions | |
void | parse (OptionName what_name, const char *value) override |
virtual void | update_reference () |
virtual void | add_value (const T &value) |
void | clear () override |
Clear the internal data structure. | |
void | parse (OptionName what_name, const char *value) |
Protected Attributes | |
std::unique_ptr< T > | default_ |
T * | assign_to_ |
std::vector< T > | values_ |
std::string | short_name_ |
std::string | long_name_ |
std::string | description_ |
Attribute | attribute_ |
Value option with optional default value.
Value option with optional default value If set, it requires an argument
|
inline |
|
inline |
short_name | the option's short name. Must be empty or one character. |
long_name | the option's long name. Can be empty. |
description | the Option's description that will be shown in the help message |
default_val | the Option's default value |
assign_to | pointer to a variable to assign the parsed command line value to |
Definition at line 559 of file popl.h.
References Piduino::Value< T >::assign_to(), Piduino::Value< T >::assign_to_, and Piduino::Value< T >::set_default().
|
inlineprotectedvirtual |
|
inlineoverridevirtual |
Get the Option's argument type
Implements Piduino::Option.
Definition at line 657 of file popl.h.
References Piduino::required.
|
inline |
Assign the last parsed command line value to "var"
var | pointer to the variable where is value is written to |
Definition at line 579 of file popl.h.
Referenced by Piduino::Value< T >::Value().
|
inlineinherited |
Get the Option's attribute
Definition at line 542 of file popl.h.
References Piduino::Option::attribute_.
Referenced by Piduino::Option::set_attribute().
|
inlineoverrideprotectedvirtual |
Clear the internal data structure.
Implements Piduino::Option.
|
inlineoverridevirtual |
Check how often the Option is set on command line
Implements Piduino::Option.
|
inlineinherited |
Get the Option's description
Definition at line 532 of file popl.h.
References Piduino::Option::description_.
|
inline |
|
inlineoverridevirtual |
Get the Option's default value
out | stream to write the default value to |
Implements Piduino::Option.
|
inline |
|
inlineoverridevirtual |
|
inlineinherited |
Get the Option's long name
Definition at line 516 of file popl.h.
References Piduino::Option::long_name_.
Referenced by Piduino::Option::Option().
|
inlineinherited |
Get the Option's long or short name
what_name | the option's name to return |
what_hyphen | preced the returned name with (double-)hypen |
Definition at line 521 of file popl.h.
References Piduino::long_name, Piduino::Option::long_name_, Piduino::short_name, and Piduino::Option::short_name_.
|
inlineprotectedvirtual |
Parse the command line option and fill the internal data structure
what_name | short or long option name |
value | the value as given on command line |
Implements Piduino::Option.
Definition at line 663 of file popl.h.
References Piduino::invalid_option::missing_argument.
|
inlineoverrideprotectedvirtual |
Parse the command line option and fill the internal data structure
what_name | short or long option name |
value | the value as given on command line |
Implements Piduino::Option.
Definition at line 673 of file popl.h.
References Piduino::invalid_option::invalid_argument, Piduino::invalid_option::missing_argument, and Piduino::invalid_option::too_many_arguments.
Referenced by Piduino::Implicit< T >::parse().
|
inlineinherited |
Set the Option's attribute
attribute |
Definition at line 537 of file popl.h.
References Piduino::Option::attribute(), and Piduino::Option::attribute_.
|
inline |
Set the Option's default value
value | the default value if not specified on command line |
Definition at line 624 of file popl.h.
Referenced by Piduino::Value< T >::Value().
|
inline |
|
inlineinherited |
Get the Option's short name
Definition at line 508 of file popl.h.
References Piduino::Option::short_name_.
Referenced by Piduino::Option::Option().
|
inlineprotectedvirtual |
|
inline |
Get the Option's value. Will throw if option at index idx is not available
idx | the zero based index of the value (if set multiple times) |
Definition at line 593 of file popl.h.
References Piduino::long_name, and Piduino::short_name.
|
protected |
Definition at line 236 of file popl.h.
Referenced by Piduino::Value< T >::Value().
|
protectedinherited |
Definition at line 169 of file popl.h.
Referenced by Piduino::Option::attribute(), and Piduino::Option::set_attribute().
|
protected |
|
protectedinherited |
Definition at line 168 of file popl.h.
Referenced by Piduino::Option::description().
|
protectedinherited |
Definition at line 167 of file popl.h.
Referenced by Piduino::Option::long_name(), and Piduino::Option::name().
|
protectedinherited |
Definition at line 166 of file popl.h.
Referenced by Piduino::Option::name(), and Piduino::Option::short_name().
|
protected |