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"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmake.h"
|
2015-04-05 00:33:26 +03:00
|
|
|
#include "cmState.h"
|
2006-12-01 21:35:21 +03:00
|
|
|
|
2015-06-06 10:41:20 +03:00
|
|
|
#include <assert.h>
|
|
|
|
|
2013-09-03 00:27:32 +04:00
|
|
|
cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name)
|
2006-12-01 21:35:21 +03:00
|
|
|
{
|
|
|
|
cmPropertyMap::iterator it = this->find(name);
|
|
|
|
cmProperty *prop;
|
|
|
|
if (it == this->end())
|
|
|
|
{
|
|
|
|
prop = &(*this)[name];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prop = &(it->second);
|
|
|
|
}
|
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
|
2015-06-06 10:41:15 +03:00
|
|
|
void cmPropertyMap::SetProperty(const std::string& name, const char *value)
|
2006-12-01 21:35:21 +03:00
|
|
|
{
|
2007-03-13 21:23:08 +03:00
|
|
|
if(!value)
|
|
|
|
{
|
|
|
|
this->erase(name);
|
|
|
|
return;
|
|
|
|
}
|
2006-12-01 21:35:21 +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.
|
2013-09-03 00:27:32 +04:00
|
|
|
if(!value || !*value)
|
2008-01-18 02:13:55 +03:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmProperty *prop = this->GetOrCreateProperty(name);
|
2015-06-06 10:46:26 +03:00
|
|
|
prop->Append(value,asString);
|
2008-01-18 02:13:55 +03:00
|
|
|
}
|
|
|
|
|
2006-12-01 21:35:21 +03:00
|
|
|
const char *cmPropertyMap
|
2015-06-06 10:41:30 +03:00
|
|
|
::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);
|
|
|
|
if (it == this->end())
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return it->second.GetValue();
|
|
|
|
}
|
|
|
|
|