cli11
Loading...
Searching...
No Matches
cli::option_base_t Class Referenceexport
module cli11

Settings shared by option_t and option_defaults_t. More...

Inheritance diagram for cli::option_base_t:
cli::option_defaults_t cli::option_t

Public Member Functions

template<typename self_t>
auto group (this self_t &self, const std::string &name) -> self_t *
 Sets the help group this option is listed under.
template<typename self_t>
auto required (this self_t &self, bool value=true) -> self_t *
 Marks the option as required.
template<typename self_t>
auto mandatory (this self_t &self, bool value=true) -> self_t *
 Marks the option as required.
template<typename self_t>
auto always_capture_default (this self_t &self, bool value=true) -> self_t *
 Captures the bound variable's value as the printed default.
auto get_group () const -> const std::string &
 Returns the help group this option is listed under.
auto get_required () const -> bool
 Reports whether the option must appear.
auto get_ignore_case () const -> bool
 Reports whether name matching ignores case.
auto get_ignore_underscore () const -> bool
 Reports whether name matching ignores underscores.
auto get_configurable () const -> bool
 Reports whether the option may be set from a configuration file.
auto get_disable_flag_override () const -> bool
 Reports whether flag overrides are rejected.
auto get_delimiter () const -> char
 Returns the character that splits a value into several.
auto get_always_capture_default () const -> bool
 Reports whether defaults are captured automatically.
auto get_multi_option_policy () const -> multi_option_policy_t
 Returns what happens to surplus values.
auto get_callback_priority () const -> callback_priority_t
 Returns when this option's callback runs.
template<typename self_t>
auto take_last (this self_t &self) -> self_t *
 Keeps only the last value given.
template<typename self_t>
auto take_first (this self_t &self) -> self_t *
 Keeps only the first value given.
template<typename self_t>
auto take_all (this self_t &self) -> self_t *
 Keeps every value given.
template<typename self_t>
auto join (this self_t &self) -> self_t *
 Joins every value given.
template<typename self_t>
auto join (this self_t &self, char delim) -> self_t *
 Joins every value given, using a specific delimiter.
template<typename self_t>
auto configurable (this self_t &self, bool value=true) -> self_t *
 Allows or forbids setting the option from a configuration file.
template<typename self_t>
auto delimiter (this self_t &self, char value='\0') -> self_t *
 Sets the character that splits a value into several.

Protected Member Functions

template<typename T>
auto copy_to (T *other) const -> void
 Copies every shared setting onto another option.

Protected Attributes

std::string group_ = std::string("OPTIONS")
 The help group this option is listed under.
bool required_ {false}
 Whether the option must appear.
bool ignore_case_ {false}
 Whether name matching ignores case.
bool ignore_underscore_ {false}
 Whether name matching ignores underscores.
bool configurable_ {true}
 Whether the option may be set from a configuration file.
bool disable_flag_override_ {false}
 Whether --no-flag style overrides are rejected.
char delimiter_ {'\0'}
 Character that splits a single value into several.
bool always_capture_default_ {false}
 Whether the bound value's default is captured automatically.
multi_option_policy_t multi_option_policy_ {multi_option_policy_t::reject}
 What to do with surplus values.
callback_priority_t callback_priority_ {callback_priority_t::normal}
 When this option's callback runs.

Detailed Description

Settings shared by option_t and option_defaults_t.

Every setter returns a pointer to the derived type so that chaining keeps working on the concrete class. That used to be done with CRTP; it now uses an explicit object parameter, so the class is no longer a template.

Member Function Documentation

◆ always_capture_default()

template<typename self_t>
auto cli::option_base_t::always_capture_default ( this self_t & self,
bool value = true ) -> self_t *
inline

Captures the bound variable's value as the printed default.

Parameters
selfThe concrete option, deduced.
valueWhether to capture automatically.
Returns
A pointer to self, for chaining.

◆ configurable()

template<typename self_t>
auto cli::option_base_t::configurable ( this self_t & self,
bool value = true ) -> self_t *
inline

Allows or forbids setting the option from a configuration file.

Parameters
selfThe concrete option, deduced.
valueWhether the option is configurable.
Returns
A pointer to self, for chaining.

◆ copy_to()

template<typename T>
auto cli::option_base_t::copy_to ( T * other) const -> void
inlineprotected

Copies every shared setting onto another option.

Template Parameters
TThe destination type.
Parameters
otherThe option to copy onto.

◆ delimiter()

template<typename self_t>
auto cli::option_base_t::delimiter ( this self_t & self,
char value = '\0' ) -> self_t *
inline

