mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 12:16:40 +08:00
cmArgumentParser: Record parsed keywords
This commit is contained in:
@@ -61,10 +61,14 @@ void Instance::Bind(MultiStringList& val)
|
|||||||
|
|
||||||
void Instance::Consume(cm::string_view arg, void* result,
|
void Instance::Consume(cm::string_view arg, void* result,
|
||||||
std::vector<std::string>* unparsedArguments,
|
std::vector<std::string>* unparsedArguments,
|
||||||
std::vector<std::string>* keywordsMissingValue)
|
std::vector<std::string>* keywordsMissingValue,
|
||||||
|
std::vector<std::string>* parsedKeywords)
|
||||||
{
|
{
|
||||||
auto const it = this->Bindings.Find(arg);
|
auto const it = this->Bindings.Find(arg);
|
||||||
if (it != this->Bindings.end()) {
|
if (it != this->Bindings.end()) {
|
||||||
|
if (parsedKeywords != nullptr) {
|
||||||
|
parsedKeywords->emplace_back(arg);
|
||||||
|
}
|
||||||
it->second(*this, result);
|
it->second(*this, result);
|
||||||
if (this->ExpectValue && keywordsMissingValue != nullptr) {
|
if (this->ExpectValue && keywordsMissingValue != nullptr) {
|
||||||
keywordsMissingValue->emplace_back(arg);
|
keywordsMissingValue->emplace_back(arg);
|
||||||
|
@@ -45,7 +45,8 @@ public:
|
|||||||
|
|
||||||
void Consume(cm::string_view arg, void* result,
|
void Consume(cm::string_view arg, void* result,
|
||||||
std::vector<std::string>* unparsedArguments,
|
std::vector<std::string>* unparsedArguments,
|
||||||
std::vector<std::string>* keywordsMissingValue);
|
std::vector<std::string>* keywordsMissingValue,
|
||||||
|
std::vector<std::string>* parsedKeywords);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActionMap const& Bindings;
|
ActionMap const& Bindings;
|
||||||
@@ -79,21 +80,25 @@ public:
|
|||||||
template <typename Range>
|
template <typename Range>
|
||||||
void Parse(Result& result, Range const& args,
|
void Parse(Result& result, Range const& args,
|
||||||
std::vector<std::string>* unparsedArguments = nullptr,
|
std::vector<std::string>* unparsedArguments = nullptr,
|
||||||
std::vector<std::string>* keywordsMissingValue = nullptr) const
|
std::vector<std::string>* keywordsMissingValue = nullptr,
|
||||||
|
std::vector<std::string>* parsedKeywords = nullptr) const
|
||||||
{
|
{
|
||||||
ArgumentParser::Instance instance(this->Bindings);
|
ArgumentParser::Instance instance(this->Bindings);
|
||||||
for (cm::string_view arg : args) {
|
for (cm::string_view arg : args) {
|
||||||
instance.Consume(arg, &result, unparsedArguments, keywordsMissingValue);
|
instance.Consume(arg, &result, unparsedArguments, keywordsMissingValue,
|
||||||
|
parsedKeywords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Range>
|
template <typename Range>
|
||||||
Result Parse(Range const& args,
|
Result Parse(Range const& args,
|
||||||
std::vector<std::string>* unparsedArguments = nullptr,
|
std::vector<std::string>* unparsedArguments = nullptr,
|
||||||
std::vector<std::string>* keywordsMissingValue = nullptr) const
|
std::vector<std::string>* keywordsMissingValue = nullptr,
|
||||||
|
std::vector<std::string>* parsedKeywords = nullptr) const
|
||||||
{
|
{
|
||||||
Result result;
|
Result result;
|
||||||
this->Parse(result, args, unparsedArguments, keywordsMissingValue);
|
this->Parse(result, args, unparsedArguments, keywordsMissingValue,
|
||||||
|
parsedKeywords);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,11 +121,13 @@ public:
|
|||||||
template <typename Range>
|
template <typename Range>
|
||||||
void Parse(Range const& args,
|
void Parse(Range const& args,
|
||||||
std::vector<std::string>* unparsedArguments = nullptr,
|
std::vector<std::string>* unparsedArguments = nullptr,
|
||||||
std::vector<std::string>* keywordsMissingValue = nullptr) const
|
std::vector<std::string>* keywordsMissingValue = nullptr,
|
||||||
|
std::vector<std::string>* parsedKeywords = nullptr) const
|
||||||
{
|
{
|
||||||
ArgumentParser::Instance instance(this->Bindings);
|
ArgumentParser::Instance instance(this->Bindings);
|
||||||
for (cm::string_view arg : args) {
|
for (cm::string_view arg : args) {
|
||||||
instance.Consume(arg, nullptr, unparsedArguments, keywordsMissingValue);
|
instance.Consume(arg, nullptr, unparsedArguments, keywordsMissingValue,
|
||||||
|
parsedKeywords);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user