summaryrefslogtreecommitdiff
path: root/Source/cmPropertyDefinition.cxx
diff options
context:
space:
mode:
authorTushar Maheshwari <tushar27192@gmail.com>2020-05-13 19:54:03 +0530
committerTushar Maheshwari <tushar27192@gmail.com>2020-05-15 18:58:02 +0530
commit6728f0fa858c1782e6c619661f32c016d84d1ad6 (patch)
tree5debb1b915705c9cbe1ca397304a76233c9847cb /Source/cmPropertyDefinition.cxx
parent1cc4bc41916b60e9d52c3a89f6f77b091fbe0d31 (diff)
downloadcmake-6728f0fa858c1782e6c619661f32c016d84d1ad6.tar.gz
cmPropertyDefinitionMap: simplify and shorten
Diffstat (limited to 'Source/cmPropertyDefinition.cxx')
-rw-r--r--Source/cmPropertyDefinition.cxx39
1 files changed, 30 insertions, 9 deletions
diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx
index c8efaf65a9..1796bb8d0e 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;
+}