ENH: add support for a default value, fix case when there is no item except
the own group Alex
This commit is contained in:
parent
c6e937ca53
commit
2120ce4fcd
|
@ -23,6 +23,7 @@ cmCommandArgument::cmCommandArgument(cmCommandArgumentsHelper* args,
|
||||||
:Key(key)
|
:Key(key)
|
||||||
,Group(group)
|
,Group(group)
|
||||||
,WasActive(false)
|
,WasActive(false)
|
||||||
|
,ArgumentsBeforeEmpty(true)
|
||||||
,CurrentIndex(0)
|
,CurrentIndex(0)
|
||||||
{
|
{
|
||||||
if (args!=0)
|
if (args!=0)
|
||||||
|
@ -45,6 +46,7 @@ void cmCommandArgument::Reset()
|
||||||
|
|
||||||
void cmCommandArgument::Follows(const cmCommandArgument* arg)
|
void cmCommandArgument::Follows(const cmCommandArgument* arg)
|
||||||
{
|
{
|
||||||
|
this->ArgumentsBeforeEmpty = false;
|
||||||
this->ArgumentsBefore.insert(arg);
|
this->ArgumentsBefore.insert(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +54,7 @@ void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group)
|
||||||
{
|
{
|
||||||
if (group!=0)
|
if (group!=0)
|
||||||
{
|
{
|
||||||
|
this->ArgumentsBeforeEmpty = false;
|
||||||
for(std::vector<cmCommandArgument*>::const_iterator
|
for(std::vector<cmCommandArgument*>::const_iterator
|
||||||
argIt= group->ContainedArguments.begin();
|
argIt= group->ContainedArguments.begin();
|
||||||
argIt != group->ContainedArguments.end();
|
argIt != group->ContainedArguments.end();
|
||||||
|
@ -64,7 +67,7 @@ void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group)
|
||||||
|
|
||||||
bool cmCommandArgument::MayFollow(const cmCommandArgument* current) const
|
bool cmCommandArgument::MayFollow(const cmCommandArgument* current) const
|
||||||
{
|
{
|
||||||
if (this->ArgumentsBefore.empty())
|
if (this->ArgumentsBeforeEmpty)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +183,7 @@ bool cmCAString::DoConsume(const std::string& arg, unsigned int index)
|
||||||
|
|
||||||
void cmCAString::DoReset()
|
void cmCAString::DoReset()
|
||||||
{
|
{
|
||||||
this->String = "";
|
this->String = this->DefaultString;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args,
|
cmCAEnabler::cmCAEnabler(cmCommandArgumentsHelper* args,
|
||||||
|
|
|
@ -87,6 +87,7 @@ class cmCommandArgument
|
||||||
std::set<const cmCommandArgument*> ArgumentsBefore;
|
std::set<const cmCommandArgument*> ArgumentsBefore;
|
||||||
cmCommandArgumentGroup* Group;
|
cmCommandArgumentGroup* Group;
|
||||||
bool WasActive;
|
bool WasActive;
|
||||||
|
bool ArgumentsBeforeEmpty;
|
||||||
unsigned int CurrentIndex;
|
unsigned int CurrentIndex;
|
||||||
|
|
||||||
virtual bool DoConsume(const std::string& arg, unsigned int index) = 0;
|
virtual bool DoConsume(const std::string& arg, unsigned int index) = 0;
|
||||||
|
@ -128,8 +129,12 @@ class cmCAString : public cmCommandArgument
|
||||||
|
|
||||||
/// Return the string
|
/// Return the string
|
||||||
const std::string& GetString() const {return this->String;}
|
const std::string& GetString() const {return this->String;}
|
||||||
|
const char* GetCString() const {return this->String.c_str();}
|
||||||
|
void SetDefaultString(const char* text)
|
||||||
|
{this->DefaultString = (text ? text : "");}
|
||||||
private:
|
private:
|
||||||
std::string String;
|
std::string String;
|
||||||
|
std::string DefaultString;
|
||||||
unsigned int DataStart;
|
unsigned int DataStart;
|
||||||
virtual bool DoConsume(const std::string& arg, unsigned int index);
|
virtual bool DoConsume(const std::string& arg, unsigned int index);
|
||||||
virtual void DoReset();
|
virtual void DoReset();
|
||||||
|
@ -197,7 +202,6 @@ class cmCommandArgumentsHelper
|
||||||
/// Parse the argument list
|
/// Parse the argument list
|
||||||
void Parse(const std::vector<std::string>* args,
|
void Parse(const std::vector<std::string>* args,
|
||||||
std::vector<std::string>* unconsumedArgs);
|
std::vector<std::string>* unconsumedArgs);
|
||||||
|
|
||||||
/// Add an argument.
|
/// Add an argument.
|
||||||
void AddArgument(cmCommandArgument* arg);
|
void AddArgument(cmCommandArgument* arg);
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue