CPP-AP 2.7.0
Command-line argument parser for C++20
Loading...
Searching...
No Matches
ap::detail::argument_name Struct Reference

Structure holding the argument's name. More...

#include <argument_name.hpp>

Public Types

enum class  match_type : std::uint8_t { m_any , m_primary , m_secondary }
 Specifies the type of argument name match. More...
 

Public Member Functions

 argument_name ()=delete
 
argument_nameoperator= (const argument_name &)=delete
 
argument_nameoperator= (argument_name &&)=delete
 
 argument_name (const argument_name &)=default
 
 argument_name (argument_name &&)=default
 
 argument_name (std::optional< std::string > primary, std::optional< std::string > secondary=std::nullopt, std::optional< char > flag_char=std::nullopt)
 Primary and secondary name constructor.
 
 ~argument_name ()=default
 Class destructor.
 
bool operator== (const argument_name &other) const noexcept
 Equality comparison operator.
 
bool match (std::string_view arg_name, const match_type m_type=m_any) const noexcept
 Matches the given string to the argument_name instance.
 
bool match (const argument_name &arg_name, const match_type m_type=m_any) const noexcept
 Matches the given argument name to the argument_name instance.
 
std::string str () const noexcept
 Get a string representation of the argument_name.
 

Public Attributes

const std::optional< std::string > primary
 The primary name of the argument.
 
const std::optional< std::string > secondary
 The optional (short) name of the argument.
 
const std::optional< char > flag_char
 The flag character (used for optional argument names).
 

Friends

std::ostream & operator<< (std::ostream &os, const argument_name &arg_name) noexcept
 Stream insertion operator for argument names.
 

Detailed Description

Structure holding the argument's name.

Definition at line 20 of file argument_name.hpp.

Member Enumeration Documentation

◆ match_type

enum class ap::detail::argument_name::match_type : std::uint8_t
strong

Specifies the type of argument name match.

Enumerator
m_any 

Matches either the primary or the secondary name.

m_primary 

Matches only the primary name.

m_secondary 

Matches only the secondary name.

Definition at line 22 of file argument_name.hpp.

Constructor & Destructor Documentation

◆ argument_name() [1/4]

ap::detail::argument_name::argument_name ( )
delete

◆ argument_name() [2/4]

ap::detail::argument_name::argument_name ( const argument_name )
default

◆ argument_name() [3/4]

ap::detail::argument_name::argument_name ( argument_name &&  )
default

◆ argument_name() [4/4]

ap::detail::argument_name::argument_name ( std::optional< std::string >  primary,
std::optional< std::string >  secondary = std::nullopt,
std::optional< char >  flag_char = std::nullopt 
)
inline

Primary and secondary name constructor.

Parameters
primaryThe primary name of the argument.
secondaryThe secondary (short) name of the argument.
flag_charThe flag character (used for optional argument names).

Definition at line 43 of file argument_name.hpp.

◆ ~argument_name()

ap::detail::argument_name::~argument_name ( )
default

Class destructor.

Member Function Documentation

◆ match() [1/2]

bool ap::detail::argument_name::match ( const argument_name arg_name,
const match_type  m_type = m_any 
) const
inlinenoexcept

Matches the given argument name to the argument_name instance.

Parameters
arg_nameThe argument_name instance to match.
m_typeUNUSED - necessary to match the signature of the string_view overload of the match function.
Returns
True if arg_name's primary or secondary value matches the argument_name instance.

Definition at line 94 of file argument_name.hpp.

◆ match() [2/2]

bool ap::detail::argument_name::match ( std::string_view  arg_name,
const match_type  m_type = m_any 
) const
inlinenoexcept

Matches the given string to the argument_name instance.

Parameters
arg_nameThe name string to match.
m_typeThe match type used to find the argument.
Returns
true if the given name matches the primary/secondary name (depending on the match type).

Definition at line 74 of file argument_name.hpp.

◆ operator=() [1/2]

argument_name & ap::detail::argument_name::operator= ( argument_name &&  )
delete

◆ operator=() [2/2]

argument_name & ap::detail::argument_name::operator= ( const argument_name )
delete

◆ operator==()

bool ap::detail::argument_name::operator== ( const argument_name other) const
inlinenoexcept

Equality comparison operator.

Parameters
otherThe argument_name instance to compare with.
Returns
Equality of argument names.

Definition at line 64 of file argument_name.hpp.

◆ str()

std::string ap::detail::argument_name::str ( ) const
inlinenoexcept

Get a string representation of the argument_name.

Parameters
flag_charThe character used for the argument flag prefix.

Definition at line 110 of file argument_name.hpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const argument_name arg_name 
)
friend

Stream insertion operator for argument names.

Parameters
osThe output stream.
arg_nameThe argument name to be inserted into the stream.
Returns
The modified output stream.

Definition at line 129 of file argument_name.hpp.

Member Data Documentation

◆ flag_char

const std::optional<char> ap::detail::argument_name::flag_char

The flag character (used for optional argument names).

Definition at line 136 of file argument_name.hpp.

◆ primary

const std::optional<std::string> ap::detail::argument_name::primary

The primary name of the argument.

Definition at line 134 of file argument_name.hpp.

◆ secondary

const std::optional<std::string> ap::detail::argument_name::secondary

The optional (short) name of the argument.

Definition at line 135 of file argument_name.hpp.


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