23#ifndef TCLAP_ARG_GROUP_H
24#define TCLAP_ARG_GROUP_H
99 for (
Arg *arg : *
this) {
110 [[nodiscard]]
const std::string
getName()
const;
143 "Required arguments are not allowed"
144 " in an exclusive grouping.",
164 [[nodiscard]]
bool isRequired()
const override {
return false; }
176 [[nodiscard]]
bool isRequired()
const override {
return true; }
192 [[nodiscard]]
bool isRequired()
const override {
return false; }
196 if (std::ranges::any_of(*
this, [arg](
const Arg *existing) {
200 "Argument with same flag/name already exists!", arg->
longID());
204 members.push_back(arg);
217 for (
Arg *candidate : *
this) {
218 if (candidate->isSet()) {
219 if (arg !=
nullptr && arg != candidate) {
223 "Only one is allowed.",
224 flag +
" AND " + candidate->setBy() +
" provided.");
237 std::string sep =
"{";
239 for (
const Arg *arg : *
this) {
249 return static_cast<int>(std::ranges::count_if(
Groups arguments for presentation without imposing a selection rule.
bool isExclusive() const override
Returns true if this argument group is exclusive.
AnyOf(CmdLineInterface &parser)
bool validate() override
Validates that the constraints of the ArgGroup are satisfied.
bool isRequired() const override
Returns true if this argument group is required.
Interface that allows adding an Arg to a "container".
ArgGroup is the base class for implementing groups of arguments that are mutually exclusive (it repla...
virtual bool isExclusive() const =0
Returns true if this argument group is exclusive.
void setParser(CmdLineInterface &parser)
Used by the parser to connect itself to this arg group.
CmdLineInterface * _parser
iterator begin() noexcept
ArgGroup & operator=(const ArgGroup &)=delete
const_iterator end() const noexcept
Container::const_iterator const_iterator
const_iterator begin() const noexcept
Container::iterator iterator
const std::string getName() const
Returns the argument group's name.
virtual bool showAsGroup() const
If arguments in this group should show up as grouped in help.
ArgContainer & add(Arg &arg) override
Add an argument to this arg group.
std::list< Arg * > Container
virtual bool validate()=0
Validates that the constraints of the ArgGroup are satisfied.
ArgGroup(const ArgGroup &)=delete
~ArgGroup() override=default
virtual bool isRequired() const =0
Returns true if this argument group is required.
A virtual base class that defines the essential data for all arguments.
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
bool conflictsWith(const Arg &a) const noexcept
Checks declared registration conflicts: the same object, the same name, or the same nonempty short fl...
const std::string & setBy() const noexcept
Returns the value specified to set this flag (like -a or –all).
const std::string & getName() const noexcept
Returns the argument name.
virtual bool visibleInHelp() const
Returns true if this Arg is visible in the help output.
virtual bool isRequired() const
Indicates whether the argument is required.
The base class that manages the command line definition and passes along the parsing to the appropria...
ArgContainer & add(Arg &a) override=0
Adds an argument.
virtual bool attachGroup(ArgGroup &)
virtual void addToArgList(Arg *a)=0
Thrown from CmdLine when the arguments on the command line are not properly specified,...
The base class that manages the command line definition and passes along the parsing to the appropria...
Implements a group of arguments where at most one can be selected.
bool isRequired() const override
Returns true if this argument group is required.
EitherOf(CmdLineInterface &parser)
Implements common functionality for exclusive argument groups.
ArgContainer & add(Arg &arg) override
Add an argument to this arg group.
bool validate() override
Validates that the constraints of the ArgGroup are satisfied.
ArgContainer & add(Arg *arg) override
Add an argument to this arg group.
ExclusiveArgGroup(CmdLineInterface &parser)
bool isExclusive() const override
Returns true if this argument group is exclusive.
ExclusiveArgGroup()=default
Implements a group of arguments where exactly one must be selected.
OneOf(CmdLineInterface &parser)
bool isRequired() const override
Returns true if this argument group is required.
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
int CountVisibleArgs(const ArgGroup &g)