Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmPropertyMap.cxx
blob53fbae3eab017a15d5d41f460b21741d545b1a7e
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmPropertyMap.cxx,v $
5 Language: C++
6 Date: $Date: 2008/01/17 23:13:55 $
7 Version: $Revision: 1.11 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmPropertyMap.h"
18 #include "cmSystemTools.h"
19 #include "cmake.h"
21 cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
23 cmPropertyMap::iterator it = this->find(name);
24 cmProperty *prop;
25 if (it == this->end())
27 prop = &(*this)[name];
29 else
31 prop = &(it->second);
33 return prop;
36 void cmPropertyMap::SetProperty(const char *name, const char *value,
37 cmProperty::ScopeType scope)
39 if (!name)
41 return;
43 if(!value)
45 this->erase(name);
46 return;
48 #ifdef CMAKE_STRICT
49 if (!this->CMakeInstance)
51 cmSystemTools::Error("CMakeInstance not set on a property map!");
52 abort();
54 else
56 this->CMakeInstance->RecordPropertyAccess(name,scope);
58 #else
59 (void)scope;
60 #endif
62 cmProperty *prop = this->GetOrCreateProperty(name);
63 prop->Set(name,value);
66 void cmPropertyMap::AppendProperty(const char* name, const char* value,
67 cmProperty::ScopeType scope)
69 // Skip if nothing to append.
70 if(!name || !value || !*value)
72 return;
74 #ifdef CMAKE_STRICT
75 if (!this->CMakeInstance)
77 cmSystemTools::Error("CMakeInstance not set on a property map!");
78 abort();
80 else
82 this->CMakeInstance->RecordPropertyAccess(name,scope);
84 #else
85 (void)scope;
86 #endif
88 cmProperty *prop = this->GetOrCreateProperty(name);
89 prop->Append(name,value);
92 const char *cmPropertyMap
93 ::GetPropertyValue(const char *name,
94 cmProperty::ScopeType scope,
95 bool &chain) const
97 chain = false;
98 if (!name)
100 return 0;
103 // has the property been defined?
104 #ifdef CMAKE_STRICT
105 if (!this->CMakeInstance)
107 cmSystemTools::Error("CMakeInstance not set on a property map!");
108 abort();
110 else
112 this->CMakeInstance->RecordPropertyAccess(name,scope);
114 #endif
116 cmPropertyMap::const_iterator it = this->find(name);
117 if (it == this->end())
119 // should we chain up?
120 if (this->CMakeInstance)
122 chain = this->CMakeInstance->IsPropertyChained(name,scope);
124 return 0;
126 return it->second.GetValue();