[Cmake-commits] [cmake-commits] king committed cmCacheManager.cxx 1.104 1.105 cmCacheManager.h 1.49 1.50 cmProperty.h 1.3 1.4 cmPropertyDefinitionMap.cxx 1.5 1.6

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Mar 10 11:10:45 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv23804/Source

Modified Files:
	cmCacheManager.cxx cmCacheManager.h cmProperty.h 
	cmPropertyDefinitionMap.cxx 
Log Message:
ENH: Use cmPropertyMap for cache properties

This re-implements cache entry property storage in cmCacheManager to use
cmPropertyMap so it can share the standard property implementation.


Index: cmPropertyDefinitionMap.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPropertyDefinitionMap.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -C 2 -d -r1.5 -r1.6
*** cmPropertyDefinitionMap.cxx	23 Oct 2007 14:40:49 -0000	1.5
--- cmPropertyDefinitionMap.cxx	10 Mar 2009 15:10:42 -0000	1.6
***************
*** 70,73 ****
--- 70,76 ----
            secName = "Properties on Tests";
            break;
+         case cmProperty::CACHE:
+           secName = "Properties on Cache Entries";
+           break;
          case cmProperty::VARIABLE:
            secName = "Variables";

Index: cmCacheManager.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCacheManager.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -C 2 -d -r1.49 -r1.50
*** cmCacheManager.h	7 Mar 2008 16:43:47 -0000	1.49
--- cmCacheManager.h	10 Mar 2009 15:10:42 -0000	1.50
***************
*** 19,22 ****
--- 19,23 ----
  
  #include "cmStandardIncludes.h"
+ #include "cmPropertyMap.h"
  class cmMakefile;
  class cmMarkAsAdvancedCommand;
***************
*** 42,46 ****
      std::string Value;
      CacheEntryType Type;
!     std::map<cmStdString,cmStdString> Properties;
      bool Initialized;
      CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false)
--- 43,50 ----
      std::string Value;
      CacheEntryType Type;
!     cmPropertyMap Properties;
!     const char* GetProperty(const char*) const;
!     void SetProperty(const char* property, const char* value);
!     void AppendProperty(const char* property, const char* value);
      bool Initialized;
      CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false)
***************
*** 62,65 ****
--- 66,70 ----
      bool PropertyExists(const char*) const;
      void SetProperty(const char* property, const char* value);
+     void AppendProperty(const char* property, const char* value);
      void SetProperty(const char* property, bool value);
      const char* GetValue() const { return this->GetEntry().Value.c_str(); }

