49 if (not (this->
secondary and other.secondary) and (this->
secondary or other.secondary))
52 if (this->
primary != other.primary)
63 [[nodiscard]]
bool match(std::string_view arg_name)
const noexcept {
64 return arg_name == this->
primary
74 if (this->
match(arg_name.primary))
77 if (arg_name.secondary)
78 return this->
match(arg_name.secondary.value());
87 [[nodiscard]] std::string
str(
const std::optional<char> flag_char = std::nullopt)
90 const std::string fc(flag_char.has_value(), flag_char.value_or(
char()));
92 ? std::format(
"{}{}{}, {}{}", fc, fc, this->
primary, fc, this->
secondary.value())
93 : std::format(
"{}{}{}", fc, fc, this->
primary);
103 os << arg_name.str();
Structure holding the argument's name.
bool operator==(const argument_name &other) const noexcept
Equality comparison operator.
std::string str(const std::optional< char > flag_char=std::nullopt) const noexcept
Get a string representation of the argument_name.
bool match(const argument_name &arg_name) const noexcept
Matches the given argument name to the argument_name instance.
const std::optional< std::string > secondary
The optional (short) name of the argument.
argument_name(std::string_view primary, std::string_view secondary)
Primary and secondary name constructor.
~argument_name()=default
Class destructor.
const std::string primary
The primary name of the argument.
bool match(std::string_view arg_name) const noexcept
Matches the given string to the argument_name instance.
argument_name(std::string_view primary)
Primary name constructor.
friend std::ostream & operator<<(std::ostream &os, const argument_name &arg_name) noexcept
Stream insertion operator for argument names.