CPP-AP 2.2.6
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 Member Functions

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::string_view primary)
 Primary name constructor.
 
 argument_name (std::string_view primary, std::string_view secondary)
 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 noexcept
 Matches the given string to the argument_name instance.
 
bool match (const argument_name &arg_name) const noexcept
 Matches the given argument name to the argument_name instance.
 
std::string str (const std::optional< char > flag_char=std::nullopt) const noexcept
 Get a string representation of the argument_name.
 

Public Attributes

const std::string primary
 The primary name of the argument.
 
const std::optional< std::string > secondary
 The optional (short) name of the argument.
 

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 17 of file argument_name.hpp.

Constructor & Destructor Documentation

◆ argument_name() [1/2]

ap::detail::argument_name::argument_name ( std::string_view  primary)
inline

Primary name constructor.

Parameters
primaryThe primary name of the argument.

Definition at line 30 of file argument_name.hpp.

◆ argument_name() [2/2]

ap::detail::argument_name::argument_name ( std::string_view  primary,
std::string_view  secondary 
)
inline

Primary and secondary name constructor.

Parameters
primaryThe primary name of the argument.
secondaryThe secondary (short) name of the argument.

Definition at line 37 of file argument_name.hpp.

Member Function Documentation

◆ match() [1/2]

bool ap::detail::argument_name::match ( const argument_name arg_name) const
inlinenoexcept

Matches the given argument name to the argument_name instance.

Parameters
arg_nameThe argument_name instance to match.
Returns
True if arg_name's primary or secondary value matches the argument_name instance.

Definition at line 73 of file argument_name.hpp.

◆ match() [2/2]

bool ap::detail::argument_name::match ( std::string_view  arg_name) const
inlinenoexcept

Matches the given string to the argument_name instance.

Parameters
arg_nameThe name string to match.
Returns
True if name is equal to either the primary or the secondary name of the argument_name instance.

Definition at line 63 of file argument_name.hpp.

◆ 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 48 of file argument_name.hpp.

◆ str()

std::string ap::detail::argument_name::str ( const std::optional< char >  flag_char = std::nullopt) const
inlinenoexcept

Get a string representation of the argument_name.

Parameters
flag_charThe character used for the argument flag prefix.

Definition at line 87 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 102 of file argument_name.hpp.

Member Data Documentation

◆ primary

const std::string ap::detail::argument_name::primary

The primary name of the argument.

Definition at line 107 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 108 of file argument_name.hpp.


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