cmPropertyDefinitionMap.cxx 3.4 KB

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