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

Abstract Base class for Options. More...

#include <popl.h>

Inheritance diagram for Piduino::Option:
Collaboration diagram for Piduino::Option:

Public Member Functions

 Option (const std::string &short_name, const std::string &long_name, std::string description)
 Option implementation /////////////////////////////////.
 
virtual ~Option ()=default
 Destructor.
 
 Option (const Option &)=default
 default copy constructor
 
 Option (Option &&)=default
 default move constructor
 
Optionoperator= (const Option &)=default
 default assignement operator
 
Optionoperator= (Option &&)=default
 default move assignement operator
 
char short_name () const
 
std::string long_name () const
 
std::string name (OptionName what_name, bool with_hypen=false) const
 
std::string description () const
 
virtual bool get_default (std::ostream &out) const =0
 
void set_attribute (const Attribute &attribute)
 
Attribute attribute () const
 
virtual Argument argument_type () const =0
 
virtual size_t count () const =0
 
virtual bool is_set () const =0
 

Protected Member Functions

virtual void parse (OptionName what_name, const char *value)=0
 
virtual void clear ()=0
 Clear the internal data structure.
 

Protected Attributes

std::string short_name_
 
std::string long_name_
 
std::string description_
 
Attribute attribute_
 

Detailed Description

Abstract Base class for Options.

Base class for Options holds just configuration data, no runtime data. Option is not bound to a special type "T"

Definition at line 90 of file popl.h.

Constructor & Destructor Documentation

◆ Option() [1/3]

Piduino::Option::Option ( const std::string &  short_name,
const std::string &  long_name,
std::string  description 
)
inline

Option implementation /////////////////////////////////.

Construct an Option

Parameters
short_namethe options's short name. Must be empty or one character.
long_namethe option's long name. Can be empty.
descriptionthe Option's description that will be shown in the help message

Definition at line 493 of file popl.h.

References long_name(), and short_name().

Here is the call graph for this function:

◆ ~Option()

virtual Piduino::Option::~Option ( )
virtualdefault

Destructor.

◆ Option() [2/3]

Piduino::Option::Option ( const Option )
default

default copy constructor

◆ Option() [3/3]

Piduino::Option::Option ( Option &&  )
default

default move constructor

Member Function Documentation

◆ argument_type()

virtual Argument Piduino::Option::argument_type ( ) const
pure virtual

Get the Option's argument type

Returns
argument type (no, required, optional)

Implemented in Piduino::Value< T >, Piduino::Value< bool >, Piduino::Implicit< T >, and Piduino::Switch.

◆ attribute()

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

Get the Option's attribute

Returns
the Options's attribute

Definition at line 542 of file popl.h.

References attribute_.

Referenced by set_attribute().

◆ clear()

virtual void Piduino::Option::clear ( )
protectedpure virtual

Clear the internal data structure.

Implemented in Piduino::Value< T >, and Piduino::Value< bool >.

◆ count()

virtual size_t Piduino::Option::count ( ) const
pure virtual

Check how often the Option is set on command line

Returns
the Option's count on command line

Implemented in Piduino::Value< T >, and Piduino::Value< bool >.

◆ description()

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

Get the Option's description

Returns
the description

Definition at line 532 of file popl.h.

References description_.

◆ get_default()

virtual bool Piduino::Option::get_default ( std::ostream &  out) const
pure virtual

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

Implemented in Piduino::Value< T >, and Piduino::Value< bool >.

◆ is_set()

virtual bool Piduino::Option::is_set ( ) const
pure virtual

Check if the Option is set

Returns
true if set at least once

Implemented in Piduino::Value< T >, and Piduino::Value< bool >.

◆ long_name()

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

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 long_name_.

Referenced by Option().

◆ name()

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

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, long_name_, Piduino::short_name, and short_name_.

◆ operator=() [1/2]

Option & Piduino::Option::operator= ( const Option )
default

default assignement operator

◆ operator=() [2/2]

Option & Piduino::Option::operator= ( Option &&  )
default

default move assignement operator

◆ parse()

virtual void Piduino::Option::parse ( OptionName  what_name,
const char *  value 
)
protectedpure virtual

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

Implemented in Piduino::Value< T >, Piduino::Value< bool >, Piduino::Value< T >, Piduino::Value< bool >, Piduino::Implicit< T >, and Piduino::Switch.

◆ set_attribute()

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

Set the Option's attribute

Parameters
attribute

Definition at line 537 of file popl.h.

References attribute(), and attribute_.

Here is the call graph for this function:

◆ short_name()

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

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 short_name_.

Referenced by Option().

Member Data Documentation

◆ attribute_

Attribute Piduino::Option::attribute_
protected

Definition at line 169 of file popl.h.

Referenced by attribute(), and set_attribute().

◆ description_

std::string Piduino::Option::description_
protected

Definition at line 168 of file popl.h.

Referenced by description().

◆ long_name_

std::string Piduino::Option::long_name_
protected

Definition at line 167 of file popl.h.

Referenced by long_name(), and name().

◆ short_name_

std::string Piduino::Option::short_name_
protected

Definition at line 166 of file popl.h.

Referenced by name(), and short_name().