Compute Library
 23.11
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...
 
 SimpleOption (std::string name, T default_value)
 Construct the option with the given default value. 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...
 
 Option (std::string name)
 Constructor. More...
 
 Option (std::string name, bool is_required, bool is_set)
 Constructor. 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 35 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 51 of file ToggleOption.h.

52  : SimpleOption<bool>{std::move(name), default_value}
53 {
54 }

References Option::name().

Member Function Documentation

◆ help()

std::string help ( ) const
inlineoverridevirtual

Help message for the option.

Returns
String representing the help message for the specific subclass.

Implements Option.

Definition at line 72 of file ToggleOption.h.

73 {
74  return "--" + name() + ", --no-" + name() + " - " + _help;
75 }

References Option::name().

◆ parse()

bool parse ( std::string  value)
inlineoverridevirtual

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.

Definition at line 56 of file ToggleOption.h.

57 {
58  if (value == "true")
59  {
60  _value = true;
61  _is_set = true;
62  }
63  else if (value == "false")
64  {
65  _value = false;
66  _is_set = true;
67  }
68 
69  return _is_set;
70 }

References SimpleOption< bool >::value().

◆ SimpleOption()

SimpleOption
inline

Construct the option with the given default value.

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

Definition at line 75 of file SimpleOption.h.

76  : Option{std::move(name), false, true}, _value{std::move(default_value)}
77 {
78 }

The documentation for this class was generated from the following file:
arm_compute::utils::Option::name
std::string name() const
Name of the option.
Definition: Option.h:114
arm_compute::utils::SimpleOption< bool >::Option
Option(std::string name)
Constructor.
Definition: Option.h:105
arm_compute::utils::SimpleOption< bool >::value
const bool & value() const
Get the option value.
Definition: SimpleOption.h:111