/src/CMake/Source/cmInstalledFile.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 "cmInstalledFile.h" |
4 | | |
5 | | #include <utility> |
6 | | |
7 | | #include "cmGeneratorExpression.h" |
8 | | #include "cmList.h" |
9 | | #include "cmListFileCache.h" |
10 | | #include "cmMakefile.h" |
11 | | #include "cmValue.h" |
12 | | |
13 | 0 | cmInstalledFile::cmInstalledFile() = default; |
14 | | |
15 | 0 | cmInstalledFile::~cmInstalledFile() = default; |
16 | | |
17 | 0 | cmInstalledFile::Property::Property() = default; |
18 | | |
19 | 0 | cmInstalledFile::Property::~Property() = default; |
20 | | |
21 | | void cmInstalledFile::SetName(cmMakefile* mf, std::string const& name) |
22 | 0 | { |
23 | 0 | cmListFileBacktrace backtrace = mf->GetBacktrace(); |
24 | 0 | cmGeneratorExpression ge(*mf->GetCMakeInstance(), backtrace); |
25 | |
|
26 | 0 | this->Name = name; |
27 | 0 | this->NameExpression = ge.Parse(name); |
28 | 0 | } |
29 | | |
30 | | std::string const& cmInstalledFile::GetName() const |
31 | 0 | { |
32 | 0 | return this->Name; |
33 | 0 | } |
34 | | |
35 | | cmCompiledGeneratorExpression const& cmInstalledFile::GetNameExpression() const |
36 | 0 | { |
37 | 0 | return *(this->NameExpression); |
38 | 0 | } |
39 | | |
40 | | void cmInstalledFile::RemoveProperty(std::string const& prop) |
41 | 0 | { |
42 | 0 | this->Properties.erase(prop); |
43 | 0 | } |
44 | | |
45 | | void cmInstalledFile::SetProperty(cmMakefile const* mf, |
46 | | std::string const& prop, |
47 | | std::string const& value) |
48 | 0 | { |
49 | 0 | this->RemoveProperty(prop); |
50 | 0 | this->AppendProperty(mf, prop, value); |
51 | 0 | } |
52 | | |
53 | | void cmInstalledFile::AppendProperty(cmMakefile const* mf, |
54 | | std::string const& prop, |
55 | | std::string const& value, |
56 | | bool /*asString*/) |
57 | 0 | { |
58 | 0 | cmListFileBacktrace backtrace = mf->GetBacktrace(); |
59 | 0 | cmGeneratorExpression ge(*mf->GetCMakeInstance(), backtrace); |
60 | |
|
61 | 0 | Property& property = this->Properties[prop]; |
62 | 0 | property.ValueExpressions.push_back(ge.Parse(value)); |
63 | 0 | } |
64 | | |
65 | | bool cmInstalledFile::HasProperty(std::string const& prop) const |
66 | 0 | { |
67 | 0 | return this->Properties.find(prop) != this->Properties.end(); |
68 | 0 | } |
69 | | |
70 | | bool cmInstalledFile::GetProperty(std::string const& prop, |
71 | | std::string& value) const |
72 | 0 | { |
73 | 0 | auto i = this->Properties.find(prop); |
74 | 0 | if (i == this->Properties.end()) { |
75 | 0 | return false; |
76 | 0 | } |
77 | | |
78 | 0 | Property const& property = i->second; |
79 | |
|
80 | 0 | std::string output; |
81 | 0 | std::string separator; |
82 | |
|
83 | 0 | for (auto const& ve : property.ValueExpressions) { |
84 | 0 | output += separator; |
85 | 0 | output += ve->GetInput(); |
86 | 0 | separator = ";"; |
87 | 0 | } |
88 | |
|
89 | 0 | value = output; |
90 | 0 | return true; |
91 | 0 | } |
92 | | |
93 | | bool cmInstalledFile::GetPropertyAsBool(std::string const& prop) const |
94 | 0 | { |
95 | 0 | std::string value; |
96 | 0 | bool isSet = this->GetProperty(prop, value); |
97 | 0 | return isSet && cmIsOn(value); |
98 | 0 | } |
99 | | |
100 | | std::vector<std::string> cmInstalledFile::GetPropertyAsList( |
101 | | std::string const& prop) const |
102 | 0 | { |
103 | 0 | std::string value; |
104 | 0 | this->GetProperty(prop, value); |
105 | |
|
106 | 0 | return std::move(cmList(value).data()); |
107 | 0 | } |