cmIDEOptions: Factor FlagMap update out to separate method

This will allow it to be re-used in other code paths.
This commit is contained in:
Brad King 2014-04-01 14:54:28 -04:00
parent 358be9b320
commit f2a3dd9d1a
2 changed files with 33 additions and 27 deletions

View File

@ -99,33 +99,7 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
(!(entry->special & cmIDEFlagTable::UserRequired) ||
static_cast<int>(strlen(flag+1)) > n))
{
if(entry->special & cmIDEFlagTable::UserIgnored)
{
// Ignore the user-specified value.
this->FlagMap[entry->IDEName] = entry->value;
}
else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
{
const char *new_value = flag+1+n;
std::map<std::string,std::string>::iterator itr;
itr = this->FlagMap.find(entry->IDEName);
if(itr != this->FlagMap.end())
{
// Append to old value (if present) with semicolons;
itr->second += ";";
itr->second += new_value;
}
else
{
this->FlagMap[entry->IDEName] = new_value;
}
}
else
{
// Use the user-specified value.
this->FlagMap[entry->IDEName] = flag+1+n;
}
this->FlagMapUpdate(entry, flag+n+1);
entry_found = true;
}
}
@ -150,6 +124,37 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
return false;
}
//----------------------------------------------------------------------------
void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry,
const char* new_value)
{
if(entry->special & cmIDEFlagTable::UserIgnored)
{
// Ignore the user-specified value.
this->FlagMap[entry->IDEName] = entry->value;
}
else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
{
std::map<std::string,std::string>::iterator itr;
itr = this->FlagMap.find(entry->IDEName);
if(itr != this->FlagMap.end())
{
// Append to old value (if present) with semicolons;
itr->second += ";";
itr->second += new_value;
}
else
{
this->FlagMap[entry->IDEName] = new_value;
}
}
else
{
// Use the user-specified value.
this->FlagMap[entry->IDEName] = new_value;
}
}
//----------------------------------------------------------------------------
void cmIDEOptions::AddDefine(const std::string& def)
{

View File

@ -56,6 +56,7 @@ protected:
void HandleFlag(const char* flag);
bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
bool& flag_handled);
void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value);
virtual void StoreUnknownFlag(const char* flag) = 0;
};