2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2006-12-01 21:35:21 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2006-12-01 21:35:21 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2006-12-01 21:35:21 +03:00
|
|
|
#include "cmPropertyMap.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmState.h"
|
2006-12-01 21:35:21 +03:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
|
2015-06-06 10:41:20 +03:00
|
|
|
#include <assert.h>
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name)
|
2006-12-01 21:35:21 +03:00
|
|
|
{
|
|
|
|
cmPropertyMap::iterator it = this->find(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmProperty* prop;
|
|
|
|
if (it == this->end()) {
|
2006-12-01 21:35:21 +03:00
|
|
|
prop = &(*this)[name];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-12-01 21:35:21 +03:00
|
|
|
prop = &(it->second);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-12-01 21:35:21 +03:00
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmPropertyMap::SetProperty(const std::string& name, const char* value)
|
2006-12-01 21:35:21 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!value) {
|
2007-03-13 21:23:08 +03:00
|
|
|
this->erase(name);
|
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-12-01 21:35:21 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmProperty* prop = this->GetOrCreateProperty(name);
|
2015-06-06 10:46:26 +03:00
|
|
|
prop->Set(value);
|
2006-12-01 21:35:21 +03:00
|
|
|
}
|
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
|
2015-06-06 10:41:15 +03:00
|
|
|
bool asString)
|
2008-01-18 02:13:55 +03:00
|
|
|
{
|
|
|
|
// Skip if nothing to append.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!value || !*value) {
|
2008-01-18 02:13:55 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-18 02:13:55 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmProperty* prop = this->GetOrCreateProperty(name);
|
|
|
|
prop->Append(value, asString);
|
2008-01-18 02:13:55 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
|
2012-08-13 21:42:58 +04:00
|
|
|
{
|
2015-06-06 10:41:20 +03:00
|
|
|
assert(!name.empty());
|
2006-12-01 21:35:21 +03:00
|
|
|
|
|
|
|
cmPropertyMap::const_iterator it = this->find(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (it == this->end()) {
|
2006-12-01 21:35:21 +03:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-12-01 21:35:21 +03:00
|
|
|
return it->second.GetValue();
|
|
|
|
}
|