44 std::optional<std::string>
primary,
45 std::optional<std::string>
secondary = std::nullopt,
46 std::optional<char>
flag_char = std::nullopt
52 throw std::logic_error(
"An argument name cannot be empty! At least one of "
53 "primary/secondary must be specified");
112 const std::string
fc(this->
flag_char.has_value(),
this->flag_char.value_or(
char()));
argument_name_discriminator
Argument name member discriminator.
@ n_secondary
Represents the secondary name (used with a short flag prefix –).
@ n_primary
Represents the primary name (used with a long flag prefix –).
Structure holding the argument's name.
const std::optional< std::string > secondary
The optional (short) name of the argument.
std::string str() const noexcept
Get a string representation of the argument_name.
~argument_name()=default
Class destructor.
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.
const std::optional< char > flag_char
The flag character (used for optional argument names).
match_type
Specifies the type of argument name match.
@ m_any
Matches either the primary or the secondary name.
@ m_primary
Matches only the primary name.
@ m_secondary
Matches only the secondary name.
argument_name(const argument_name &)=default
argument_name & operator=(argument_name &&)=delete
argument_name & operator=(const argument_name &)=delete
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.
bool operator==(const argument_name &other) const noexcept
Equality comparison operator.
argument_name(argument_name &&)=default
friend std::ostream & operator<<(std::ostream &os, const argument_name &arg_name) noexcept
Stream insertion operator for argument names.
const std::optional< std::string > primary
The primary name of the argument.