koutil
Loading...
Searching...
No Matches
koutil::argparser::Commands< Cmd > Class Template Reference

Collection of subcommands. More...

#include <subcommand.h>

Inheritance diagram for koutil::argparser::Commands< Cmd >:
koutil::argparser::CommandsBase

Public Member Functions

constexpr Commands (const Cmd &... cmd)
 
constexpr std::size_t size () const override
 Gets the number of subcommands.
 
constexpr const SubcommandBasefind (std::string_view name) const override
 Finds a subcommand by name.
 
- Public Member Functions inherited from koutil::argparser::CommandsBase
virtual constexpr ~CommandsBase ()=default
 

Private Types

using storage_t = std::conditional_t<count != 1, std::tuple<Cmd...>, type::types_get_t<type::types<std::decay_t<Cmd>...>, 0>>
 

Private Member Functions

constexpr bool contains_duplicate () const
 Checks for duplicate subcommand names.
 
template<std::size_t I, std::size_t J>
requires (I < count && J < count)
constexpr bool contains_duplicate_impl () const
 Checks for duplicate subcommand names recursively.*.
 
template<std::size_t I, std::size_t J>
requires (I >= count || J >= count)
constexpr bool contains_duplicate_impl () const
 
template<std::size_t I>
constexpr const SubcommandBasefind_impl (std::string_view name) const
 Finds a subcommand by name recursively.
 

Private Attributes

storage_t m_cmds
 

Static Private Attributes

static constexpr std::size_t count = sizeof...(Cmd)
 

Detailed Description

template<is_subcommand... Cmd>
class koutil::argparser::Commands< Cmd >

Collection of subcommands.

Template Parameters
CmdTypes of subcommands.

Member Typedef Documentation

◆ storage_t

template<is_subcommand... Cmd>
using koutil::argparser::Commands< Cmd >::storage_t = std::conditional_t<count != 1, std::tuple<Cmd...>, type::types_get_t<type::types<std::decay_t<Cmd>...>, 0>>
private

Constructor & Destructor Documentation

◆ Commands()

template<is_subcommand... Cmd>
koutil::argparser::Commands< Cmd >::Commands ( const Cmd &... cmd)
inlineconstexpr

Member Function Documentation

◆ contains_duplicate()

template<is_subcommand... Cmd>
bool koutil::argparser::Commands< Cmd >::contains_duplicate ( ) const
inlinenodiscardconstexprprivate

Checks for duplicate subcommand names.

Returns
True if duplicate names are found, false otherwise.

◆ contains_duplicate_impl() [1/2]

template<is_subcommand... Cmd>
template<std::size_t I, std::size_t J>
requires (I < count && J < count)
bool koutil::argparser::Commands< Cmd >::contains_duplicate_impl ( ) const
inlinenodiscardconstexprprivate

Checks for duplicate subcommand names recursively.*.

Template Parameters
IIndex of the current subcommand.
JIndex of the subcommand to compare against.
Returns
True if duplicate names are found, false otherwise.

◆ contains_duplicate_impl() [2/2]

template<is_subcommand... Cmd>
template<std::size_t I, std::size_t J>
requires (I >= count || J >= count)
bool koutil::argparser::Commands< Cmd >::contains_duplicate_impl ( ) const
inlinenodiscardconstexprprivate

◆ find()

template<is_subcommand... Cmd>
const SubcommandBase * koutil::argparser::Commands< Cmd >::find ( std::string_view name) const
inlinenodiscardconstexproverridevirtual

Finds a subcommand by name.

Parameters
nameThe name of the subcommand to find.
Returns
A pointer to the found subcommand, or nullptr if not found.

Implements koutil::argparser::CommandsBase.

◆ find_impl()

template<is_subcommand... Cmd>
template<std::size_t I>
const SubcommandBase * koutil::argparser::Commands< Cmd >::find_impl ( std::string_view name) const
inlinenodiscardconstexprprivate

Finds a subcommand by name recursively.

Template Parameters
IIndex of the current subcommand.
Parameters
nameThe name of the subcommand to find.
Returns
A pointer to the found subcommand, or nullptr if not found.

◆ size()

template<is_subcommand... Cmd>
std::size_t koutil::argparser::Commands< Cmd >::size ( ) const
inlinenodiscardconstexproverridevirtual

Gets the number of subcommands.

Returns
The number of subcommands.

Implements koutil::argparser::CommandsBase.

Member Data Documentation

◆ count

template<is_subcommand... Cmd>
std::size_t koutil::argparser::Commands< Cmd >::count = sizeof...(Cmd)
staticconstexprprivate

◆ m_cmds

template<is_subcommand... Cmd>
storage_t koutil::argparser::Commands< Cmd >::m_cmds
private

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