summaryrefslogtreecommitdiffstats
path: root/Source/cmCacheManager.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2001-04-26 18:53:44 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2001-04-26 18:53:44 (GMT)
commit2c1fb789d7a182ab0df53aad474a657d59d894b0 (patch)
tree3f4db8d752a6f3a218e92ad470efb97b5e7421c7 /Source/cmCacheManager.cxx
parent6e5af0e6ccbb0f2c0a4aec00003ea0ce68ea2f95 (diff)
downloadCMake-2c1fb789d7a182ab0df53aad474a657d59d894b0.zip
CMake-2c1fb789d7a182ab0df53aad474a657d59d894b0.tar.gz
CMake-2c1fb789d7a182ab0df53aad474a657d59d894b0.tar.bz2
ENH: add help for cache entries
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r--Source/cmCacheManager.cxx77
1 files changed, 63 insertions, 14 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 2424526..e6b31e8 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -88,6 +88,15 @@ bool cmCacheManager::LoadCache(const char* path)
{
continue;
}
+ while(buffer[0] == '/')
+ {
+ e.m_HelpString += &buffer[2];
+ fin.getline(buffer, bsize);
+ if(!fin)
+ {
+ continue;
+ }
+ }
if(reg.find(buffer))
{
e.m_Type = cmCacheManager::StringToType(reg.match(2).c_str());
@@ -135,11 +144,13 @@ bool cmCacheManager::SaveCache(const char* path) const
for( std::map<std::string, CacheEntry>::const_iterator i = m_Cache.begin();
i != m_Cache.end(); ++i)
{
- CacheEntryType t = (*i).second.m_Type;
+ const CacheEntry& ce = (*i).second;
+ CacheEntryType t = ce.m_Type;
// Format is key:type=value
+ cmCacheManager::OutputHelpString(fout, ce.m_HelpString);
fout << (*i).first.c_str() << ":"
<< cmCacheManagerTypes[t] << "="
- << (*i).second.m_Value << "\n";
+ << ce.m_Value << "\n";
}
fout << "\n";
fout.close();
@@ -149,21 +160,46 @@ bool cmCacheManager::SaveCache(const char* path) const
return true;
}
-void cmCacheManager::RemoveCacheEntry(const char* key)
+void cmCacheManager::OutputHelpString(std::ofstream& fout,
+ const std::string& helpString)
{
- m_Cache.erase(key);
+ std::string::size_type end = helpString.size();
+ if(end == 0)
+ {
+ return;
+ }
+ std::string oneLine;
+ std::string::size_type pos = 0;
+ std::string::size_type nextBreak = 60;
+ bool done = false;
+
+ while(!done)
+ {
+ if(nextBreak >= end)
+ {
+ nextBreak = end;
+ done = true;
+ }
+ else
+ {
+ while(nextBreak < end && helpString[nextBreak] != ' ')
+ {
+ nextBreak++;
+ }
+ }
+ oneLine = helpString.substr(pos, nextBreak - pos);
+ fout << "//" << oneLine.c_str() << "\n";
+ pos = nextBreak;
+ nextBreak += 60;
+ }
}
-void cmCacheManager::AddCacheEntry(const char* key,
- const char* value,
- CacheEntryType type)
+void cmCacheManager::RemoveCacheEntry(const char* key)
{
- CacheEntry e;
- e.m_Value = value;
- e.m_Type = type;
- m_Cache[key] = e;
+ m_Cache.erase(key);
}
+
cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key)
{
if(m_Cache.count(key))
@@ -210,15 +246,28 @@ void cmCacheManager::PrintCache(std::ostream& out) const
}
-void cmCacheManager::AddCacheEntry(const char* key, bool v)
+void cmCacheManager::AddCacheEntry(const char* key,
+ const char* value,
+ const char* helpString,
+ CacheEntryType type)
+{
+ CacheEntry e;
+ e.m_Value = value;
+ e.m_Type = type;
+ e.m_HelpString = helpString;
+ m_Cache[key] = e;
+}
+
+void cmCacheManager::AddCacheEntry(const char* key, bool v,
+ const char* helpString)
{
if(v)
{
- this->AddCacheEntry(key, "ON", cmCacheManager::BOOL);
+ this->AddCacheEntry(key, "ON", helpString, cmCacheManager::BOOL);
}
else
{
- this->AddCacheEntry(key, "OFF", cmCacheManager::BOOL);
+ this->AddCacheEntry(key, "OFF", helpString, cmCacheManager::BOOL);
}
}