summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCacheManager.h')
-rw-r--r--Source/cmCacheManager.h121
1 files changed, 92 insertions, 29 deletions
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index d9a9112..8462259 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -14,6 +14,8 @@
#include "cmStandardIncludes.h"
#include "cmPropertyMap.h"
+#include "cmState.h"
+
class cmMakefile;
class cmMarkAsAdvancedCommand;
class cmake;
@@ -30,21 +32,22 @@ public:
cmCacheManager(cmake* cm);
class CacheIterator;
friend class cmCacheManager::CacheIterator;
- enum CacheEntryType{ BOOL=0, PATH, FILEPATH, STRING, INTERNAL,STATIC,
- UNINITIALIZED };
private:
struct CacheEntry
{
std::string Value;
- CacheEntryType Type;
+ cmState::CacheEntryType Type;
cmPropertyMap Properties;
const char* GetProperty(const std::string&) const;
void SetProperty(const std::string& property, const char* value);
void AppendProperty(const std::string& property, const char* value,
bool asString=false);
bool Initialized;
- CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false)
+ CacheEntry()
+ : Value(""),
+ Type(cmState::UNINITIALIZED),
+ Initialized(false)
{}
};
@@ -65,11 +68,13 @@ public:
void AppendProperty(const std::string& property, const char* value,
bool asString=false);
void SetProperty(const std::string& property, bool value);
- std::string GetValue() const { return this->GetEntry().Value; }
+ const char* GetValue() const { return this->GetEntry().Value.c_str(); }
bool GetValueAsBool() const;
void SetValue(const char*);
- CacheEntryType GetType() const { return this->GetEntry().Type; }
- void SetType(CacheEntryType ty) { this->GetEntry().Type = ty; }
+ cmState::CacheEntryType GetType() const
+ { return this->GetEntry().Type; }
+ void SetType(cmState::CacheEntryType ty)
+ { this->GetEntry().Type = ty; }
bool Initialized() { return this->GetEntry().Initialized; }
cmCacheManager &Container;
std::map<std::string, CacheEntry>::iterator Position;
@@ -94,28 +99,12 @@ public:
return CacheIterator(*this);
}
- /**
- * Types for the cache entries. These are useful as
- * hints for a cache editor program. Path should bring
- * up a file chooser, BOOL a check box, and STRING a
- * text entry box, FILEPATH is a full path to a file which
- * can be different than just a path input
- */
- static CacheEntryType StringToType(const char*);
- static const char* TypeToString(CacheEntryType);
- static bool IsType(const char*);
-
- ///! Load a cache for given makefile. Loads from ouput home.
- bool LoadCache(cmMakefile*);
///! Load a cache for given makefile. Loads from path/CMakeCache.txt.
bool LoadCache(const std::string& path);
- bool LoadCache(const std::string& path, bool internal);
bool LoadCache(const std::string& path, bool internal,
std::set<std::string>& excludes,
std::set<std::string>& includes);
- ///! Save cache for given makefile. Saves to ouput home CMakeCache.txt.
- bool SaveCache(cmMakefile*) ;
///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt
bool SaveCache(const std::string& path) ;
@@ -139,22 +128,97 @@ public:
static bool ParseEntry(const std::string& entry,
std::string& var,
std::string& value,
- CacheEntryType& type);
+ cmState::CacheEntryType& type);
///! Get a value from the cache given a key
- const char* GetCacheValue(const std::string& key) const;
+ const char* GetInitializedCacheValue(const std::string& key) const;
+
+ const char* GetCacheEntryValue(const std::string& key)
+ {
+ cmCacheManager::CacheIterator it = this->GetCacheIterator(key.c_str());
+ if (it.IsAtEnd())
+ {
+ return 0;
+ }
+ return it.GetValue();
+ }
+
+ const char* GetCacheEntryProperty(std::string const& key,
+ std::string const& propName)
+ {
+ return this->GetCacheIterator(key.c_str()).GetProperty(propName);
+ }
+
+ cmState::CacheEntryType GetCacheEntryType(std::string const& key)
+ {
+ return this->GetCacheIterator(key.c_str()).GetType();
+ }
+
+ bool GetCacheEntryPropertyAsBool(std::string const& key,
+ std::string const& propName)
+ {
+ return this->GetCacheIterator(key.c_str()).GetPropertyAsBool(propName);
+ }
+
+ void SetCacheEntryProperty(std::string const& key,
+ std::string const& propName,
+ std::string const& value)
+ {
+ this->GetCacheIterator(key.c_str()).SetProperty(propName, value.c_str());
+ }
+
+ void SetCacheEntryBoolProperty(std::string const& key,
+ std::string const& propName,
+ bool value)
+ {
+ this->GetCacheIterator(key.c_str()).SetProperty(propName, value);
+ }
+
+ void SetCacheEntryValue(std::string const& key,
+ std::string const& value)
+ {
+ this->GetCacheIterator(key.c_str()).SetValue(value.c_str());
+ }
+
+ void RemoveCacheEntryProperty(std::string const& key,
+ std::string const& propName)
+ {
+ this->GetCacheIterator(key.c_str()).SetProperty(propName, (void*)0);
+ }
+
+ void AppendCacheEntryProperty(std::string const& key,
+ std::string const& propName,
+ std::string const& value,
+ bool asString = false)
+ {
+ this->GetCacheIterator(key.c_str()).AppendProperty(propName,
+ value.c_str(),
+ asString);
+ }
+
+ std::vector<std::string> GetCacheEntryKeys()
+ {
+ std::vector<std::string> definitions;
+ definitions.reserve(this->GetSize());
+ cmCacheManager::CacheIterator cit = this->GetCacheIterator();
+ for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
+ {
+ definitions.push_back(cit.GetName());
+ }
+ return definitions;
+ }
/** Get the version of CMake that wrote the cache. */
unsigned int GetCacheMajorVersion() const
{ return this->CacheMajorVersion; }
unsigned int GetCacheMinorVersion() const
{ return this->CacheMinorVersion; }
- bool NeedCacheCompatibility(int major, int minor);
protected:
///! Add an entry into the cache
void AddCacheEntry(const std::string& key, const char* value,
- const char* helpString, CacheEntryType type);
+ const char* helpString,
+ cmState::CacheEntryType type);
///! Get a cache entry object for a key
CacheEntry *GetCacheEntry(const std::string& key);
@@ -179,9 +243,8 @@ private:
CacheEntryMap Cache;
// Only cmake and cmMakefile should be able to add cache values
// the commands should never use the cmCacheManager directly
- friend class cmMakefile; // allow access to add cache values
+ friend class cmState; // allow access to add cache values
friend class cmake; // allow access to add cache values
- friend class cmMarkAsAdvancedCommand; // allow access to add cache values
};
#endif