diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2021-09-14 16:33:12 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2021-09-15 16:08:19 (GMT) |
commit | 8d0ae460de553afdf0a2b272a6aca01667c781da (patch) | |
tree | 8d49d1cb0854fb8890db36169c791ef95d5ed678 | |
parent | 1375862764faad681b45e6ca99e542862e9ae62c (diff) | |
download | CMake-8d0ae460de553afdf0a2b272a6aca01667c781da.zip CMake-8d0ae460de553afdf0a2b272a6aca01667c781da.tar.gz CMake-8d0ae460de553afdf0a2b272a6aca01667c781da.tar.bz2 |
cmCTestGenericHandler::SetOption accepts cmProp or std::string
-rw-r--r-- | Source/CTest/cmCTestGenericHandler.cxx | 26 | ||||
-rw-r--r-- | 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); /** |