cmake/Source/cmPropertyDefinition.cxx

43 lines
1.5 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmPropertyDefinition.h"
2016-07-09 11:21:54 +02:00
2020-08-30 11:54:41 +02:00
#include <tuple>
cmPropertyDefinition::cmPropertyDefinition(std::string shortDescription,
std::string fullDescription,
2022-03-29 21:10:50 +02:00
bool chained,
std::string initializeFromVariable)
2020-08-30 11:54:41 +02:00
: ShortDescription(std::move(shortDescription))
, FullDescription(std::move(fullDescription))
, Chained(chained)
2022-03-29 21:10:50 +02:00
, InitializeFromVariable(std::move(initializeFromVariable))
2020-08-30 11:54:41 +02:00
{
}
void cmPropertyDefinitionMap::DefineProperty(
const std::string& name, cmProperty::ScopeType scope,
const std::string& ShortDescription, const std::string& FullDescription,
2022-03-29 21:10:50 +02:00
bool chain, const std::string& initializeFromVariable)
{
2022-03-29 21:10:50 +02:00
auto it = this->Map_.find(KeyType(name, scope));
2020-08-30 11:54:41 +02:00
if (it == this->Map_.end()) {
// try_emplace() since C++17
2022-03-29 21:10:50 +02:00
this->Map_.emplace(std::piecewise_construct,
std::forward_as_tuple(name, scope),
std::forward_as_tuple(ShortDescription, FullDescription,
chain, initializeFromVariable));
2016-07-09 11:21:54 +02:00
}
2020-08-30 11:54:41 +02:00
}
cmPropertyDefinition const* cmPropertyDefinitionMap::GetPropertyDefinition(
const std::string& name, cmProperty::ScopeType scope) const
{
2022-03-29 21:10:50 +02:00
auto it = this->Map_.find(KeyType(name, scope));
2020-08-30 11:54:41 +02:00
if (it != this->Map_.end()) {
return &it->second;
2016-07-09 11:21:54 +02:00
}
2020-08-30 11:54:41 +02:00
return nullptr;
}