aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor C. Richberger <Taywee@gmx.com>2016-07-16 00:12:23 -0600
committerTaylor C. Richberger <Taywee@gmx.com>2016-07-16 00:12:23 -0600
commitc62586df308d9e93ba1ed3ef7de906779b3e6cab (patch)
tree4a0e5e29cc8d5362793946af36b7b6b2a8c34461
parentupdate pages (diff)
parentMerge pull request #8 from iamthebot/master (diff)
downloadargs.hxx-c62586df308d9e93ba1ed3ef7de906779b3e6cab.tar.xz
Merge branch 'master' of github.com:Taywee/args
-rw-r--r--args.hxx102
1 files changed, 51 insertions, 51 deletions
diff --git a/args.hxx b/args.hxx
index fa38aab..8deb71b 100644
--- a/args.hxx
+++ b/args.hxx
@@ -585,6 +585,57 @@ namespace args
std::function<bool(const Group &)> validator;
public:
+ /** Default validators
+ */
+ struct Validators
+ {
+ static bool Xor(const Group &group)
+ {
+ return group.MatchedChildren() == 1;
+ }
+
+ static bool AtLeastOne(const Group &group)
+ {
+ return group.MatchedChildren() >= 1;
+ }
+
+ static bool AtMostOne(const Group &group)
+ {
+ return group.MatchedChildren() <= 1;
+ }
+
+ static bool All(const Group &group)
+ {
+ return group.Children().size() == group.MatchedChildren();
+ }
+
+ static bool AllOrNone(const Group &group)
+ {
+ return (All(group) || None(group));
+ }
+
+ static bool AllChildGroups(const Group &group)
+ {
+ return std::find_if(std::begin(group.Children()), std::end(group.Children()), [](const Base* child) -> bool {
+ return dynamic_cast<const Group *>(child) && !child->Matched();
+ }) == std::end(group.Children());
+ }
+
+ static bool DontCare(const Group &group)
+ {
+ return true;
+ }
+
+ static bool CareTooMuch(const Group &group)
+ {
+ return false;
+ }
+
+ static bool None(const Group &group)
+ {
+ return group.MatchedChildren() == 0;
+ }
+ };
/// If help is empty, this group will not be printed in help output
Group(const std::string &help = std::string(), const std::function<bool(const Group &)> &validator = Validators::DontCare) : Base(help), validator(validator) {}
/// If help is empty, this group will not be printed in help output
@@ -784,57 +835,6 @@ namespace args
}
#endif
- /** Default validators
- */
- struct Validators
- {
- static bool Xor(const Group &group)
- {
- return group.MatchedChildren() == 1;
- }
-
- static bool AtLeastOne(const Group &group)
- {
- return group.MatchedChildren() >= 1;
- }
-
- static bool AtMostOne(const Group &group)
- {
- return group.MatchedChildren() <= 1;
- }
-
- static bool All(const Group &group)
- {
- return group.Children().size() == group.MatchedChildren();
- }
-
- static bool AllOrNone(const Group &group)
- {
- return (All(group) || None(group));
- }
-
- static bool AllChildGroups(const Group &group)
- {
- return std::find_if(std::begin(group.Children()), std::end(group.Children()), [](const Base* child) -> bool {
- return dynamic_cast<const Group *>(child) && !child->Matched();
- }) == std::end(group.Children());
- }
-
- static bool DontCare(const Group &group)
- {
- return true;
- }
-
- static bool CareTooMuch(const Group &group)
- {
- return false;
- }
-
- static bool None(const Group &group)
- {
- return group.MatchedChildren() == 0;
- }
- };
};
/** The main user facing command line argument parser class