aboutsummaryrefslogtreecommitdiff
path: root/args.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'args.hxx')
-rw-r--r--args.hxx46
1 files changed, 43 insertions, 3 deletions
diff --git a/args.hxx b/args.hxx
index 8deb71b..7be2305 100644
--- a/args.hxx
+++ b/args.hxx
@@ -574,6 +574,15 @@ namespace args
}
virtual void ParseValue(const std::string &value) = 0;
+
+ virtual void Reset() noexcept override
+ {
+ matched = false;
+ ready = true;
+#ifdef ARGS_NOEXCEPT
+ error = Error::None;
+#endif
+ }
};
/** Class for all kinds of validating groups, including ArgumentParser
@@ -686,7 +695,7 @@ namespace args
{
next = group->GetNextPositional();
}
- if (next and next->Ready())
+ if (next && next->Ready())
{
return next;
}
@@ -1162,7 +1171,7 @@ namespace args
{
const auto &chunk = *it;
- if (!terminated and chunk == terminator)
+ if (!terminated && chunk == terminator)
{
terminated = true;
// If a long arg was found
@@ -1475,10 +1484,11 @@ namespace args
class CounterFlag : public Flag
{
private:
+ const int startcount;
int count;
public:
- CounterFlag(Group &group, const std::string &name, const std::string &help, Matcher &&matcher, const int startcount = 0): Flag(group, name, help, std::move(matcher)), count(startcount) {}
+ CounterFlag(Group &group, const std::string &name, const std::string &help, Matcher &&matcher, const int startcount = 0): Flag(group, name, help, std::move(matcher)), startcount(startcount), count(startcount) {}
virtual ~CounterFlag() {}
@@ -1508,6 +1518,12 @@ namespace args
{
return count;
}
+
+ virtual void Reset() noexcept override
+ {
+ FlagBase::Reset();
+ count = startcount;
+ }
};
/** A default Reader class for argument classes
@@ -1645,6 +1661,12 @@ namespace args
{
return name + std::string("...");
}
+
+ virtual void Reset() noexcept override
+ {
+ ValueFlagBase::Reset();
+ values.clear();
+ }
};
/** A mapping value flag class
@@ -1778,6 +1800,12 @@ namespace args
{
return name + std::string("...");
}
+
+ virtual void Reset() noexcept override
+ {
+ ValueFlagBase::Reset();
+ values.clear();
+ }
};
/** A positional argument class
@@ -1873,6 +1901,12 @@ namespace args
{
return values;
}
+
+ virtual void Reset() noexcept override
+ {
+ PositionalBase::Reset();
+ values.clear();
+ }
};
/** A positional argument mapping class
@@ -2009,5 +2043,11 @@ namespace args
{
return name + std::string("...");
}
+
+ virtual void Reset() noexcept override
+ {
+ PositionalBase::Reset();
+ values.clear();
+ }
};
}