diff options
author | Brad King <brad.king@kitware.com> | 2022-06-17 16:52:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-07-20 20:03:13 (GMT) |
commit | a77b9c0ece8dbb2164c2c0f11c1f5368bd055f8a (patch) | |
tree | 3840abcbcad6356f880a634e626145caa904ad63 /Source/cmArgumentParser.h | |
parent | 197ef69aa1758040ccf8a01dd0a9be6ddb8f8c17 (diff) | |
download | CMake-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.h | 18 |
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: |