COMMON: Retire dangerous non const operator[] on ConfMan

This commit is contained in:
Henrik "Henke37" Andersson 2020-10-19 21:57:31 +02:00 committed by Eugene Sandulenko
parent 2300f0a7d4
commit 2eb52fe900
4 changed files with 16 additions and 17 deletions

View File

@ -1287,14 +1287,14 @@ void upgradeTargets() {
// the target referred to by dom. We update several things
// Always set the engine ID and game ID explicitly (in case of legacy targets)
dom["engineid"] = g->engineId;
dom["gameid"] = g->gameId;
dom.setVal("engineid", g->engineId);
dom.setVal("gameid", g->gameId);
// Always set the GUI options. The user should not modify them, and engines might
// gain more features over time, so we want to keep this list up-to-date.
if (!g->getGUIOptions().empty()) {
printf(" -> update guioptions to '%s'\n", g->getGUIOptions().c_str());
dom["guioptions"] = g->getGUIOptions();
dom.setVal("guioptions", g->getGUIOptions());
} else if (dom.contains("guioptions")) {
dom.erase("guioptions");
}
@ -1302,13 +1302,13 @@ void upgradeTargets() {
// Update the language setting but only if none has been set yet.
if (lang == Common::UNK_LANG && g->language != Common::UNK_LANG) {
printf(" -> set language to '%s'\n", Common::getLanguageCode(g->language));
dom["language"] = Common::getLanguageCode(g->language);
dom.setVal("language", Common::getLanguageCode(g->language));
}
// Update the platform setting but only if none has been set yet.
if (plat == Common::kPlatformUnknown && g->platform != Common::kPlatformUnknown) {
printf(" -> set platform to '%s'\n", Common::getPlatformCode(g->platform));
dom["platform"] = Common::getPlatformCode(g->platform);
dom.setVal("platform", Common::getPlatformCode(g->platform));
}
// TODO: We could also update the description. But not everybody will want that.
@ -1318,7 +1318,7 @@ void upgradeTargets() {
#if 0
if (desc != g->description) {
printf(" -> update desc from '%s' to\n '%s' ?\n", desc.c_str(), g->description.c_str());
dom["description"] = g->description;
dom.setVal("description", = g->description);
}
#endif
}

View File

@ -441,7 +441,7 @@ void PluginManagerUncached::updateConfigWithFileName(const Common::String &engin
Common::ConfigManager::Domain *domain = ConfMan.getDomain("engine_plugin_files");
assert(domain);
(*domain)[engineId] = (*_currentPlugin)->getFileName();
(*domain).setVal(engineId, (*_currentPlugin)->getFileName());
ConfMan.flushToDisk();
}

View File

@ -237,7 +237,7 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) {
value.trim();
// Finally, store the key/value pair in the active domain
domain[key] = value;
domain.setVal(key, value);
// Store comment
domain.setKVComment(key, comment);
@ -522,9 +522,9 @@ void ConfigManager::set(const String &key, const String &value) {
// Write the new key/value pair into the active domain, resp. into
// the application domain if no game domain is active.
if (_activeDomain)
(*_activeDomain)[key] = value;
(*_activeDomain).setVal(key, value);
else
_appDomain[key] = value;
_appDomain.setVal(key, value);
}
void ConfigManager::setAndFlush(const String &key, const Common::String &value) {
@ -555,7 +555,7 @@ void ConfigManager::set(const String &key, const String &value, const String &do
error("ConfigManager::set(%s,%s,%s) called on non-existent domain",
key.c_str(), value.c_str(), domName.c_str());
(*domain)[key] = value;
(*domain).setVal(key, value);
// TODO/FIXME: We used to erase the given key from the transient domain
// here. Do we still want to do that?
@ -570,14 +570,14 @@ void ConfigManager::set(const String &key, const String &value, const String &do
// to replace it in a clean fashion...
#if 0
if (domName == kTransientDomain)
_transientDomain[key] = value;
_transientDomain.setVal(key, value);
else {
if (domName == kApplicationDomain) {
_appDomain[key] = value;
_appDomain.setVal(key, value;
if (_activeDomainName.empty() || !_gameDomains[_activeDomainName].contains(key))
_transientDomain.erase(key);
} else {
_gameDomains[domName][key] = value;
_gameDomains[domName].setVal(key, value);
if (domName == _activeDomainName)
_transientDomain.erase(key);
}
@ -598,7 +598,7 @@ void ConfigManager::setBool(const String &key, bool value, const String &domName
void ConfigManager::registerDefault(const String &key, const String &value) {
_defaultsDomain[key] = value;
_defaultsDomain.setVal(key, value);
}
void ConfigManager::registerDefault(const String &key, const char *value) {
@ -694,7 +694,7 @@ void ConfigManager::renameDomain(const String &oldName, const String &newName, D
Domain &newDom = map[newName];
Domain::const_iterator iter;
for (iter = oldDom.begin(); iter != oldDom.end(); ++iter)
newDom[iter->_key] = iter->_value;
newDom.setVal(iter->_key, iter->_value);
map.erase(oldName);
}

View File

@ -73,7 +73,6 @@ public:
/** Return the configuration value for the given key.
* If no entry exists for the given key in the configuration, it is created.
*/
String &operator[](const String &key) { return _entries[key]; }
/** Return the configuration value for the given key.
* @note This function does *not* create a configuration entry
* for the given key if it does not exist.