Index: cmProperty.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmProperty.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C 2 -d -r1.3 -r1.4
*** cmProperty.h	17 Jan 2008 23:13:55 -0000	1.3
--- cmProperty.h	10 Mar 2009 15:10:42 -0000	1.4
***************
*** 23,27 ****
  {
  public:
!   enum ScopeType { TARGET, SOURCE_FILE, DIRECTORY, GLOBAL, 
                     TEST, VARIABLE, CACHED_VARIABLE };
  
--- 23,27 ----
  {
  public:
!   enum ScopeType { TARGET, SOURCE_FILE, DIRECTORY, GLOBAL, CACHE,
                     TEST, VARIABLE, CACHED_VARIABLE };
  

Index: cmCacheManager.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCacheManager.cxx,v
retrieving revision 1.104
retrieving revision 1.105
diff -C 2 -d -r1.104 -r1.105
*** cmCacheManager.cxx	5 Mar 2009 20:17:06 -0000	1.104
--- cmCacheManager.cxx	10 Mar 2009 15:10:41 -0000	1.105
***************
*** 213,216 ****
--- 213,217 ----
      {
      // Format is key:type=value
+     std::string helpString;
      CacheEntry e;
      cmSystemTools::GetLineFromStream(fin, buffer);
***************
*** 233,242 ****
        if ((realbuffer[2] == '\\') && (realbuffer[3]=='n'))
          {
!         e.Properties["HELPSTRING"] += "\n";
!         e.Properties["HELPSTRING"] += &realbuffer[4];
          }
        else
          {
!         e.Properties["HELPSTRING"] += &realbuffer[2];
          }
        cmSystemTools::GetLineFromStream(fin, buffer);
--- 234,243 ----
        if ((realbuffer[2] == '\\') && (realbuffer[3]=='n'))
          {
!         helpString += "\n";
!         helpString += &realbuffer[4];
          }
        else
          {
!         helpString += &realbuffer[2];
          }
        cmSystemTools::GetLineFromStream(fin, buffer);
***************
*** 247,250 ****
--- 248,252 ----
          }
        }
+     e.SetProperty("HELPSTRING", helpString.c_str());
      if(cmCacheManager::ParseEntry(realbuffer, entryKey, e.Value, e.Type))
        {
***************
*** 264,273 ****
              {
              e.Type = INTERNAL;
!             e.Properties["HELPSTRING"] = "DO NOT EDIT, ";
!             e.Properties["HELPSTRING"] += entryKey;
!             e.Properties["HELPSTRING"] += " loaded from external file.  "
                "To change this value edit this file: ";
!             e.Properties["HELPSTRING"] += path;
!             e.Properties["HELPSTRING"] += "/CMakeCache.txt"   ;
              }
            if ( e.Type == cmCacheManager::INTERNAL &&
--- 266,276 ----
              {
              e.Type = INTERNAL;
!             helpString = "DO NOT EDIT, ";
!             helpString += entryKey;
!             helpString += " loaded from external file.  "
                "To change this value edit this file: ";
!             helpString += path;
!             helpString += "/CMakeCache.txt"   ;
!             e.SetProperty("HELPSTRING", helpString.c_str());
              }
            if ( e.Type == cmCacheManager::INTERNAL &&
***************
*** 473,485 ****
        {
        // Format is key:type=value
!       std::map<cmStdString,cmStdString>::const_iterator it = 
!         ce.Properties.find("HELPSTRING");
!       if ( it == ce.Properties.end() )
          {
!         cmCacheManager::OutputHelpString(fout, "Missing description");
          }
        else
          {
!         cmCacheManager::OutputHelpString(fout, it->second);
          }
        std::string key;
--- 476,486 ----
        {
        // Format is key:type=value
!       if(const char* help = ce.GetProperty("HELPSTRING"))
          {
!         cmCacheManager::OutputHelpString(fout, help);
          }
        else
          {
!         cmCacheManager::OutputHelpString(fout, "Missing description");
          }
        std::string key;
***************
*** 804,816 ****
        }
      }
!   if ( helpString )
!     {
!     e.Properties["HELPSTRING"] = helpString;
!     }
!   else
!     {
!     e.Properties["HELPSTRING"] = 
!       "(This variable does not exist and should not be used)";
!     }
    this->Cache[key] = e;
  }
--- 805,810 ----
        }
      }
!   e.SetProperty("HELPSTRING", helpString? helpString :
!                 "(This variable does not exist and should not be used)");
    this->Cache[key] = e;
  }
***************
*** 871,989 ****
  }
  
! const char* cmCacheManager::CacheIterator::GetProperty(
!   const char* property) const
  {
!   // make sure it is not at the end
!   if (this->IsAtEnd())
!     {
!     return 0;
!     }
  
!   if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") )
      {
!     cmSystemTools::Error("Property \"", property,
!                          "\" cannot be accessed through the GetProperty()");
!     return 0;
      }
!   const CacheEntry* ent = &this->GetEntry();
!   std::map<cmStdString,cmStdString>::const_iterator it = 
!     ent->Properties.find(property);
!   if ( it == ent->Properties.end() )
      {
!     return 0;
      }
!   return it->second.c_str();
  }
  
! void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
  {
!   // make sure it is not at the end
!   if (this->IsAtEnd())
      {
!     return;
      }
! 
!   if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") )
      {
!     cmSystemTools::Error("Property \"", p,
!                          "\" cannot be accessed through the SetProperty()");
!     return;
      }
-   CacheEntry* ent = &this->GetEntry();
-   ent->Properties[p] = v;
- }
- 
- 
- bool cmCacheManager::CacheIterator::GetValueAsBool() const 
- { 
-   return cmSystemTools::IsOn(this->GetEntry().Value.c_str()); 
  }
  
! bool cmCacheManager::CacheIterator::GetPropertyAsBool(
!   const char* property) const
  {
!   // make sure it is not at the end
!   if (this->IsAtEnd())
      {
!     return false;
      }
! 
!   if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") )
      {
!     cmSystemTools::Error("Property \"", property,
!       "\" cannot be accessed through the GetPropertyAsBool()");
!     return false;
      }
!   const CacheEntry* ent = &this->GetEntry();
!   std::map<cmStdString,cmStdString>::const_iterator it = 
!     ent->Properties.find(property);
!   if ( it == ent->Properties.end() )
      {
!     return false;
      }
-   return cmSystemTools::IsOn(it->second.c_str());
  }
  
