summaryrefslogtreecommitdiffstats
path: root/Source/cmArgumentParser.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-06-17 16:52:55 (GMT)
committerBrad King <brad.king@kitware.com>2022-07-20 20:03:13 (GMT)
commita77b9c0ece8dbb2164c2c0f11c1f5368bd055f8a (patch)
tree3840abcbcad6356f880a634e626145caa904ad63 /Source/cmArgumentParser.h
parent197ef69aa1758040ccf8a01dd0a9be6ddb8f8c17 (diff)
downloadCMake-a77b9c0ece8dbb2164c2c0f11c1f5368bd055f8a.zip
CMake-a77b9c0ece8dbb2164c2c0f11c1f5368bd055f8a.tar.gz
CMake-a77b9c0ece8dbb2164c2c0f11c1f5368bd055f8a.tar.bz2
cmArgumentParser: De-duplicate parse loop
Diffstat (limited to 'Source/cmArgumentParser.h')
-rw-r--r--Source/cmArgumentParser.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h
index a26195d..7cbef92 100644
--- a/Source/cmArgumentParser.h
+++ b/Source/cmArgumentParser.h
@@ -65,7 +65,13 @@ public:
this->Bind(*optVal);
}
- void Consume(cm::string_view arg);
+ template <typename Range>
+ void Parse(Range const& args)
+ {
+ for (cm::string_view arg : args) {
+ this->Consume(arg);
+ }
+ }
private:
ActionMap const& Bindings;
@@ -78,6 +84,8 @@ private:
std::vector<std::string>* CurrentList = nullptr;
bool ExpectValue = false;
+ void Consume(cm::string_view arg);
+
template <typename Result>
friend class ::cmArgumentParser;
};
@@ -114,9 +122,7 @@ public:
ArgumentParser::Instance instance(this->Bindings, unparsedArguments,
keywordsMissingValue, parsedKeywords,
&result);
- for (cm::string_view arg : args) {
- instance.Consume(arg);
- }
+ instance.Parse(args);
}
template <typename Range>
@@ -153,9 +159,7 @@ public:
{
ArgumentParser::Instance instance(this->Bindings, unparsedArguments,
keywordsMissingValue, parsedKeywords);
- for (cm::string_view arg : args) {
- instance.Consume(arg);
- }
+ instance.Parse(args);
}
protected: