summaryrefslogtreecommitdiffstats
path: root/Source/cmCommandArgumentsHelper.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCommandArgumentsHelper.cxx')
-rw-r--r--Source/cmCommandArgumentsHelper.cxx210
1 files changed, 85 insertions, 125 deletions
diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx
index 1a2efc6..c336bc5 100644
--- a/Source/cmCommandArgumentsHelper.cxx
+++ b/Source/cmCommandArgumentsHelper.cxx
@@ -15,26 +15,24 @@
cmCommandArgument::cmCommandArgument(cmCommandArgumentsHelper* args,
const char* key,
cmCommandArgumentGroup* group)
-:Key(key)
-,Group(group)
-,WasActive(false)
-,ArgumentsBeforeEmpty(true)
-,CurrentIndex(0)
+ : Key(key)
+ , Group(group)
+ , WasActive(false)
+ , ArgumentsBeforeEmpty(true)
+ , CurrentIndex(0)
{
- if (args!=0)
- {
+ if (args != 0) {
args->AddArgument(this);
- }
+ }
- if (this->Group!=0)
- {
+ if (this->Group != 0) {
this->Group->ContainedArguments.push_back(this);
- }
+ }
}
void cmCommandArgument::Reset()
{
- this->WasActive =false;
+ this->WasActive = false;
this->CurrentIndex = 0;
this->DoReset();
}
@@ -47,55 +45,47 @@ void cmCommandArgument::Follows(const cmCommandArgument* arg)
void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group)
{
- if (group!=0)
- {
+ if (group != 0) {
this->ArgumentsBeforeEmpty = false;
this->ArgumentsBefore.insert(group->ContainedArguments.begin(),
group->ContainedArguments.end());
- }
+ }
}
bool cmCommandArgument::MayFollow(const cmCommandArgument* current) const
{
- if (this->ArgumentsBeforeEmpty)
- {
+ if (this->ArgumentsBeforeEmpty) {
return true;
- }
+ }
- std::set<const cmCommandArgument*>::const_iterator argIt
- = this->ArgumentsBefore.find(current);
- if (argIt != this->ArgumentsBefore.end())
- {
+ std::set<const cmCommandArgument*>::const_iterator argIt =
+ this->ArgumentsBefore.find(current);
+ if (argIt != this->ArgumentsBefore.end()) {
return true;
- }
+ }
return false;
}
bool cmCommandArgument::KeyMatches(const std::string& key) const
{
- if ((this->Key==0) || (this->Key[0]=='\0'))
- {
+ if ((this->Key == 0) || (this->Key[0] == '\0')) {
return true;
- }
- return (key==this->Key);
+ }
+ return (key == this->Key);
}
void cmCommandArgument::ApplyOwnGroup()
{
- if (this->Group!=0)
- {
- for (std::vector<cmCommandArgument*>::const_iterator
- it = this->Group->ContainedArguments.begin();
- it != this->Group->ContainedArguments.end();
- ++it)
- {
- if(*it != this)
- {
+ if (this->Group != 0) {
+ for (std::vector<cmCommandArgument*>::const_iterator it =
+ this->Group->ContainedArguments.begin();
+ it != this->Group->ContainedArguments.end(); ++it) {
+ if (*it != this) {
this->ArgumentsBefore.insert(*it);
- }
}
}
+ }
}
void cmCommandArgument::Activate()
@@ -106,37 +96,31 @@ void cmCommandArgument::Activate()
bool cmCommandArgument::Consume(const std::string& arg)
{
- bool res=this->DoConsume(arg, this->CurrentIndex);
+ bool res = this->DoConsume(arg, this->CurrentIndex);
this->CurrentIndex++;
return res;
}
-
cmCAStringVector::cmCAStringVector(cmCommandArgumentsHelper* args,
const char* key,
cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
-,Ignore(0)
+ : cmCommandArgument(args, key, group)
+ , Ignore(0)
{
- if ((key==0) || (*key==0))
- {
+ if ((key == 0) || (*key == 0)) {
this->DataStart = 0;
- }
- else
- {
+ } else {
this->DataStart = 1;
- }
+ }
}
-bool cmCAStringVector::DoConsume(const std::string& arg,unsigned int index)
+bool cmCAStringVector::DoConsume(const std::string& arg, unsigned int index)
{
- if (index >= this->DataStart)
- {
- if ((this->Ignore==0) || (arg != this->Ignore))
- {
+ if (index >= this->DataStart) {
+ if ((this->Ignore == 0) || (arg != this->Ignore)) {
this->Vector.push_back(arg);
- }
}
+ }
return false;
}
@@ -146,27 +130,22 @@ void cmCAStringVector::DoReset()
this->Vector.clear();
}
-cmCAString::cmCAString(cmCommandArgumentsHelper* args,
- const char* key,
+cmCAString::cmCAString(cmCommandArgumentsHelper* args, const char* key,
cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
+ : cmCommandArgument(args, key, group)
{
- if ((key==0) || (*key==0))
- {
+ if ((key == 0) || (*key == 0)) {
this->DataStart = 0;
- }
- else
- {
+ } else {
this->DataStart = 1;
- }
+ }
}
bool cmCAString::DoConsume(const std::string& arg, unsigned int index)
{
- if (index == this->DataStart)
- {
+ if (index == this->DataStart) {
this->String = arg;
- }
+ }
return index >= this->DataStart;
}
@@ -176,19 +155,18 @@ void cmCAString::DoReset()
this->String = "";
}
-cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args,
- const char* key,
+cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args, const char* key,
cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
-,Enabled(false)
-{}
+ : cmCommandArgument(args, key, group)
+ , Enabled(false)
+{
+}
bool cmCAEnabler::DoConsume(const std::string&, unsigned int index)
{
- if (index==0)
- {
+ if (index == 0) {
this->Enabled = true;
- }
+ }
return true;
}
@@ -197,19 +175,18 @@ void cmCAEnabler::DoReset()
this->Enabled = false;
}
-cmCADisabler::cmCADisabler(cmCommandArgumentsHelper* args,
- const char* key,
+cmCADisabler::cmCADisabler(cmCommandArgumentsHelper* args, const char* key,
cmCommandArgumentGroup* group)
-:cmCommandArgument(args, key, group)
-,Enabled(true)
-{}
+ : cmCommandArgument(args, key, group)
+ , Enabled(true)
+{
+}
bool cmCADisabler::DoConsume(const std::string&, unsigned int index)
{
- if (index==0)
- {
+ if (index == 0) {
this->Enabled = false;
- }
+ }
return true;
}
@@ -220,83 +197,66 @@ void cmCADisabler::DoReset()
void cmCommandArgumentGroup::Follows(const cmCommandArgument* arg)
{
- for(std::vector<cmCommandArgument*>::iterator
- it = this->ContainedArguments.begin();
- it != this->ContainedArguments.end();
- ++it)
- {
+ for (std::vector<cmCommandArgument*>::iterator it =
+ this->ContainedArguments.begin();
+ it != this->ContainedArguments.end(); ++it) {
(*it)->Follows(arg);
- }
+ }
}
void cmCommandArgumentGroup::FollowsGroup(const cmCommandArgumentGroup* group)
{
- for(std::vector<cmCommandArgument*>::iterator
- it = this->ContainedArguments.begin();
- it != this->ContainedArguments.end();
- ++it)
- {
+ for (std::vector<cmCommandArgument*>::iterator it =
+ this->ContainedArguments.begin();
+ it != this->ContainedArguments.end(); ++it) {
(*it)->FollowsGroup(group);
- }
+ }
}
void cmCommandArgumentsHelper::Parse(const std::vector<std::string>* args,
std::vector<std::string>* unconsumedArgs)
{
- if(args==0)
- {
+ if (args == 0) {
return;
- }
+ }
- for(std::vector<cmCommandArgument*>::iterator
- argIt = this->Arguments.begin();
- argIt != this->Arguments.end();
- ++argIt)
- {
+ for (std::vector<cmCommandArgument*>::iterator argIt =
+ this->Arguments.begin();
+ argIt != this->Arguments.end(); ++argIt) {
(*argIt)->ApplyOwnGroup();
(*argIt)->Reset();
- }
+ }
cmCommandArgument* activeArgument = 0;
const cmCommandArgument* previousArgument = 0;
- 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)))
- {
+ 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;
activeArgument->Activate();
break;
- }
}
+ }
- if (activeArgument)
- {
+ if (activeArgument) {
bool argDone = activeArgument->Consume(*it);
previousArgument = activeArgument;
- if (argDone)
- {
+ if (argDone) {
activeArgument = 0;
- }
}
- else
- {
- if (unconsumedArgs!=0)
- {
+ } else {
+ if (unconsumedArgs != 0) {
unconsumedArgs->push_back(*it);
- }
}
}
+ }
}
void cmCommandArgumentsHelper::AddArgument(cmCommandArgument* arg)
{
this->Arguments.push_back(arg);
}
-