24#ifndef TCLAP_VALUES_CONSTRAINT_H
25#define TCLAP_VALUES_CONSTRAINT_H
43 requires(std::ostream &os,
const T &val) { os << val; };
68 [[nodiscard]] std::string
description()
const override;
73 [[nodiscard]] std::string
shortID()
const override;
80 bool check(
const T &value)
const override;
97 : _allowed(allowed), _typeDesc(
"") {
99 for (
const T &value : _allowed) {
100 std::ostringstream os;
103 if (!first) _typeDesc +=
"|";
104 _typeDesc += os.str();
111 return std::ranges::find(_allowed, val) != _allowed.end();
The interface that defines the interaction between the Arg and Constraint.
A Constraint that constrains the Arg to only those values specified in the constraint.
bool check(const T &value) const override
The method used to verify that the value parsed from the command line meets the constraint.
ValuesConstraint(const std::vector< T > &allowed)
Constructor.
std::string _typeDesc
The string used to describe the allowed values of this constraint.
std::string shortID() const override
Returns the short ID for the Constraint.
std::vector< T > _allowed
The list of valid values.
~ValuesConstraint() override=default
Virtual destructor.
std::string description() const override
Returns a description of the Constraint.