diff options
Diffstat (limited to 'Source/cmCommandArgumentsHelper.cxx')
-rw-r--r-- | Source/cmCommandArgumentsHelper.cxx | 74 |
1 files changed, 31 insertions, 43 deletions
diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx index babddbe..968b17c 100644 --- a/Source/cmCommandArgumentsHelper.cxx +++ b/Source/cmCommandArgumentsHelper.cxx @@ -11,11 +11,11 @@ cmCommandArgument::cmCommandArgument(cmCommandArgumentsHelper* args, , ArgumentsBeforeEmpty(true) , CurrentIndex(0) { - if (args != CM_NULLPTR) { + if (args != nullptr) { args->AddArgument(this); } - if (this->Group != CM_NULLPTR) { + if (this->Group != nullptr) { this->Group->ContainedArguments.push_back(this); } } @@ -35,7 +35,7 @@ void cmCommandArgument::Follows(const cmCommandArgument* arg) void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group) { - if (group != CM_NULLPTR) { + if (group != nullptr) { this->ArgumentsBeforeEmpty = false; this->ArgumentsBefore.insert(group->ContainedArguments.begin(), group->ContainedArguments.end()); @@ -52,7 +52,7 @@ bool cmCommandArgument::MayFollow(const cmCommandArgument* current) const bool cmCommandArgument::KeyMatches(const std::string& key) const { - if ((this->Key == CM_NULLPTR) || (this->Key[0] == '\0')) { + if ((this->Key == nullptr) || (this->Key[0] == '\0')) { return true; } return (key == this->Key); @@ -60,12 +60,10 @@ bool cmCommandArgument::KeyMatches(const std::string& key) const void cmCommandArgument::ApplyOwnGroup() { - if (this->Group != CM_NULLPTR) { - for (std::vector<cmCommandArgument*>::const_iterator it = - this->Group->ContainedArguments.begin(); - it != this->Group->ContainedArguments.end(); ++it) { - if (*it != this) { - this->ArgumentsBefore.insert(*it); + if (this->Group != nullptr) { + for (cmCommandArgument* cargs : this->Group->ContainedArguments) { + if (cargs != this) { + this->ArgumentsBefore.insert(cargs); } } } @@ -88,9 +86,9 @@ cmCAStringVector::cmCAStringVector(cmCommandArgumentsHelper* args, const char* key, cmCommandArgumentGroup* group) : cmCommandArgument(args, key, group) - , Ignore(CM_NULLPTR) + , Ignore(nullptr) { - if ((key == CM_NULLPTR) || (*key == 0)) { + if ((key == nullptr) || (*key == 0)) { this->DataStart = 0; } else { this->DataStart = 1; @@ -100,7 +98,7 @@ cmCAStringVector::cmCAStringVector(cmCommandArgumentsHelper* args, bool cmCAStringVector::DoConsume(const std::string& arg, unsigned int index) { if (index >= this->DataStart) { - if ((this->Ignore == CM_NULLPTR) || (arg != this->Ignore)) { + if ((this->Ignore == nullptr) || (arg != this->Ignore)) { this->Vector.push_back(arg); } } @@ -117,7 +115,7 @@ cmCAString::cmCAString(cmCommandArgumentsHelper* args, const char* key, cmCommandArgumentGroup* group) : cmCommandArgument(args, key, group) { - if ((key == CM_NULLPTR) || (*key == 0)) { + if ((key == nullptr) || (*key == 0)) { this->DataStart = 0; } else { this->DataStart = 1; @@ -135,7 +133,7 @@ bool cmCAString::DoConsume(const std::string& arg, unsigned int index) void cmCAString::DoReset() { - this->String = ""; + this->String.clear(); } cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args, const char* key, @@ -180,60 +178,50 @@ void cmCADisabler::DoReset() void cmCommandArgumentGroup::Follows(const cmCommandArgument* arg) { - for (std::vector<cmCommandArgument*>::iterator it = - this->ContainedArguments.begin(); - it != this->ContainedArguments.end(); ++it) { - (*it)->Follows(arg); + for (cmCommandArgument* ca : this->ContainedArguments) { + ca->Follows(arg); } } void cmCommandArgumentGroup::FollowsGroup(const cmCommandArgumentGroup* group) { - for (std::vector<cmCommandArgument*>::iterator it = - this->ContainedArguments.begin(); - it != this->ContainedArguments.end(); ++it) { - (*it)->FollowsGroup(group); + for (cmCommandArgument* ca : this->ContainedArguments) { + ca->FollowsGroup(group); } } void cmCommandArgumentsHelper::Parse(const std::vector<std::string>* args, std::vector<std::string>* unconsumedArgs) { - if (args == CM_NULLPTR) { + if (args == nullptr) { return; } - for (std::vector<cmCommandArgument*>::iterator argIt = - this->Arguments.begin(); - argIt != this->Arguments.end(); ++argIt) { - (*argIt)->ApplyOwnGroup(); - (*argIt)->Reset(); + for (cmCommandArgument* ca : this->Arguments) { + ca->ApplyOwnGroup(); + ca->Reset(); } - cmCommandArgument* activeArgument = CM_NULLPTR; - const cmCommandArgument* previousArgument = CM_NULLPTR; - for (std::vector<std::string>::const_iterator it = args->begin(); - it != args->end(); ++it) { - for (std::vector<cmCommandArgument*>::iterator argIt = - this->Arguments.begin(); - argIt != this->Arguments.end(); ++argIt) { - if ((*argIt)->KeyMatches(*it) && - ((*argIt)->MayFollow(previousArgument))) { - activeArgument = *argIt; + cmCommandArgument* activeArgument = nullptr; + const cmCommandArgument* previousArgument = nullptr; + for (std::string const& it : *args) { + for (cmCommandArgument* ca : this->Arguments) { + if (ca->KeyMatches(it) && (ca->MayFollow(previousArgument))) { + activeArgument = ca; activeArgument->Activate(); break; } } if (activeArgument) { - bool argDone = activeArgument->Consume(*it); + bool argDone = activeArgument->Consume(it); previousArgument = activeArgument; if (argDone) { - activeArgument = CM_NULLPTR; + activeArgument = nullptr; } } else { - if (unconsumedArgs != CM_NULLPTR) { - unconsumedArgs->push_back(*it); + if (unconsumedArgs != nullptr) { + unconsumedArgs->push_back(it); } } } |