A command-line argument.
More...
#include <arguments.hpp>
|
| | Arg (const config &c, const std::function< std::string(const std::string_view &)> &handler=[](const std::string_view &value){return std::string(value);}, const std::function< std::string(const std::string_view &)> &m_handler=[](const std::string_view &value){return std::string(value);}) |
| | Construct an argument.
|
| |
| bool | digest (const shared::vector &args, uint_fast8_t &x) |
| | Digest arguments.
|
| |
| void | update () |
| | Update configurations.
|
| |
| std::string | get_help () const |
| | Get the help text for the argument.
|
| |
| auto && | get (this auto &&self) |
| | Get a mutable reference to the stored value.
|
| |
| void | emplace (const std::string &val) |
| | Emplace a value.
|
| |
| auto && | mod (this auto &&self) |
| | Get a mutable reference to the stored modifier.
|
| |
| const bool & | is_list () const |
| | Return whether the argument is a list.
|
| |
| const bool & | is_flagset () const |
| | Return whether the argument is a flagset.
|
| |
| uint_fast8_t | level () const |
| | Return the current level of the argument.
|
| |
| auto && | get_list (this auto &&self) |
| | Return a mutable reference to each unique value passed to the argument.
|
| |
| auto && | get_valid (this auto &&self) |
| | Return a set of all valid values.
|
| |
| std::vector< std::pair< std::string, std::string > > | get_modlist () const |
| | Return all values paired with their modifiers.
|
| |
|
const bool & | updates_sof () const |
| |
| const uint_fast8_t & | position () const |
| | Return the position of the argument.
|
| |
| | operator bool () const |
| | Return whether the argument was set.
|
| |
| const bool | operator< (const std::string_view &val) const |
| | Check if the current value is underneath the provided.
|
| |
| const bool | operator>= (const std::string_view &val) const |
| | Check if the current value meets the provided.
|
| |
◆ Arg()
| arg::Arg::Arg |
( |
const config & | c, |
|
|
const std::function< std::string(const std::string_view &)> & | handler = [](const std::string_view& value){return std::string(value);}, |
|
|
const std::function< std::string(const std::string_view &)> & | m_handler = [](const std::string_view& value){return std::string(value);} ) |
|
inline |
Construct an argument.
- Parameters
-
| c | THe configuration structure. |
| handler | The regular lambda for parsing arguments. |
| m_handler | The lambda for parsing modifier arguments. |
◆ digest()
| bool arg::Arg::digest |
( |
const shared::vector & | args, |
|
|
uint_fast8_t & | x ) |
|
inline |
Digest arguments.
- Parameters
-
| args | The list of command line arguments. |
| x | The current position within the list. |
- Returns
- : Whether the current argument was consumed.
◆ emplace()
| void arg::Arg::emplace |
( |
const std::string & | val | ) |
|
|
inline |
Emplace a value.
- Parameters
-
- Exceptions
-
| std::runtime_error | if the valid is invalid. |
- Note
- For single value arguments, this overwrites the stored value. For lists, it emplaces to the back of the list if its valid.
- Warning
- This function uses the same parsing logic as initial argument parsing, which means invalid values will throw exceptions.
◆ get()
| auto && arg::Arg::get |
( |
this auto && | self | ) |
|
|
inline |
Get a mutable reference to the stored value.
- Returns
- The reference.
- Exceptions
-
| std::runtime_error | if the argument is a list, use get_list() instead. |
◆ get_help()
| std::string arg::Arg::get_help |
( |
| ) |
const |
|
inline |
Get the help text for the argument.
- Returns
- The string.
◆ get_list()
| auto && arg::Arg::get_list |
( |
this auto && | self | ) |
|
|
inline |
Return a mutable reference to each unique value passed to the argument.
- Returns
- The set.
- Exceptions
-
| std::runtime_error | if the argument is not a list. |
◆ get_modlist()
| std::vector< std::pair< std::string, std::string > > arg::Arg::get_modlist |
( |
| ) |
const |
|
inline |
Return all values paired with their modifiers.
- Returns
- A vector of pairs.
- Exceptions
-
| std::runtime_error | if the argument is not a list, or doesn't allow modifiers. |
◆ get_valid()
| auto && arg::Arg::get_valid |
( |
this auto && | self | ) |
|
|
inline |
Return a set of all valid values.
- Returns
- The set.
◆ is_flagset()
| const bool & arg::Arg::is_flagset |
( |
| ) |
const |
|
inline |
Return whether the argument is a flagset.
- Returns
- Whether the argument is a true/false with a list of flags
◆ is_list()
| const bool & arg::Arg::is_list |
( |
| ) |
const |
|
inline |
Return whether the argument is a list.
- Returns
- Whether the argument accepts multiple values.
◆ level()
| uint_fast8_t arg::Arg::level |
( |
| ) |
const |
|
inline |
Return the current level of the argument.
- Returns
- The current level.
◆ mod()
| auto && arg::Arg::mod |
( |
this auto && | self | ) |
|
|
inline |
Get a mutable reference to the stored modifier.
- Returns
- The modifier.
- Note
- This function returns an empty string if a modifier does not exist or is allowed.
◆ operator bool()
| arg::Arg::operator bool |
( |
| ) |
const |
|
inline |
Return whether the argument was set.
- Returns
- Whether the value is greater than the default (IE unset).
◆ operator<()
| const bool arg::Arg::operator< |
( |
const std::string_view & | val | ) |
const |
|
inline |
Check if the current value is underneath the provided.
- Parameters
-
- Returns
- Whether the current value is less than the provided.
◆ operator>=()
| const bool arg::Arg::operator>= |
( |
const std::string_view & | val | ) |
const |
|
inline |
Check if the current value meets the provided.
- Parameters
-
- Returns
- Whether the current value meets the provided.
◆ position()
| const uint_fast8_t & arg::Arg::position |
( |
| ) |
const |
|
inline |
Return the position of the argument.
- Returns
- The mandatory level.
◆ update()
| void arg::Arg::update |
( |
| ) |
|
|
inline |
Update configurations.
- Note
- This function is used for arguments that depend on the value of other arguments.
The documentation for this class was generated from the following file: