kaycxx-cli
C++ CLI library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
kaycxx::cli::parameters< T > Class Template Reference

Typed positional parameter list definition. More...

#include <kaycxx/cli/parameters.hpp>

Inheritance diagram for kaycxx::cli::parameters< T >:
Inheritance graph
[legend]
Collaboration diagram for kaycxx::cli::parameters< T >:
Collaboration graph
[legend]

Public Member Functions

 parameters (std::string_view name, std::optional< std::string_view > description=std::nullopt)
 Creates a positional parameter list definition.
 
void min (std::size_t count) noexcept
 Sets the minimum number of values consumed by this parameter list.
 
void max (std::size_t count) noexcept
 Sets the maximum number of values consumed by this parameter list.
 
void default_values (std::vector< T > values)
 Sets default values for this parameter list.
 
std::string usage () const override
 Returns generated help usage for this parameter list.
 
std::size_t min_count () const noexcept override
 Returns the minimum number of values consumed by this parameter list.
 
std::size_t max_count () const noexcept override
 Returns the maximum number of values consumed by this parameter list.
 
std::any parse_values (std::span< std::string_view const > values) const override
 Parses this positional parameter list.
 
- Public Member Functions inherited from kaycxx::cli::parameter_base
 parameter_base (std::string_view name, std::optional< std::string_view > description=std::nullopt)
 Creates a positional parameter definition.
 
virtual ~parameter_base ()=default
 Destroys the parameter definition.
 
std::string constname () const noexcept
 Returns the parameter name.
 
std::optional< std::string > constdescription () const noexcept
 Returns the parameter description.
 

Detailed Description

template<parseable_value T>
class kaycxx::cli::parameters< T >

Typed positional parameter list definition.

A parameter list can consume zero or more positional values. Minimum and maximum counts define how many values may be consumed before following positional parameters are considered.

Template Parameters
TParsed parameter value type.

Constructor & Destructor Documentation

◆ parameters()

template<parseable_value T>
kaycxx::cli::parameters< T >::parameters ( std::string_view  name,
std::optional< std::string_view >  description = std::nullopt 
)
inlineexplicit

Creates a positional parameter list definition.

Parameters
namePlaceholder name used by generated help output and parse errors.
descriptionOptional human-readable parameter description used by generated help output.

Member Function Documentation

◆ default_values()

template<parseable_value T>
void kaycxx::cli::parameters< T >::default_values ( std::vector< T values)
inline

Sets default values for this parameter list.

Parameters
valuesDefault values used when the parameter list is not present in parsed arguments.

◆ max()

template<parseable_value T>
void kaycxx::cli::parameters< T >::max ( std::size_t  count)
inlinenoexcept

Sets the maximum number of values consumed by this parameter list.

Parameters
countMaximum value count.

◆ max_count()

template<parseable_value T>
std::size_t kaycxx::cli::parameters< T >::max_count ( ) const
inlineoverridevirtualnoexcept

Returns the maximum number of values consumed by this parameter list.

Returns
Configured maximum value count.

Implements kaycxx::cli::parameter_base.

◆ min()

template<parseable_value T>
void kaycxx::cli::parameters< T >::min ( std::size_t  count)
inlinenoexcept

Sets the minimum number of values consumed by this parameter list.

Parameters
countMinimum value count.

◆ min_count()

template<parseable_value T>
std::size_t kaycxx::cli::parameters< T >::min_count ( ) const
inlineoverridevirtualnoexcept

Returns the minimum number of values consumed by this parameter list.

Returns
Zero when default values are configured, otherwise the configured minimum count.

Implements kaycxx::cli::parameter_base.

◆ parse_values()

template<parseable_value T>
std::any kaycxx::cli::parameters< T >::parse_values ( std::span< std::string_view const values) const
inlineoverridevirtual

Parses this positional parameter list.

Parameters
valuesValue texts to parse.
Returns
Parsed parameter values stored in type-erased form.
Exceptions
parse_errorWhen one of the values is syntactically invalid or the parsed or default value count is outside the configured range.

Implements kaycxx::cli::parameter_base.

◆ usage()

template<parseable_value T>
std::string kaycxx::cli::parameters< T >::usage ( ) const
inlineoverridevirtual

Returns generated help usage for this parameter list.

Returns
Usage text.

Implements kaycxx::cli::parameter_base.


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