1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmPropertyMap.cxx,v $
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"
21 cmProperty
*cmPropertyMap::GetOrCreateProperty(const char *name
)
23 cmPropertyMap::iterator it
= this->find(name
);
25 if (it
== this->end())
27 prop
= &(*this)[name
];
36 void cmPropertyMap::SetProperty(const char *name
, const char *value
,
37 cmProperty::ScopeType scope
)
49 if (!this->CMakeInstance
)
51 cmSystemTools::Error("CMakeInstance not set on a property map!");
56 this->CMakeInstance
->RecordPropertyAccess(name
,scope
);
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
)
75 if (!this->CMakeInstance
)
77 cmSystemTools::Error("CMakeInstance not set on a property map!");
82 this->CMakeInstance
->RecordPropertyAccess(name
,scope
);
88 cmProperty
*prop
= this->GetOrCreateProperty(name
);
89 prop
->Append(name
,value
);
92 const char *cmPropertyMap
93 ::GetPropertyValue(const char *name
,
94 cmProperty::ScopeType scope
,
103 // has the property been defined?
105 if (!this->CMakeInstance
)
107 cmSystemTools::Error("CMakeInstance not set on a property map!");
112 this->CMakeInstance
->RecordPropertyAccess(name
,scope
);
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
);
126 return it
->second
.GetValue();