! 
! void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v)
  {
!   // make sure it is not at the end
!   if (this->IsAtEnd())
      {
!     return;
      }
  
!   if ( !strcmp(p, "TYPE") || !strcmp(p, "VALUE") )
      {
!     cmSystemTools::Error("Property \"", p,
!                          "\" cannot be accessed through the SetProperty()");
!     return;
      }
-   CacheEntry* ent = &this->GetEntry();
-   ent->Properties[p] = v ? "ON" : "OFF";
  }
  
! bool cmCacheManager::CacheIterator::PropertyExists(const char* property) const
  {
!   // make sure it is not at the end
!   if (this->IsAtEnd())
      {
!     return false;
      }
  
!   if ( !strcmp(property, "TYPE") || !strcmp(property, "VALUE") )
!     {
!     cmSystemTools::Error("Property \"", property,
!       "\" cannot be accessed through the PropertyExists()");
!     return false;
!     }
!   const CacheEntry* ent = &this->GetEntry();
!   std::map<cmStdString,cmStdString>::const_iterator it = 
!     ent->Properties.find(property);
!   if ( it == ent->Properties.end() )
      {
!     return false;
      }
!   return true;
  }
  
--- 865,983 ----
  }
  
! //----------------------------------------------------------------------------
! bool cmCacheManager::CacheIterator::GetValueAsBool() const
  {
!   return cmSystemTools::IsOn(this->GetEntry().Value.c_str());
! }
  
! //----------------------------------------------------------------------------
! const char*
! cmCacheManager::CacheEntry::GetProperty(const char* prop) const
! {
!   if(strcmp(prop, "TYPE") == 0)
      {
!     return cmCacheManagerTypes[this->Type];
      }
!   else if(strcmp(prop, "VALUE") == 0)
      {
!     return this->Value.c_str();
      }
!   bool c = false;
!   return
!     this->Properties.GetPropertyValue(prop, cmProperty::CACHE, c);
  }
  
! //----------------------------------------------------------------------------
! void cmCacheManager::CacheEntry::SetProperty(const char* prop,
!                                              const char* value)
  {
!   if(strcmp(prop, "TYPE") == 0)
      {
!     this->Type = cmCacheManager::StringToType(value? value : "STRING");
      }
!   else if(strcmp(prop, "VALUE") == 0)
      {
!     this->Value = value? value : "";
!     }
!   else
!     {
!     this->Properties.SetProperty(prop, value, cmProperty::CACHE);
      }
  }
  
! //----------------------------------------------------------------------------
! void cmCacheManager::CacheEntry::AppendProperty(const char* prop,
!                                                 const char* value)
  {
!   if(strcmp(prop, "TYPE") == 0)
      {
!     this->Type = cmCacheManager::StringToType(value? value : "STRING");
      }
!   else if(strcmp(prop, "VALUE") == 0)
      {
!     if(value)
!       {
!       if(!this->Value.empty() && *value)
!         {
!         this->Value += ";";
!         }
!       this->Value += value;
!       }
      }
!   else
      {
!     this->Properties.AppendProperty(prop, value, cmProperty::CACHE);
      }
  }
  
! //----------------------------------------------------------------------------
! const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const
  {
!   if(!this->IsAtEnd())
      {
!     return this->GetEntry().GetProperty(prop);
      }
+   return 0;
+ }
  
! //----------------------------------------------------------------------------
! void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
! {
!   if(!this->IsAtEnd())
      {
!     return this->GetEntry().SetProperty(p, v);
      }
  }
  
! //----------------------------------------------------------------------------
! void cmCacheManager::CacheIterator::AppendProperty(const char* p,
!                                                    const char* v)
  {
!   if(!this->IsAtEnd())
      {
!     this->GetEntry().AppendProperty(p, v);
      }
+ }
  
! //----------------------------------------------------------------------------
! bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const
! {
!   if(const char* value = this->GetProperty(prop))
      {
!     return cmSystemTools::IsOn(value);
      }
!   return false;
! }
! 
! //----------------------------------------------------------------------------
! void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v)
! {
!   this->SetProperty(p, v ? "ON" : "OFF");
! }
! 
! //----------------------------------------------------------------------------
! bool cmCacheManager::CacheIterator::PropertyExists(const char* prop) const
! {
!   return this->GetProperty(prop)? true:false;
  }
  



More information about the Cmake-commits mailing list