cmPropertyMap.cxx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #include "cmState.h"
  14. #include <assert.h>
  15. cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name)
  16. {
  17. cmPropertyMap::iterator it = this->find(name);
  18. cmProperty *prop;
  19. if (it == this->end())
  20. {
  21. prop = &(*this)[name];
  22. }
  23. else
  24. {
  25. prop = &(it->second);
  26. }
  27. return prop;
  28. }
  29. void cmPropertyMap::SetProperty(const std::string& name, const char *value)
  30. {
  31. if(!value)
  32. {
  33. this->erase(name);
  34. return;
  35. }
  36. cmProperty *prop = this->GetOrCreateProperty(name);
  37. prop->Set(value);
  38. }
  39. void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
  40. bool asString)
  41. {
  42. // Skip if nothing to append.
  43. if(!value || !*value)
  44. {
  45. return;
  46. }
  47. cmProperty *prop = this->GetOrCreateProperty(name);
  48. prop->Append(value,asString);
  49. }
  50. const char *cmPropertyMap
  51. ::GetPropertyValue(const std::string& name) const
  52. {
  53. assert(!name.empty());
  54. cmPropertyMap::const_iterator it = this->find(name);
  55. if (it == this->end())
  56. {
  57. return 0;
  58. }
  59. return it->second.GetValue();
  60. }