Removing optional

- C++11 compliance: there's no optional, so use invalid enum value instead.
This commit is contained in:
tustin2121 2022-09-01 13:29:05 -04:00
parent 09a590e01a
commit d97ed4b64f

View file

@ -59,11 +59,11 @@ const QMap<ProjectFilePath, std::pair<QString, QString>> defaultPaths = {
{ProjectFilePath::path_initial_facing_table, { "path_initial_facing_table", "src/event_object_movement.c"}}, {ProjectFilePath::path_initial_facing_table, { "path_initial_facing_table", "src/event_object_movement.c"}},
}; };
std::optional<ProjectFilePath> reverseDefaultPaths(QString str) { ProjectFilePath reverseDefaultPaths(QString str) {
for (auto it = defaultPaths.constKeyValueBegin(); it != defaultPaths.constKeyValueEnd(); ++it) { for (auto it = defaultPaths.constKeyValueBegin(); it != defaultPaths.constKeyValueEnd(); ++it) {
if ((*it).second.first == str) return (*it).first; if ((*it).second.first == str) return (*it).first;
} }
return std::nullopt; return static_cast<ProjectFilePath>(-1);
} }
@ -561,8 +561,8 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
#endif #endif
} else if (key.startsWith("path/")) { } else if (key.startsWith("path/")) {
auto k = reverseDefaultPaths(key.mid(5)); auto k = reverseDefaultPaths(key.mid(5));
if (k.has_value()) { if (k != static_cast<ProjectFilePath>(-1)) {
this->filePaths[k.value()] = value; this->filePaths[k] = value;
} else { } else {
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key)); logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
} }