cmake/Source/cmPropertyMap.cxx

65 lines
1.6 KiB
C++
Raw Normal View History

2009-10-04 10:30:41 +03:00
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
2009-10-04 10:30:41 +03:00
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
2009-10-04 10:30:41 +03: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.
============================================================================*/
#include "cmPropertyMap.h"
2016-07-09 11:21:54 +02:00
#include "cmState.h"
#include "cmSystemTools.h"
#include "cmake.h"
2015-11-17 17:22:37 +01:00
#include <assert.h>
2016-07-09 11:21:54 +02:00
cmProperty* cmPropertyMap::GetOrCreateProperty(const std::string& name)
{
cmPropertyMap::iterator it = this->find(name);
2016-07-09 11:21:54 +02:00
cmProperty* prop;
if (it == this->end()) {
prop = &(*this)[name];
2016-07-09 11:21:54 +02:00
} else {
prop = &(it->second);
2016-07-09 11:21:54 +02:00
}
return prop;
}
2016-07-09 11:21:54 +02:00
void cmPropertyMap::SetProperty(const std::string& name, const char* value)
{
2016-07-09 11:21:54 +02:00
if (!value) {
this->erase(name);
return;
2016-07-09 11:21:54 +02:00
}
2016-07-09 11:21:54 +02:00
cmProperty* prop = this->GetOrCreateProperty(name);
2015-11-17 17:22:37 +01:00
prop->Set(value);
}
2015-04-27 22:25:09 +02:00
void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
2015-11-17 17:22:37 +01:00
bool asString)
{
// Skip if nothing to append.
2016-07-09 11:21:54 +02:00
if (!value || !*value) {
return;
2016-07-09 11:21:54 +02:00
}
2016-07-09 11:21:54 +02:00
cmProperty* prop = this->GetOrCreateProperty(name);
prop->Append(value, asString);
}
2016-07-09 11:21:54 +02:00
const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
2013-03-16 19:13:01 +02:00
{
2015-11-17 17:22:37 +01:00
assert(!name.empty());
cmPropertyMap::const_iterator it = this->find(name);
2016-07-09 11:21:54 +02:00
if (it == this->end()) {
return 0;
2016-07-09 11:21:54 +02:00
}
return it->second.GetValue();
}