[Scummvm-cvs-logs] CVS: scummvm/common config-manager.cpp,1.6,1.7 config-manager.h,1.3,1.4

Max Horn fingolfin at users.sourceforge.net
Wed Nov 5 04:17:18 CET 2003


Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv30679

Modified Files:
	config-manager.cpp config-manager.h 
Log Message:
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)

Index: config-manager.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/config-manager.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- config-manager.cpp	5 Nov 2003 00:57:00 -0000	1.6
+++ config-manager.cpp	5 Nov 2003 12:16:14 -0000	1.7
@@ -211,7 +211,7 @@
 	// 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 @@
 	return false;
 }
 
-
 bool ConfigManager::hasKey(const String &key, const String &dom) const {
 	assert(!dom.isEmpty());
 
@@ -238,7 +237,6 @@
 	return false;
 }
 
-
 void ConfigManager::removeKey(const String &key, const String &dom) {
 	assert(!dom.isEmpty());
 
@@ -261,7 +259,7 @@
 	// 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 @@
 	// 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 @@
 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;

Index: config-manager.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/config-manager.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- config-manager.h	5 Nov 2003 00:57:00 -0000	1.3
+++ config-manager.h	5 Nov 2003 12:16:14 -0000	1.4
@@ -107,7 +107,7 @@
 	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;





More information about the Scummvm-git-logs mailing list