From 8d0ae460de553afdf0a2b272a6aca01667c781da Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Tue, 14 Sep 2021 18:33:12 +0200 Subject: cmCTestGenericHandler::SetOption accepts cmProp or std::string --- Source/CTest/cmCTestGenericHandler.cxx | 26 ++++++++++++++++++++++++-- Source/CTest/cmCTestGenericHandler.h | 10 ++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index bd33055..dc7103a 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -21,11 +21,12 @@ cmCTestGenericHandler::cmCTestGenericHandler() cmCTestGenericHandler::~cmCTestGenericHandler() = default; +namespace { /* Modify the given `map`, setting key `op` to `value` if `value` * is non-null, otherwise removing key `op` (if it exists). */ -static void SetMapValue(cmCTestGenericHandler::t_StringToString& map, - const std::string& op, const char* value) +void SetMapValue(cmCTestGenericHandler::t_StringToString& map, + const std::string& op, const char* value) { if (!value) { map.erase(op); @@ -34,11 +35,26 @@ static void SetMapValue(cmCTestGenericHandler::t_StringToString& map, map[op] = value; } +void SetMapValue(cmCTestGenericHandler::t_StringToString& map, + const std::string& op, cmProp value) +{ + if (!value) { + map.erase(op); + return; + } + + map[op] = *value; +} +} void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) { SetMapValue(this->Options, op, value); } +void cmCTestGenericHandler::SetOption(const std::string& op, cmProp value) +{ + SetMapValue(this->Options, op, value); +} void cmCTestGenericHandler::SetPersistentOption(const std::string& op, const char* value) @@ -46,6 +62,12 @@ void cmCTestGenericHandler::SetPersistentOption(const std::string& op, this->SetOption(op, value); SetMapValue(this->PersistentOptions, op, value); } +void cmCTestGenericHandler::SetPersistentOption(const std::string& op, + cmProp value) +{ + this->SetOption(op, value); + SetMapValue(this->PersistentOptions, op, value); +} void cmCTestGenericHandler::AddMultiOption(const std::string& op, const std::string& value) diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index 0b8b224..852d4ea 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -87,7 +87,17 @@ public: * as a multi-value will return nullptr. */ void SetPersistentOption(const std::string& op, const char* value); + void SetPersistentOption(const std::string& op, const std::string& value) + { + this->SetPersistentOption(op, cmProp(value)); + } + void SetPersistentOption(const std::string& op, cmProp value); void SetOption(const std::string& op, const char* value); + void SetOption(const std::string& op, const std::string& value) + { + this->SetOption(op, cmProp(value)); + } + void SetOption(const std::string& op, cmProp value); cmProp GetOption(const std::string& op); /** -- cgit v0.12