koutil
Loading...
Searching...
No Matches
koutil::args::argument_t< Result > Class Template Reference

Represents a positional command-line argument. More...

#include <argument.h>

Public Types

using result_t = Result
 
using handle_t = std::function<void(std::string_view, result_t&)>
 Type alias for argument handler function.
 

Public Member Functions

 argument_t (std::string_view name, std::string_view description)
 Constructs an argument with a name and description.
 
template<void_handle< std::string_view, result_t & > Handle>
 argument_t (std::string_view name, std::string_view description, Handle &&handle)
 Constructs an argument with a name, description, and handler.
 
std::string_view name () const
 Gets the argument name.
 
std::string_view description () const
 Gets the argument description.
 
void process (std::string_view value, result_t &result) const
 Processes the argument value using the assigned handler.
 

Private Attributes

std::string_view m_name
 
std::string_view m_description
 
handle_t m_handle
 

Detailed Description

template<extends_result Result = result_base_t>
class koutil::args::argument_t< Result >

Represents a positional command-line argument.

Each argument has a name, description, and an optional handler function. The order in which arguments are added defines the order in which they are expected on the command line and displayed in the help text.

Member Typedef Documentation

◆ handle_t

template<extends_result Result = result_base_t>
using koutil::args::argument_t< Result >::handle_t = std::function<void(std::string_view, result_t&)>

Type alias for argument handler function.

◆ result_t

template<extends_result Result = result_base_t>
using koutil::args::argument_t< Result >::result_t = Result

Constructor & Destructor Documentation

◆ argument_t() [1/2]

template<extends_result Result = result_base_t>
koutil::args::argument_t< Result >::argument_t ( std::string_view name,
std::string_view description )
inlineexplicit

Constructs an argument with a name and description.

Parameters
nameArgument name.
descriptionArgument description.

◆ argument_t() [2/2]

template<extends_result Result = result_base_t>
template<void_handle< std::string_view, result_t & > Handle>
koutil::args::argument_t< Result >::argument_t ( std::string_view name,
std::string_view description,
Handle && handle )
inlineexplicit

Constructs an argument with a name, description, and handler.

Template Parameters
HandleCallable type compatible with void(std::string_view, result_t&).
Parameters
nameArgument name.
descriptionArgument description.
handleFunction to process the argument value.

Member Function Documentation

◆ description()

template<extends_result Result = result_base_t>
std::string_view koutil::args::argument_t< Result >::description ( ) const
inlinenodiscard

Gets the argument description.

Returns
Argument description.

◆ name()

template<extends_result Result = result_base_t>
std::string_view koutil::args::argument_t< Result >::name ( ) const
inlinenodiscard

Gets the argument name.

Returns
Argument name.

◆ process()

template<extends_result Result>
void koutil::args::argument_t< Result >::process ( std::string_view value,
result_t & result ) const

Processes the argument value using the assigned handler.

Parameters
valueArgument value.
resultResult object to update.

Member Data Documentation

◆ m_description

template<extends_result Result = result_base_t>
std::string_view koutil::args::argument_t< Result >::m_description
private

◆ m_handle

template<extends_result Result = result_base_t>
handle_t koutil::args::argument_t< Result >::m_handle
private

◆ m_name

template<extends_result Result = result_base_t>
std::string_view koutil::args::argument_t< Result >::m_name
private

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