cmPropertyMap.cxx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmPropertyMap.h"
  4. #include <utility>
  5. void cmPropertyMap::Clear()
  6. {
  7. Map_.clear();
  8. }
  9. void cmPropertyMap::SetProperty(const std::string& name, const char* value)
  10. {
  11. if (!value) {
  12. Map_.erase(name);
  13. return;
  14. }
  15. Map_[name].Set(value);
  16. }
  17. void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
  18. bool asString)
  19. {
  20. // Skip if nothing to append.
  21. if (!value || !*value) {
  22. return;
  23. }
  24. Map_[name].Append(value, asString);
  25. }
  26. const char* cmPropertyMap::GetPropertyValue(const std::string& name) const
  27. {
  28. {
  29. auto it = Map_.find(name);
  30. if (it != Map_.end()) {
  31. return it->second.GetValue();
  32. }
  33. }
  34. return nullptr;
  35. }
  36. std::vector<std::string> cmPropertyMap::GetKeys() const
  37. {
  38. std::vector<std::string> keyList;
  39. keyList.reserve(Map_.size());
  40. for (auto const& item : Map_) {
  41. keyList.push_back(item.first);
  42. }
  43. return keyList;
  44. }
  45. std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const
  46. {
  47. std::vector<std::pair<std::string, std::string>> kvList;
  48. kvList.reserve(Map_.size());
  49. for (auto const& item : Map_) {
  50. kvList.emplace_back(item.first, item.second.GetValue());
  51. }
  52. return kvList;
  53. }