Sets the character that splits a value into several.

Parameters
selfThe concrete option, deduced.
valueThe delimiter, or '\0' for none.
Returns
A pointer to self, for chaining.

◆ get_always_capture_default()

auto cli::option_base_t::get_always_capture_default ( ) const -> bool
inlinenodiscard

Reports whether defaults are captured automatically.

Returns
true if defaults are captured.

◆ get_callback_priority()

auto cli::option_base_t::get_callback_priority ( ) const -> callback_priority_t
inlinenodiscard

Returns when this option's callback runs.

Returns
The callback priority.

◆ get_configurable()

auto cli::option_base_t::get_configurable ( ) const -> bool
inlinenodiscard

Reports whether the option may be set from a configuration file.

Returns
true if the option is configurable.

◆ get_delimiter()

auto cli::option_base_t::get_delimiter ( ) const -> char
inlinenodiscard

Returns the character that splits a value into several.

Returns
The delimiter, or '\0' if none is set.

◆ get_disable_flag_override()

auto cli::option_base_t::get_disable_flag_override ( ) const -> bool
inlinenodiscard

Reports whether flag overrides are rejected.

Returns
true if overrides are disabled.

◆ get_group()

auto cli::option_base_t::get_group ( ) const -> const std::string &
inlinenodiscard

Returns the help group this option is listed under.

Returns
The group name.

◆ get_ignore_case()

auto cli::option_base_t::get_ignore_case ( ) const -> bool
inlinenodiscard

Reports whether name matching ignores case.

Returns
true if case is ignored.

◆ get_ignore_underscore()

auto cli::option_base_t::get_ignore_underscore ( ) const -> bool
inlinenodiscard

Reports whether name matching ignores underscores.

Returns
true if underscores are ignored.

◆ get_multi_option_policy()

auto cli::option_base_t::get_multi_option_policy ( ) const -> multi_option_policy_t
inlinenodiscard

Returns what happens to surplus values.

Returns
The multi-option policy.

◆ get_required()

auto cli::option_base_t::get_required ( ) const -> bool
inlinenodiscard

Reports whether the option must appear.

Returns
true if the option is required.

◆ group()

template<typename self_t>
auto cli::option_base_t::group ( this self_t & self,
const std::string & name ) -> self_t *
inline

Sets the help group this option is listed under.

Parameters
selfThe concrete option, deduced.
nameThe group name.
Returns
A pointer to self, for chaining.
Exceptions
cli::incorrect_construction_tIf name contains a newline or null.

◆ join() [1/2]

template<typename self_t>
auto cli::option_base_t::join ( this self_t & self) -> self_t *
inline

Joins every value given.

Parameters
selfThe concrete option, deduced.
Returns
A pointer to self, for chaining.

◆ join() [2/2]

template<typename self_t>
auto cli::option_base_t::join ( this self_t & self,
char delim ) -> self_t *
inline

Joins every value given, using a specific delimiter.

Parameters
selfThe concrete option, deduced.
delimThe character placed between joined values.
Returns
A pointer to self, for chaining.

◆ mandatory()

template<typename self_t>
auto cli::option_base_t::mandatory ( this self_t & self,
bool value = true ) -> self_t *
inline

Marks the option as required.

Parameters
selfThe concrete option, deduced.
valueWhether the option must appear.
Returns
A pointer to self, for chaining.

◆ required()

template<typename self_t>
auto cli::option_base_t::required ( this self_t & self,
bool value = true ) -> self_t *
inline

Marks the option as required.

Parameters
selfThe concrete option, deduced.
valueWhether the option must appear.
Returns
A pointer to self, for chaining.

◆ take_all()

template<typename self_t>
auto cli::option_base_t::take_all ( this self_t & self) -> self_t *
inline

Keeps every value given.

Parameters
selfThe concrete option, deduced.
Returns
A pointer to self, for chaining.

◆ take_first()

template<typename self_t>
auto cli::option_base_t::take_first ( this self_t & self) -> self_t *
inline

Keeps only the first value given.

Parameters
selfThe concrete option, deduced.
Returns
A pointer to self, for chaining.

◆ take_last()

template<typename self_t>
auto cli::option_base_t::take_last ( this self_t & self) -> self_t *
inline

Keeps only the last value given.

Parameters
selfThe concrete option, deduced.
Returns
A pointer to self, for chaining.

The documentation for this class was generated from the following file:
  • /home/mccakit/desktop/repositories/cli11/src/option.cpp