koutil
Loading...
Searching...
No Matches
koutil::argparser::Arguments< Args > Class Template Reference

Base class for argument collections. More...

#include <arg.h>

Inheritance diagram for koutil::argparser::Arguments< Args >:
koutil::argparser::ArgumentsBase

Public Member Functions

constexpr Arguments (const Args &... args)
 
 ~Arguments () override=default
 
constexpr std::size_t size () const override
 Gets the number of arguments.
 
constexpr std::size_t count_short_args () const override
 Gets the number of short arguments.
 
constexpr std::size_t count_long_args () const override
 Gets the number of long arguments.
 
constexpr const Argfind_short (char name) const override
 Finds an argument by its short name.
 
constexpr const Argfind_long (std::string_view name) const override
 Finds an argument by its long name.
 
constexpr std::span< const Argargs () const override
 Gets a span of all arguments.
 
- Public Member Functions inherited from koutil::argparser::ArgumentsBase
virtual constexpr ~ArgumentsBase ()=default
 

Private Types

using args_t = std::array<Arg, sizeof...(Args)>
 
using args_ref_t = std::pair<std::size_t, std::array<std::size_t, sizeof...(Args)>>
 

Private Member Functions

constexpr void create_refs ()
 
template<typename Proj >
constexpr bool contains_duplicates (const args_ref_t &search, Proj member)
 Checks if there are duplicate arguments.
 

Private Attributes

args_t m_args
 
args_ref_t m_short_args
 
args_ref_t m_long_args
 

Detailed Description

template<is_arg... Args>
class koutil::argparser::Arguments< Args >

Base class for argument collections.

Member Typedef Documentation

◆ args_ref_t

template<is_arg... Args>
using koutil::argparser::Arguments< Args >::args_ref_t = std::pair<std::size_t, std::array<std::size_t, sizeof...(Args)>>
private

◆ args_t

template<is_arg... Args>
using koutil::argparser::Arguments< Args >::args_t = std::array<Arg, sizeof...(Args)>
private

Constructor & Destructor Documentation

◆ Arguments()

template<is_arg... Args>
koutil::argparser::Arguments< Args >::Arguments ( const Args &... args)
inlineconstexpr

◆ ~Arguments()

template<is_arg... Args>
koutil::argparser::Arguments< Args >::~Arguments ( )
overridedefault

Member Function Documentation

◆ args()

template<is_arg... Args>
std::span< const Arg > koutil::argparser::Arguments< Args >::args ( ) const
inlinenodiscardconstexproverridevirtual

Gets a span of all arguments.

Returns
A span containing all arguments.

Implements koutil::argparser::ArgumentsBase.

◆ contains_duplicates()

template<is_arg... Args>
template<typename Proj >
bool koutil::argparser::Arguments< Args >::contains_duplicates ( const args_ref_t & search,
Proj member )
inlineconstexprprivate

Checks if there are duplicate arguments.

Template Parameters
ProjThe type of the member projection.
Parameters
searchThe reference to search in.
memberThe member to project.
Returns
True if duplicates are found, false otherwise.

◆ count_long_args()

template<is_arg... Args>
std::size_t koutil::argparser::Arguments< Args >::count_long_args ( ) const
inlinenodiscardconstexproverridevirtual

Gets the number of long arguments.

Returns
The number of long arguments.

Implements koutil::argparser::ArgumentsBase.

◆ count_short_args()

template<is_arg... Args>
std::size_t koutil::argparser::Arguments< Args >::count_short_args ( ) const
inlinenodiscardconstexproverridevirtual

Gets the number of short arguments.

Returns
The number of short arguments.

Implements koutil::argparser::ArgumentsBase.

◆ create_refs()

template<is_arg... Args>
void koutil::argparser::Arguments< Args >::create_refs ( )
inlineconstexprprivate

◆ find_long()

template<is_arg... Args>
const Arg * koutil::argparser::Arguments< Args >::find_long ( std::string_view name) const
inlinenodiscardconstexproverridevirtual

Finds an argument by its long name.

Parameters
nameThe long name of the argument to find.
Returns
A pointer to the argument if found, nullptr otherwise.

Implements koutil::argparser::ArgumentsBase.

◆ find_short()

template<is_arg... Args>
const Arg * koutil::argparser::Arguments< Args >::find_short ( char name) const
inlinenodiscardconstexproverridevirtual

Finds an argument by its short name.

Parameters
nameThe short name of the argument to find.
Returns
A pointer to the argument if found, nullptr otherwise.

Implements koutil::argparser::ArgumentsBase.

◆ size()

template<is_arg... Args>
std::size_t koutil::argparser::Arguments< Args >::size ( ) const
inlinenodiscardconstexproverridevirtual

Gets the number of arguments.

Returns
The number of arguments.

Implements koutil::argparser::ArgumentsBase.

Member Data Documentation

◆ m_args

template<is_arg... Args>
args_t koutil::argparser::Arguments< Args >::m_args
private

◆ m_long_args

template<is_arg... Args>
args_ref_t koutil::argparser::Arguments< Args >::m_long_args
private

◆ m_short_args

template<is_arg... Args>
args_ref_t koutil::argparser::Arguments< Args >::m_short_args
private

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