Compute Library
 21.08
ToggleOption Class Reference

Implementation of an option that can be either true or false. More...

#include <ToggleOption.h>

Collaboration diagram for ToggleOption:
[legend]

Public Member Functions

 ToggleOption (std::string name, bool default_value)
 Construct the option with the given default value. More...
 
bool parse (std::string value) override
 Parses the given string. More...
 
std::string help () const override
 Help message for the option. More...
 
- Public Member Functions inherited from SimpleOption< bool >
 SimpleOption (std::string name, bool default_value)
 Construct the option with the given default value. More...
 
bool parse (std::string value) override
 Parses the given string. More...
 
bool parse (std::string value)
 Parses the given string. More...
 
std::string help () const override
 Help message for the option. More...
 
const bool & value () const
 Get the option value. More...
 
- Public Member Functions inherited from Option
 Option (std::string name)
 Constructor. More...
 
 Option (std::string name, bool is_required, bool is_set)
 Constructor. More...
 
virtual ~Option ()=default
 Default destructor. More...
 
std::string name () const
 Name of the option. More...
 
void set_required (bool is_required)
 Set whether the option is required. More...
 
void set_help (std::string help)
 Set the help message for the option. More...
 
bool is_required () const
 Is the option required? More...
 
bool is_set () const
 Has a value been assigned to the option? More...
 

Detailed Description

Implementation of an option that can be either true or false.

Definition at line 36 of file ToggleOption.h.

Constructor & Destructor Documentation

◆ ToggleOption()

ToggleOption ( std::string  name,
bool  default_value 
)
inline

Construct the option with the given default value.

Parameters
[in]nameName of the option.
[in]default_valueDefault value.

Definition at line 52 of file ToggleOption.h.

References ToggleOption::help(), Option::name(), ToggleOption::parse(), and SimpleOption< bool >::value().

53  : SimpleOption<bool>
54 {
55  std::move(name), default_value
56 }
std::string name() const
Name of the option.
Definition: Option.h:115

Member Function Documentation

◆ help()

std::string help ( ) const
overridevirtual

Help message for the option.

Returns
String representing the help message for the specific subclass.

Implements Option.

Referenced by ToggleOption::ToggleOption().

◆ parse()

bool parse ( std::string  value)
overridevirtual

Parses the given string.

Parameters
[in]valueString representation as passed on the command line.
Returns
True if the value could be parsed by the specific subclass.

Implements Option.

Referenced by ToggleOption::ToggleOption().


The documentation for this class was generated from the following file: