Coverage Report

Created: 2026-10-28 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmPropertyMap.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmPropertyMap.h"
4
5
#include <algorithm>
6
#include <utility>
7
8
void cmPropertyMap::Clear()
9
1
{
10
1
  this->Map_.clear();
11
1
}
12
13
void cmPropertyMap::SetProperty(std::string const& name, cmValue value)
14
440k
{
15
440k
  if (!value) {
16
0
    this->Map_.erase(name);
17
0
    return;
18
0
  }
19
20
440k
  this->Map_[name] = *value;
21
440k
}
22
23
void cmPropertyMap::AppendProperty(std::string const& name,
24
                                   std::string const& value, bool asString)
25
128k
{
26
  // Skip if nothing to append.
27
128k
  if (value.empty()) {
28
74
    return;
29
74
  }
30
31
128k
  {
32
128k
    std::string& pVal = this->Map_[name];
33
128k
    if (!pVal.empty() && !asString) {
34
84.4k
      pVal += ';';
35
84.4k
    }
36
128k
    pVal += value;
37
128k
  }
38
128k
}
39
40
void cmPropertyMap::RemoveProperty(std::string const& name)
41
0
{
42
0
  this->Map_.erase(name);
43
0
}
44
45
cmValue cmPropertyMap::GetPropertyValue(std::string const& name) const
46
393k
{
47
393k
  auto it = this->Map_.find(name);
48
393k
  if (it != this->Map_.end()) {
49
38.1k
    return cmValue(it->second);
50
38.1k
  }
51
355k
  return nullptr;
52
393k
}
53
54
std::vector<std::string> cmPropertyMap::GetKeys() const
55
5.50k
{
56
5.50k
  std::vector<std::string> keyList;
57
5.50k
  keyList.reserve(this->Map_.size());
58
41.4k
  for (auto const& item : this->Map_) {
59
41.4k
    keyList.push_back(item.first);
60
41.4k
  }
61
5.50k
  std::sort(keyList.begin(), keyList.end());
62
5.50k
  return keyList;
63
5.50k
}
64
65
std::vector<std::pair<std::string, std::string>> cmPropertyMap::GetList() const
66
0
{
67
0
  using StringPair = std::pair<std::string, std::string>;
68
0
  std::vector<StringPair> kvList;
69
0
  kvList.reserve(this->Map_.size());
70
0
  for (auto const& item : this->Map_) {
71
0
    kvList.emplace_back(item.first, item.second);
72
0
  }
73
0
  std::sort(kvList.begin(), kvList.end(),
74
0
            [](StringPair const& a, StringPair const& b) {
75
0
              return a.first < b.first;
76
0
            });
77
0
  return kvList;
78
0
}