Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmPropertyDefinitionMap.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #include "cmPropertyDefinitionMap.h"
13 #include "cmSystemTools.h"
14 #include "cmDocumentationSection.h"
15
16 void cmPropertyDefinitionMap
17 ::DefineProperty(const char *name, cmProperty::ScopeType scope,
18                  const char *ShortDescription,
19                  const char *FullDescription,
20                  const char *DocumentationSection,
21                  bool chain)
22 {
23   if (!name)
24     {
25     return;
26     }
27
28   cmPropertyDefinitionMap::iterator it = this->find(name);
29   cmPropertyDefinition *prop;
30   if (it == this->end())
31     {
32     prop = &(*this)[name];
33     prop->DefineProperty(name,scope,ShortDescription, FullDescription,
34                          DocumentationSection, chain);
35     }
36 }
37
38 void cmPropertyDefinitionMap
39 ::GetPropertiesDocumentation(std::map<std::string,
40                              cmDocumentationSection *>& v) const
41 {
42   for(cmPropertyDefinitionMap::const_iterator j = this->begin();
43       j != this->end(); ++j)
44     {
45     // add a section if needed
46     std::string secName = j->second.GetDocumentationSection();
47     // if a section was not specified then use the scope
48     if (!secName.size())
49       {
50       switch (j->second.GetScope())
51         {
52         case cmProperty::GLOBAL:
53           secName = "Properties of Global Scope";
54           break;
55         case cmProperty::TARGET:
56           secName = "Properties on Targets";
57           break;
58         case cmProperty::SOURCE_FILE:
59           secName = "Properties on Source Files";
60           break;
61         case cmProperty::DIRECTORY:
62           secName = "Properties on Directories";
63           break;
64         case cmProperty::TEST:
65           secName = "Properties on Tests";
66           break;
67         case cmProperty::CACHE:
68           secName = "Properties on Cache Entries";
69           break;
70         case cmProperty::VARIABLE:
71           secName = "Variables";
72           break;
73         case cmProperty::CACHED_VARIABLE:
74           secName = "Cached Variables";
75           break;
76         default:
77           secName = "Properties of Unknown Scope";
78           break;
79         }
80       }
81     if (!v[secName])
82       {
83       v[secName] = new
84         cmDocumentationSection(secName.c_str(),
85                                cmSystemTools::UpperCase(secName).c_str());
86       }
87     cmDocumentationEntry e = j->second.GetDocumentation();
88     if (e.Brief.size() || e.Full.size())
89       {
90       v[secName]->Append(e);
91       }
92     }
93 }
94
95 bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name)
96 {
97   if (!name)
98     {
99     return false;
100     }
101
102   cmPropertyDefinitionMap::iterator it = this->find(name);
103   if (it == this->end())
104     {
105     return false;
106     }
107
108   return true;
109 }
110
111 bool cmPropertyDefinitionMap::IsPropertyChained(const char *name)
112 {
113   if (!name)
114     {
115     return false;
116     }
117
118   cmPropertyDefinitionMap::iterator it = this->find(name);
119   if (it == this->end())
120     {
121     return false;
122     }
123
124   return it->second.IsChained();
125 }