cmPropertyMap.cxx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 "cmPropertyMap.h"
  11. #include "cmSystemTools.h"
  12. #include "cmake.h"
  13. cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
  14. {
  15. cmPropertyMap::iterator it = this->find(name);
  16. cmProperty *prop;
  17. if (it == this->end())
  18. {
  19. prop = &(*this)[name];
  20. }
  21. else
  22. {
  23. prop = &(it->second);
  24. }
  25. return prop;
  26. }
  27. void cmPropertyMap::SetProperty(const char *name, const char *value,
  28. cmProperty::ScopeType scope)
  29. {
  30. if (!name)
  31. {
  32. return;
  33. }
  34. if(!value)
  35. {
  36. this->erase(name);
  37. return;
  38. }
  39. (void)scope;
  40. cmProperty *prop = this->GetOrCreateProperty(name);
  41. prop->Set(name,value);
  42. }
  43. void cmPropertyMap::AppendProperty(const char* name, const char* value,
  44. cmProperty::ScopeType scope, bool asString)
  45. {
  46. // Skip if nothing to append.
  47. if(!name || !value || !*value)
  48. {
  49. return;
  50. }
  51. (void)scope;
  52. cmProperty *prop = this->GetOrCreateProperty(name);
  53. prop->Append(name,value,asString);
  54. }
  55. const char *cmPropertyMap
  56. ::GetPropertyValue(const char *name,
  57. cmProperty::ScopeType scope,
  58. bool &chain) const
  59. {
  60. chain = false;
  61. if (!name)
  62. {
  63. return 0;
  64. }
  65. cmPropertyMap::const_iterator it = this->find(name);
  66. if (it == this->end())
  67. {
  68. // should we chain up?
  69. if (this->CMakeInstance)
  70. {
  71. chain = this->CMakeInstance->IsPropertyChained(name,scope);
  72. }
  73. return 0;
  74. }
  75. return it->second.GetValue();
  76. }