/src/CMake/Source/cmPropertyDefinition.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 "cmPropertyDefinition.h" |
4 | | |
5 | | #include <tuple> |
6 | | #include <utility> |
7 | | |
8 | | cmPropertyDefinition::cmPropertyDefinition(std::string shortDescription, |
9 | | std::string fullDescription, |
10 | | bool chained, |
11 | | std::string initializeFromVariable) |
12 | 6 | : ShortDescription(std::move(shortDescription)) |
13 | 6 | , FullDescription(std::move(fullDescription)) |
14 | 6 | , Chained(chained) |
15 | 6 | , InitializeFromVariable(std::move(initializeFromVariable)) |
16 | 6 | { |
17 | 6 | } |
18 | | |
19 | | void cmPropertyDefinitionMap::DefineProperty( |
20 | | std::string const& name, cmProperty::ScopeType scope, |
21 | | std::string const& ShortDescription, std::string const& FullDescription, |
22 | | bool chain, std::string const& initializeFromVariable) |
23 | 6 | { |
24 | 6 | auto it = this->Map_.find(name); |
25 | 6 | if (it == this->Map_.end()) { |
26 | 3 | it = this->Map_.emplace(name, ScopeMap()).first; |
27 | 3 | } |
28 | 6 | ScopeMap& scopeMap = it->second; |
29 | 6 | auto scopeIter = scopeMap.find(scope); |
30 | 6 | if (scopeIter == scopeMap.end()) { |
31 | | // try_emplace() since C++17 |
32 | 6 | scopeMap.emplace(std::piecewise_construct, std::forward_as_tuple(scope), |
33 | 6 | std::forward_as_tuple(ShortDescription, FullDescription, |
34 | 6 | chain, initializeFromVariable)); |
35 | 6 | } |
36 | 6 | } |
37 | | |
38 | | cmPropertyDefinition const* cmPropertyDefinitionMap::GetPropertyDefinition( |
39 | | std::string const& name, cmProperty::ScopeType scope) const |
40 | 0 | { |
41 | 0 | auto nameIter = this->Map_.find(name); |
42 | 0 | if (nameIter != this->Map_.end()) { |
43 | 0 | auto scopeIter = nameIter->second.find(scope); |
44 | 0 | if (scopeIter != nameIter->second.end()) { |
45 | 0 | return &scopeIter->second; |
46 | 0 | } |
47 | 0 | } |
48 | | |
49 | 0 | return nullptr; |
50 | 0 | } |