From f2a3dd9d1acb252dd40c35859f9a148c2d0ff823 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 1 Apr 2014 14:54:28 -0400 Subject: [PATCH] cmIDEOptions: Factor FlagMap update out to separate method This will allow it to be re-used in other code paths. --- Source/cmIDEOptions.cxx | 59 ++++++++++++++++++++++------------------- Source/cmIDEOptions.h | 1 + 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index e03223f76..eda1ef676 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -99,33 +99,7 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table, (!(entry->special & cmIDEFlagTable::UserRequired) || static_cast(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::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::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) { diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index 691893f6d..82c1a25ea 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -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; };