37#ifndef ARGS__GROUPS_HPP__INCLUDED
38#define ARGS__GROUPS_HPP__INCLUDED
59 template<
typename T >
61 bool required =
false )
80 [] (
const auto & arg ) {
return arg->isDefined(); } );
100 if( arg->isRequired() )
103 SL(
"\" is not allowed to be in OnlyOne group \"" ) +
117 if( arg->isDefined() )
121 "be defined in OnlyOne group \"" ) ) +
name() +
SL(
"\". " ) +
122 SL(
"Whereas defined \"" ) + defined->
name() +
123 SL(
"\" and \"" ) + arg->name() +
SL(
"\"." ) );
141 template<
typename T >
143 bool required =
false )
162 [] (
const auto & arg ) {
return !arg->isDefined(); } );
182 if( arg->isRequired() )
185 SL(
"\" is not allowed to " ) +
186 SL(
"be in AllOf group \"" ) +
name() +
SL(
"\"." ) );
196 [] (
const auto & arg ) {
return arg->isDefined(); } );
199 [] (
const auto & arg ) {
return arg->isDefined(); } );
201 if( defined && !all )
203 "AllOf group \"" ) ) +
name() +
SL(
"\" should be defined." ) );
217 template<
typename T >
219 bool required =
false )
238 [] (
const auto & arg ) {
return arg->isDefined(); } );
258 if( arg->isRequired() )
261 SL(
"\" is not allowed to " ) +
262 SL(
"be in AtLeastOne group \"" ) +
name() +
SL(
"\"." ) );
Group of args where all arguments should be defined.
bool isDefined() const override
AllOfGroup(T &&name, bool required=false)
void checkCorrectnessBeforeParsing(StringList &flags, StringList &names) const override
Check correctness of the argument before parsing.
void checkCorrectnessAfterParsing() const override
Check correctness of the argument after parsing.
ArgType type() const override
virtual String name() const =0
Group of args where at least one argument should be defined.
AtLeastOneGroup(T &&name, bool required=false)
virtual ~AtLeastOneGroup()
bool isDefined() const override
ArgType type() const override
void checkCorrectnessBeforeParsing(StringList &flags, StringList &names) const override
Check correctness of the argument before parsing.
Base exception of the library.
Interface for the groups.
String name() const override
const Arguments & children() const
void checkCorrectnessBeforeParsing(StringList &flags, StringList &names) const override
Check correctness of the argument before parsing.
void checkCorrectnessAfterParsing() const override
Check correctness of the argument after parsing.
Group of args where only one argument can be defined.
void checkCorrectnessBeforeParsing(StringList &flags, StringList &names) const override
Check correctness of the argument before parsing.
OnlyOneGroup(T &&name, bool required=false)
bool isDefined() const override
ArgType type() const override
void checkCorrectnessAfterParsing() const override
Check correctness of the argument after parsing.
constexpr std::add_const< T >::type & asConst(T &t) noexcept
Adds const to non-const objects.
std::string String
String type.
std::vector< String > StringList
List of strings.
ArgType
Type of the argument.
@ AllOfGroup
"All of" group.
@ AtLeastOneGroup
"At least one" group.
@ OnlyOneGroup
"Only one" group.