summaryrefslogtreecommitdiff
path: root/Source/cmArgumentParser.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-07-26 14:30:22 -0400
committerBrad King <brad.king@kitware.com>2022-07-27 07:03:32 -0400
commitf5d2f6076abe9247ec6a4fc5130267ecc256ab81 (patch)
treeca4efe9bce5cfceb08445e51c19bf40305759c52 /Source/cmArgumentParser.h
parent078e2aec8f7a0e6d0be91d0fd565d6c22032f666 (diff)
downloadcmake-f5d2f6076abe9247ec6a4fc5130267ecc256ab81.tar.gz
cmArgumentParser: Generalize expected argument count
Replace the boolean expectation with an integer count.
Diffstat (limited to 'Source/cmArgumentParser.h')
-rw-r--r--Source/cmArgumentParser.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h
index a417eb44ab..d0406e4a55 100644
--- a/Source/cmArgumentParser.h
+++ b/Source/cmArgumentParser.h
@@ -68,6 +68,16 @@ enum class Continue
Yes,
};
+struct ExpectAtLeast
+{
+ std::size_t Count = 0;
+
+ ExpectAtLeast(std::size_t count)
+ : Count(count)
+ {
+ }
+};
+
class Instance;
using KeywordAction = std::function<void(Instance&)>;
using KeywordNameAction = std::function<void(Instance&, cm::string_view)>;
@@ -93,6 +103,7 @@ public:
class Base
{
public:
+ using ExpectAtLeast = ArgumentParser::ExpectAtLeast;
using Continue = ArgumentParser::Continue;
using Instance = ArgumentParser::Instance;
using ParseResult = ArgumentParser::ParseResult;
@@ -136,7 +147,7 @@ public:
{
}
- void Bind(std::function<Continue(cm::string_view)> f);
+ void Bind(std::function<Continue(cm::string_view)> f, ExpectAtLeast expect);
void Bind(bool& val);
void Bind(std::string& val);
void Bind(Maybe<std::string>& val);
@@ -170,8 +181,9 @@ private:
void* Result = nullptr;
cm::string_view Keyword;
+ std::size_t KeywordValuesSeen = 0;
+ std::size_t KeywordValuesExpected = 0;
std::function<Continue(cm::string_view)> KeywordValueFunc;
- bool ExpectValue = false;
void Consume(cm::string_view arg);
void FinishKeyword();