aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2003-11-05 12:16:14 +0000
committerMax Horn2003-11-05 12:16:14 +0000
commit0dfd0e44148333257cf37e5e82ed902de3ac68a2 (patch)
treefdf5d633088922a33bedc7487e4e97b3325ed0ba /common
parent513fdae26189db34137bcf1bed239673d2b80c37 (diff)
downloadscummvm-rg350-0dfd0e44148333257cf37e5e82ed902de3ac68a2.tar.gz
scummvm-rg350-0dfd0e44148333257cf37e5e82ed902de3ac68a2.tar.bz2
scummvm-rg350-0dfd0e44148333257cf37e5e82ed902de3ac68a2.zip
changed the way get(key,domain) works for global domains (instead of defaulting to the empty string, it will now default to the registered default in this case)
svn-id: r11151
Diffstat (limited to 'common')
-rw-r--r--common/config-manager.cpp28
-rw-r--r--common/config-manager.h2
2 files changed, 19 insertions, 11 deletions
diff --git a/common/config-manager.cpp b/common/config-manager.cpp
index dc29cec8c9..1bcc06ff19 100644
--- a/common/config-manager.cpp
+++ b/common/config-manager.cpp
@@ -211,7 +211,7 @@ bool ConfigManager::hasKey(const String &key) const {
// 3) All global domains
// The defaults domain is explicitly *not* checked.
-// if (_runtimeDomain.contain(key))
+// if (_transientDomain.contain(key))
// return true;
if (!_activeDomain.isEmpty() && _gameDomains[_activeDomain].contains(key))
@@ -226,7 +226,6 @@ bool ConfigManager::hasKey(const String &key) const {
return false;
}
-
bool ConfigManager::hasKey(const String &key, const String &dom) const {
assert(!dom.isEmpty());
@@ -238,7 +237,6 @@ bool ConfigManager::hasKey(const String &key, const String &dom) const {
return false;
}
-
void ConfigManager::removeKey(const String &key, const String &dom) {
assert(!dom.isEmpty());
@@ -261,7 +259,7 @@ const String & ConfigManager::get(const String &key) const {
// 3) All global domains
// 4) The defaults
-// if (_runtimeDomain.contain(key))
+// if (_transientDomain.contain(key))
// return true;
if (!_activeDomain.isEmpty() && _gameDomains[_activeDomain].contains(key))
@@ -284,12 +282,22 @@ const String & ConfigManager::get(const String &key, const String &dom) const {
// is not found, or were dom is found, but doesn't contain 'key' ?
// Right now we just return an empty string. But might want to print
// out a warning, or even error out?
- if (_gameDomains.contains(dom))
+ if (_gameDomains.contains(dom)) {
+ // Return the value, if any; defaults to the empty string if the key is
+ // not present in the domain. We purposely do not return the registered
+ // default value.
+ //
return _gameDomains[dom].get(key);
- if (_globalDomains.contains(dom))
- return _globalDomains[dom].get(key);
-
- return String::emptyString;
+ } else if (_globalDomains.contains(dom)) {
+ if (_globalDomains[dom].contains(key))
+ return _globalDomains[dom].get(key);
+ // For global domains, we *do* use the registered default value.
+ return _defaultsDomain.get(key);
+ } else {
+ // Domain was not found. Do *not* return the registered default
+ // value, see above for the reasons.
+ return String::emptyString;
+ }
}
int ConfigManager::getInt(const String &key, const String &dom) const {
@@ -316,7 +324,7 @@ bool ConfigManager::getBool(const String &key, const String &dom) const {
void ConfigManager::set(const String &key, const String &value) {
#if 0
// TODO ?!?
-// _runtimeDomain[key] = value;
+// _transientDomain[key] = value;
#else
if (_activeDomain.isEmpty())
_globalDomains[kApplicationDomain][key] = value;
diff --git a/common/config-manager.h b/common/config-manager.h
index 8147df5ebd..83f589aafc 100644
--- a/common/config-manager.h
+++ b/common/config-manager.h
@@ -107,7 +107,7 @@ private:
void loadFile(const String &filename);
void writeDomain(FILE *file, const String &name, const Domain &domain);
-// Domain _runtimeDomain;
+// Domain _transientDomain;
DomainMap _gameDomains;
DomainMap _globalDomains;
Domain _defaultsDomain;