2016-09-27 15:01:08 -04:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2006-12-01 13:35:21 -05:00
|
|
|
#include "cmPropertyMap.h"
|
2016-04-29 09:40:20 -04:00
|
|
|
|
2017-04-11 22:00:21 +02:00
|
|
|
#include "cmConfigure.h"
|
2016-06-10 09:34:14 +02:00
|
|
|
#include <algorithm>
|
2015-06-06 09:41:20 +02:00
|
|
|
#include <assert.h>
|
2016-08-24 00:29:15 +02:00
|
|
|
#include <utility>
|
2015-06-06 09:41:20 +02:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name)
|
2006-12-01 13:35:21 -05:00
|
|
|
{
|
|
|
|
cmPropertyMap::iterator it = this->find(name);
|
2016-05-16 10:34:04 -04:00
|
|
|
cmProperty* prop;
|
|
|
|
if (it == this->end()) {
|
2006-12-01 13:35:21 -05:00
|
|
|
prop = &(*this)[name];
|
2016-05-16 10:34:04 -04:00
|
|
|
} else {
|
2006-12-01 13:35:21 -05:00
|
|
|
prop = &(it->second);
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2006-12-01 13:35:21 -05:00
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2016-06-10 09:34:14 +02:00
|
|
|
std::vector<std::string> cmPropertyMap::GetPropertyList() const
|
|
|
|
{
|
|
|
|
std::vector<std::string> keyList;
|
|
|
|
for (cmPropertyMap::const_iterator i = this->begin(), e = this->end();
|
|
|
|
i != e; ++i) {
|
|
|
|
keyList.push_back(i->first);
|
|
|
|
}
|
|
|
|
std::sort(keyList.begin(), keyList.end());
|
|
|
|
return keyList;
|
|
|
|
}
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
void cmPropertyMap::SetProperty(const std::string& name, const char* value)
|
2006-12-01 13:35:21 -05:00
|
|
|
{
|
2016-05-16 10:34:04 -04:00
|
|
|
if (!value) {
|
2007-03-13 14:23:08 -04:00
|
|
|
this->erase(name);
|
|
|
|
return;
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2006-12-01 13:35:21 -05:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
cmProperty* prop = this->GetOrCreateProperty(name);
|
2015-06-06 09:46:26 +02:00
|
|
|
prop->Set(value);
|
2006-12-01 13:35:21 -05:00
|
|
|
}
|
|
|
|
|
2013-09-02 16:27:32 -04:00
|
|
|
void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
|
2015-06-06 09:41:15 +02:00
|
|
|
bool asString)
|
2008-01-17 18:13:55 -05:00
|
|
|
{
|
|
|
|
// Skip if nothing to append.
|
2016-05-16 10:34:04 -04:00
|
|
|
if (!value || !*value) {
|
2008-01-17 18:13:55 -05:00
|
|
|
return;
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2008-01-17 18:13:55 -05:00
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
cmProperty* prop = this->GetOrCreateProperty(name);
|
|
|
|
prop->Append(value, asString);
|
2008-01-17 18:13:55 -05:00
|
|
|
}
|
|
|
|
|
2016-05-16 10:34:04 -04:00
|
|
|
const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
|
2012-08-13 13:42:58 -04:00
|
|
|
{
|
2015-06-06 09:41:20 +02:00
|
|
|
assert(!name.empty());
|
2006-12-01 13:35:21 -05:00
|
|
|
|
|
|
|
cmPropertyMap::const_iterator it = this->find(name);
|
2016-05-16 10:34:04 -04:00
|
|
|
if (it == this->end()) {
|
2016-06-27 22:44:16 +02:00
|
|
|
return CM_NULLPTR;
|
2016-05-16 10:34:04 -04:00
|
|
|
}
|
2006-12-01 13:35:21 -05:00
|
|
|
return it->second.GetValue();
|
|
|
|
}
|