PIDUINO
Loading...
Searching...
No Matches
Piduino::Switch

Value option without value. More...

#include <popl.h>

Inheritance diagram for Piduino::Switch:
Collaboration diagram for Piduino::Switch:

Public Member Functions

 Switch (const std::string &short_name, const std::string &long_name, const std::string &description, bool *assign_to=nullptr)
 Switch implementation /////////////////////////////////.
 
void set_default (const bool &value)=delete
 
Argument argument_type () const override
 
size_t count () const override
 
bool is_set () const override
 
void assign_to (bool *var)
 
void set_value (const bool &value)
 
bool value (size_t idx=0) const
 
bool has_default () const
 
bool get_default () const
 
bool get_default (std::ostream &out) 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 bool &value)
 
void clear () override
 Clear the internal data structure.
 

Protected Attributes

std::unique_ptr< bool > default_
 
bool * assign_to_
 
std::vector< bool > values_
 
std::string short_name_
 
std::string long_name_
 
std::string description_
 
Attribute attribute_
 

Detailed Description

Value option without value.

Value option without value Does not require an argument Can be either set or not set

Definition at line 270 of file popl.h.

Constructor & Destructor Documentation

◆ Switch()

Piduino::Switch::Switch ( const std::string &  short_name,
const std::string &  long_name,
const std::string &  description,
bool *  assign_to = nullptr 
)
inline

Switch implementation /////////////////////////////////.

Definition at line 763 of file popl.h.

Member Function Documentation

◆ add_value()

void Piduino::Value< bool >::add_value ( const bool &  value)
inlineprotectedvirtualinherited

Definition at line 233 of file popl.h.

◆ argument_type()

Argument Piduino::Switch::argument_type ( ) const
inlineoverridevirtual

Get the Option's argument type

Returns
argument type (no, required, optional)

Implements Piduino::Option.

Definition at line 773 of file popl.h.

References Piduino::no.

◆ assign_to()

void Piduino::Value< bool >::assign_to ( bool *  var)
inlineinherited

Assign the last parsed command line value to "var"

Parameters
varpointer to the variable where is value is written to

Definition at line 202 of file popl.h.

◆ attribute()

Attribute Piduino::Option::attribute ( ) const
inlineinherited

Get the Option's attribute

Returns
the Options's attribute

Definition at line 542 of file popl.h.

References Piduino::Option::attribute_.

Referenced by Piduino::Option::set_attribute().

◆ clear()

void Piduino::Value< bool >::clear ( )
inlineoverrideprotectedvirtualinherited

Clear the internal data structure.

Implements Piduino::Option.

Definition at line 234 of file popl.h.

◆ count()

size_t Piduino::Value< bool >::count ( ) const
inlineoverridevirtualinherited

Check how often the Option is set on command line

Returns
the Option's count on command line

Implements Piduino::Option.

Definition at line 197 of file popl.h.

◆ description()

std::string Piduino::Option::description ( ) const
inlineinherited

Get the Option's description

Returns
the description

Definition at line 532 of file popl.h.

References Piduino::Option::description_.

◆ get_default() [1/2]

bool Piduino::Value< bool >::get_default ( ) const
inlineinherited

Get the Option's default value. Will throw if no default is set.

Returns
the Option's default value

Definition at line 223 of file popl.h.

◆ get_default() [2/2]

bool Piduino::Value< bool >::get_default ( std::ostream &  out) const
inlineoverridevirtualinherited

Get the Option's default value

Parameters
outstream to write the default value to
Returns
true if a default value is available, false if not

Implements Piduino::Option.

Definition at line 224 of file popl.h.

◆ has_default()

bool Piduino::Value< bool >::has_default ( ) const
inlineinherited

Check if the Option has a default value

Returns
true if the Option has a default value

Definition at line 219 of file popl.h.

◆ is_set()

bool Piduino::Value< bool >::is_set ( ) const
inlineoverridevirtualinherited

Check if the Option is set

Returns
true if set at least once

Implements Piduino::Option.

Definition at line 198 of file popl.h.

◆ long_name()

std::string Piduino::Option::long_name ( ) const
inlineinherited

Get the Option's long name

Returns
the long name of the Option. Empty string if no long name is defined

Definition at line 516 of file popl.h.

References Piduino::Option::long_name_.

Referenced by Piduino::Option::Option().

◆ name()

std::string Piduino::Option::name ( OptionName  what_name,
bool  with_hypen = false 
) const
inlineinherited

Get the Option's long or short name

Parameters
what_namethe option's name to return
what_hyphenpreced the returned name with (double-)hypen
Returns
the requested name of the Option. Empty string if not defined.

Definition at line 521 of file popl.h.

References Piduino::long_name, Piduino::Option::long_name_, Piduino::short_name, and Piduino::Option::short_name_.

◆ parse()

void Piduino::Switch::parse ( OptionName  what_name,
const char *  value 
)
inlineoverrideprotectedvirtual

Parse the command line option and fill the internal data structure

Parameters
what_nameshort or long option name
valuethe value as given on command line

Implements Piduino::Option.

Definition at line 768 of file popl.h.

References Piduino::Value< bool >::add_value().

Here is the call graph for this function:

◆ set_attribute()

void Piduino::Option::set_attribute ( const Attribute attribute)
inlineinherited

Set the Option's attribute

Parameters
attribute

Definition at line 537 of file popl.h.

References Piduino::Option::attribute(), and Piduino::Option::attribute_.

Here is the call graph for this function:

◆ set_default()

void Piduino::Switch::set_default ( const bool &  value)
delete

◆ set_value()

void Piduino::Value< bool >::set_value ( const bool &  value)
inlineinherited

Manually set the Option's value. Deletes current value(s)

Parameters
valuethe new value of the option

Definition at line 206 of file popl.h.

◆ short_name()

char Piduino::Option::short_name ( ) const
inlineinherited

Get the Option's short name

Returns
character of the options's short name or 0 if no short name is defined

Definition at line 508 of file popl.h.

References Piduino::Option::short_name_.

Referenced by Piduino::Option::Option().

◆ update_reference()

void Piduino::Value< bool >::update_reference ( )
inlineprotectedvirtualinherited

Definition at line 232 of file popl.h.

◆ value()

bool Piduino::Value< bool >::value ( size_t  idx = 0) const
inlineinherited

Get the Option's value. Will throw if option at index idx is not available

Parameters
idxthe zero based index of the value (if set multiple times)
Returns
the Option's value at index "idx"

Definition at line 211 of file popl.h.

Member Data Documentation

◆ assign_to_

bool * Piduino::Value< bool >::assign_to_
protectedinherited

Definition at line 236 of file popl.h.

◆ attribute_

Attribute Piduino::Option::attribute_
protectedinherited

Definition at line 169 of file popl.h.

Referenced by Piduino::Option::attribute(), and Piduino::Option::set_attribute().

◆ default_

std::unique_ptr<bool > Piduino::Value< bool >::default_
protectedinherited

Definition at line 230 of file popl.h.

◆ description_

std::string Piduino::Option::description_
protectedinherited

Definition at line 168 of file popl.h.

Referenced by Piduino::Option::description().

◆ long_name_

std::string Piduino::Option::long_name_
protectedinherited

Definition at line 167 of file popl.h.

Referenced by Piduino::Option::long_name(), and Piduino::Option::name().

◆ short_name_

std::string Piduino::Option::short_name_
protectedinherited

Definition at line 166 of file popl.h.

Referenced by Piduino::Option::name(), and Piduino::Option::short_name().

◆ values_

std::vector<bool > Piduino::Value< bool >::values_
protectedinherited

Definition at line 237 of file popl.h.