diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2013-09-02 16:27:32 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-03-08 13:05:28 -0500 |
commit | ec97ed7d0c67b635caf3ada65541b2eaf0818a93 (patch) | |
tree | 9b38ed2ca59f7da24dfc0db503d9e203ed265fb4 /Source/cmCacheManager.cxx | |
parent | 2977330a7b27d21e2b6276d9386624b6811b9274 (diff) | |
download | cmake-ec97ed7d0c67b635caf3ada65541b2eaf0818a93.tar.gz |
stringapi: Use strings for property names
Property names are always generated by CMake and should never be NULL.
Diffstat (limited to 'Source/cmCacheManager.cxx')
-rw-r--r-- | Source/cmCacheManager.cxx | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 9e0064e5d8..04542d8c93 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -807,13 +807,13 @@ bool cmCacheManager::CacheIterator::GetValueAsBool() const //---------------------------------------------------------------------------- const char* -cmCacheManager::CacheEntry::GetProperty(const char* prop) const +cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const { - if(strcmp(prop, "TYPE") == 0) + if(prop == "TYPE") { return cmCacheManagerTypes[this->Type]; } - else if(strcmp(prop, "VALUE") == 0) + else if(prop == "VALUE") { return this->Value.c_str(); } @@ -823,14 +823,14 @@ cmCacheManager::CacheEntry::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -void cmCacheManager::CacheEntry::SetProperty(const char* prop, +void cmCacheManager::CacheEntry::SetProperty(const std::string& prop, const char* value) { - if(strcmp(prop, "TYPE") == 0) + if(prop == "TYPE") { this->Type = cmCacheManager::StringToType(value? value : "STRING"); } - else if(strcmp(prop, "VALUE") == 0) + else if(prop == "VALUE") { this->Value = value? value : ""; } @@ -841,15 +841,15 @@ void cmCacheManager::CacheEntry::SetProperty(const char* prop, } //---------------------------------------------------------------------------- -void cmCacheManager::CacheEntry::AppendProperty(const char* prop, +void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop, const char* value, bool asString) { - if(strcmp(prop, "TYPE") == 0) + if(prop == "TYPE") { this->Type = cmCacheManager::StringToType(value? value : "STRING"); } - else if(strcmp(prop, "VALUE") == 0) + else if(prop == "VALUE") { if(value) { @@ -867,7 +867,8 @@ void cmCacheManager::CacheEntry::AppendProperty(const char* prop, } //---------------------------------------------------------------------------- -const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const +const char* cmCacheManager::CacheIterator::GetProperty( + const std::string& prop) const { if(!this->IsAtEnd()) { @@ -877,7 +878,8 @@ const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const } //---------------------------------------------------------------------------- -void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) +void cmCacheManager::CacheIterator::SetProperty(const std::string& p, + const char* v) { if(!this->IsAtEnd()) { @@ -886,7 +888,7 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) } //---------------------------------------------------------------------------- -void cmCacheManager::CacheIterator::AppendProperty(const char* p, +void cmCacheManager::CacheIterator::AppendProperty(const std::string& p, const char* v, bool asString) { @@ -897,7 +899,8 @@ void cmCacheManager::CacheIterator::AppendProperty(const char* p, } //---------------------------------------------------------------------------- -bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const +bool cmCacheManager::CacheIterator::GetPropertyAsBool( + const std::string& prop) const { if(const char* value = this->GetProperty(prop)) { @@ -907,13 +910,14 @@ bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const } //---------------------------------------------------------------------------- -void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v) +void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v) { this->SetProperty(p, v ? "ON" : "OFF"); } //---------------------------------------------------------------------------- -bool cmCacheManager::CacheIterator::PropertyExists(const char* prop) const +bool cmCacheManager::CacheIterator::PropertyExists( + const std::string& prop) const { return this->GetProperty(prop)? true:false; } |