浏览代码

cmIDEOptions: Add SpaceAppendable flag table type

Brad King 8 年之前
父节点
当前提交
3936a2886e
共有 3 个文件被更改,包括 22 次插入0 次删除
  1. 3 0
      Source/cmIDEFlagTable.h
  2. 8 0
      Source/cmIDEOptions.cxx
  3. 11 0
      Source/cmIDEOptions.h

+ 3 - 0
Source/cmIDEFlagTable.h

@@ -24,6 +24,9 @@ struct cmIDEFlagTable
                                     // IgnoreDefaultLibraryNames)
                                     // IgnoreDefaultLibraryNames)
     UserFollowing = (1 << 5),       // expect value in following argument
     UserFollowing = (1 << 5),       // expect value in following argument
     CaseInsensitive = (1 << 6),     // flag may be any case
     CaseInsensitive = (1 << 6),     // flag may be any case
+    SpaceAppendable = (1 << 7),     // a flag that if specified multiple times
+                                    // should have its value appended to the
+                                    // old value with spaces
 
 
     UserValueIgnored = UserValue | UserIgnored,
     UserValueIgnored = UserValue | UserIgnored,
     UserValueRequired = UserValue | UserRequired
     UserValueRequired = UserValue | UserRequired

+ 8 - 0
Source/cmIDEOptions.cxx

@@ -125,6 +125,8 @@ void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry,
     this->FlagMap[entry->IDEName] = entry->value;
     this->FlagMap[entry->IDEName] = entry->value;
   } else if (entry->special & cmIDEFlagTable::SemicolonAppendable) {
   } else if (entry->special & cmIDEFlagTable::SemicolonAppendable) {
     this->FlagMap[entry->IDEName].push_back(new_value);
     this->FlagMap[entry->IDEName].push_back(new_value);
+  } else if (entry->special & cmIDEFlagTable::SpaceAppendable) {
+    this->FlagMap[entry->IDEName].append_with_space(new_value);
   } else {
   } else {
     // Use the user-specified value.
     // Use the user-specified value.
     this->FlagMap[entry->IDEName] = new_value;
     this->FlagMap[entry->IDEName] = new_value;
@@ -172,6 +174,12 @@ void cmIDEOptions::AppendFlag(std::string const& flag,
   std::copy(value.begin(), value.end(), std::back_inserter(fv));
   std::copy(value.begin(), value.end(), std::back_inserter(fv));
 }
 }
 
 
+void cmIDEOptions::AppendFlagString(std::string const& flag,
+                                    std::string const& value)
+{
+  this->FlagMap[flag].append_with_space(value);
+}
+
 void cmIDEOptions::RemoveFlag(const char* flag)
 void cmIDEOptions::RemoveFlag(const char* flag)
 {
 {
   this->FlagMap.erase(flag);
   this->FlagMap.erase(flag);

+ 11 - 0
Source/cmIDEOptions.h

@@ -29,6 +29,7 @@ public:
   void AppendFlag(std::string const& flag, std::string const& value);
   void AppendFlag(std::string const& flag, std::string const& value);
   void AppendFlag(std::string const& flag,
   void AppendFlag(std::string const& flag,
                   std::vector<std::string> const& value);
                   std::vector<std::string> const& value);
+  void AppendFlagString(std::string const& flag, std::string const& value);
   void RemoveFlag(const char* flag);
   void RemoveFlag(const char* flag);
   bool HasFlag(std::string const& flag) const;
   bool HasFlag(std::string const& flag) const;
   const char* GetFlag(const char* flag);
   const char* GetFlag(const char* flag);
@@ -57,6 +58,16 @@ protected:
       this->derived::operator=(r);
       this->derived::operator=(r);
       return *this;
       return *this;
     }
     }
+    FlagValue& append_with_space(std::string const& r)
+    {
+      this->resize(1);
+      std::string& l = this->operator[](0);
+      if (!l.empty()) {
+        l += " ";
+      }
+      l += r;
+      return *this;
+    }
   };
   };
   std::map<std::string, FlagValue> FlagMap;
   std::map<std::string, FlagValue> FlagMap;