cmCTestGenericHandler::SetOption accepts cmProp or std::string

This commit is contained in:
Marc Chevrier
2021-09-14 18:33:12 +02:00
parent 1375862764
commit 8d0ae460de
2 changed files with 34 additions and 2 deletions

View File

@@ -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)

View File

@@ -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);
/**