diff options
author | Tushar Maheshwari <tushar27192@gmail.com> | 2020-05-13 14:24:03 (GMT) |
---|---|---|
committer | Tushar Maheshwari <tushar27192@gmail.com> | 2020-05-15 13:28:02 (GMT) |
commit | 6728f0fa858c1782e6c619661f32c016d84d1ad6 (patch) | |
tree | 5debb1b915705c9cbe1ca397304a76233c9847cb /Source/cmPropertyDefinition.cxx | |
parent | 1cc4bc41916b60e9d52c3a89f6f77b091fbe0d31 (diff) | |
download | CMake-6728f0fa858c1782e6c619661f32c016d84d1ad6.zip CMake-6728f0fa858c1782e6c619661f32c016d84d1ad6.tar.gz CMake-6728f0fa858c1782e6c619661f32c016d84d1ad6.tar.bz2 |
cmPropertyDefinitionMap: simplify and shorten
Diffstat (limited to 'Source/cmPropertyDefinition.cxx')
-rw-r--r-- | Source/cmPropertyDefinition.cxx | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx index c8efaf6..1796bb8 100644 --- a/Source/cmPropertyDefinition.cxx +++ b/Source/cmPropertyDefinition.cxx @@ -2,17 +2,38 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmPropertyDefinition.h" -#include <utility> +#include <tuple> -cmPropertyDefinition::cmPropertyDefinition(std::string name, - cmProperty::ScopeType scope, - std::string shortDescription, +cmPropertyDefinition::cmPropertyDefinition(std::string shortDescription, std::string fullDescription, - bool chain) - : Name(std::move(name)) - , ShortDescription(std::move(shortDescription)) + bool chained) + : ShortDescription(std::move(shortDescription)) , FullDescription(std::move(fullDescription)) - , Scope(scope) - , Chained(chain) + , Chained(chained) { } + +void cmPropertyDefinitionMap::DefineProperty( + const std::string& name, cmProperty::ScopeType scope, + const std::string& ShortDescription, const std::string& FullDescription, + bool chain) +{ + auto it = this->Map_.find(key_type(name, scope)); + if (it == this->Map_.end()) { + // try_emplace() since C++17 + this->Map_.emplace( + std::piecewise_construct, std::forward_as_tuple(name, scope), + std::forward_as_tuple(ShortDescription, FullDescription, chain)); + } +} + +cmPropertyDefinition const* cmPropertyDefinitionMap::GetPropertyDefinition( + const std::string& name, cmProperty::ScopeType scope) const +{ + auto it = this->Map_.find(key_type(name, scope)); + if (it != this->Map_.end()) { + return &it->second; + } + + return nullptr; +} |