diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-02-25 01:24:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-08 18:05:39 (GMT) |
commit | 94fc63e2d5402bc4fa570a92e1f5fe6aba088392 (patch) | |
tree | 1d031c69fe143462a9dc581c8ace15862c89e7ee /Source | |
parent | 85fc9f26a703f28b356c93d405446c39bba43846 (diff) | |
download | CMake-94fc63e2d5402bc4fa570a92e1f5fe6aba088392.zip CMake-94fc63e2d5402bc4fa570a92e1f5fe6aba088392.tar.gz CMake-94fc63e2d5402bc4fa570a92e1f5fe6aba088392.tar.bz2 |
stringapi: Use strings for cache iterator values
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CursesDialog/cmCursesCacheEntryComposite.cxx | 5 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 12 | ||||
-rw-r--r-- | Source/cmCacheManager.h | 6 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 8 | ||||
-rw-r--r-- | Source/cmOptionCommand.cxx | 5 |
5 files changed, 19 insertions, 17 deletions
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 7929ce7..682f95f 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -51,7 +51,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( { case cmCacheManager::BOOL: this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1); - if (cmSystemTools::IsOn(it.GetValue())) + if (cmSystemTools::IsOn(it.GetValue().c_str())) { static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true); } @@ -94,7 +94,8 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( } break; case cmCacheManager::UNINITIALIZED: - cmSystemTools::Error("Found an undefined variable: ", it.GetName()); + cmSystemTools::Error("Found an undefined variable: ", + it.GetName().c_str()); break; default: // TODO : put warning message here diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 0fe5f8c..12da320 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -111,7 +111,7 @@ void QCMake::setBinaryDirectory(const QString& _dir) cmCacheManager::CacheIterator itm = cachem->NewIterator(); if ( itm.Find("CMAKE_HOME_DIRECTORY")) { - setSourceDirectory(QString::fromLocal8Bit(itm.GetValue())); + setSourceDirectory(QString::fromLocal8Bit(itm.GetValue().c_str())); } if ( itm.Find("CMAKE_GENERATOR")) { @@ -201,11 +201,11 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i.GetName()); + prop.Key = QString::fromLocal8Bit(i.GetName().c_str()); int idx = props.indexOf(prop); if(idx == -1) { - toremove.append(QString::fromLocal8Bit(i.GetName())); + toremove.append(QString::fromLocal8Bit(i.GetName().c_str())); } else { @@ -286,15 +286,15 @@ QCMakePropertyList QCMake::properties() const } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i.GetName()); + prop.Key = QString::fromLocal8Bit(i.GetName().c_str()); prop.Help = QString::fromLocal8Bit(i.GetProperty("HELPSTRING")); - prop.Value = QString::fromLocal8Bit(i.GetValue()); + prop.Value = QString::fromLocal8Bit(i.GetValue().c_str()); prop.Advanced = i.GetPropertyAsBool("ADVANCED"); if(i.GetType() == cmCacheManager::BOOL) { prop.Type = QCMakeProperty::BOOL; - prop.Value = cmSystemTools::IsOn(i.GetValue()); + prop.Value = cmSystemTools::IsOn(i.GetValue().c_str()); } else if(i.GetType() == cmCacheManager::PATH) { diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 07a8675..d9a9112 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -56,8 +56,8 @@ public: bool Find(const std::string&); bool IsAtEnd() const; void Next(); - const char *GetName() const { - return this->Position->first.c_str(); } + std::string GetName() const { + return this->Position->first; } const char* GetProperty(const std::string&) const ; bool GetPropertyAsBool(const std::string&) const ; bool PropertyExists(const std::string&) const; @@ -65,7 +65,7 @@ public: void AppendProperty(const std::string& property, const char* value, bool asString=false); void SetProperty(const std::string& property, bool value); - const char* GetValue() const { return this->GetEntry().Value.c_str(); } + std::string GetValue() const { return this->GetEntry().Value; } bool GetValueAsBool() const; void SetValue(const char*); CacheEntryType GetType() const { return this->GetEntry().Type; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e8be29f..a083c78 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1796,7 +1796,8 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, cmCacheManager::CacheEntryType type, bool force) { - const char* val = value; + bool haveVal = value ? true : false; + std::string val = haveVal ? value : ""; cmCacheManager::CacheIterator it = this->GetCacheManager()->GetCacheIterator(name.c_str()); if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) && @@ -1807,6 +1808,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, if(!force) { val = it.GetValue(); + haveVal = true; } if ( type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH ) { @@ -1829,10 +1831,12 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, this->GetCacheManager()->AddCacheEntry(name, nvalue.c_str(), doc, type); val = it.GetValue(); + haveVal = true; } } - this->GetCacheManager()->AddCacheEntry(name, val, doc, type); + this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc, + type); // if there was a definition then remove it this->Internal->VarStack.top().Set(name, 0); } diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index 776a3a4..dbe2478 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -55,10 +55,7 @@ bool cmOptionCommand it.SetProperty("HELPSTRING", args[1].c_str()); return true; } - if ( it.GetValue() ) - { - initialValue = it.GetValue(); - } + initialValue = it.GetValue(); } if(args.size() == 3) { |