[Scummvm-cvs-logs] SF.net SVN: scummvm:[48417] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Mar 29 22:31:23 CEST 2010


Revision: 48417
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48417&view=rev
Author:   fingolfin
Date:     2010-03-29 20:31:23 +0000 (Mon, 29 Mar 2010)

Log Message:
-----------
COMMON: Cleanup ConfigManager code

* get rid of ConfigManager::_emptyString
* get rid of ConfigManager::Domain::get (use getVal instead)
* remove some dead code

Modified Paths:
--------------
    scummvm/trunk/base/commandLine.cpp
    scummvm/trunk/common/config-manager.cpp
    scummvm/trunk/common/config-manager.h
    scummvm/trunk/engines/engine.cpp
    scummvm/trunk/engines/kyra/detection.cpp
    scummvm/trunk/engines/kyra/kyra_v1.cpp
    scummvm/trunk/gui/launcher.cpp
    scummvm/trunk/gui/massadd.cpp

Modified: scummvm/trunk/base/commandLine.cpp
===================================================================
--- scummvm/trunk/base/commandLine.cpp	2010-03-29 18:58:47 UTC (rev 48416)
+++ scummvm/trunk/base/commandLine.cpp	2010-03-29 20:31:23 UTC (rev 48417)
@@ -584,7 +584,7 @@
 	ConfigManager::DomainMap::const_iterator iter;
 	for (iter = domains.begin(); iter != domains.end(); ++iter) {
 		Common::String name(iter->_key);
-		Common::String description(iter->_value.get("description"));
+		Common::String description(iter->_value.getVal("description"));
 
 		if (description.empty()) {
 			// FIXME: At this point, we should check for a "gameid" override
@@ -617,7 +617,7 @@
 	// Grab the gameid from the domain resp. use the target as gameid
 	Common::String gameid;
 	if (domain)
-		gameid = domain->get("gameid");
+		gameid = domain->getVal("gameid");
 	if (gameid.empty())
 		gameid = target;
 	gameid.toLowercase();	// Normalize it to lower case
@@ -674,8 +674,8 @@
 	int success = 0, failure = 0;
 	for (iter = domains.begin(); iter != domains.end(); ++iter) {
 		Common::String name(iter->_key);
-		Common::String gameid(iter->_value.get("gameid"));
-		Common::String path(iter->_value.get("path"));
+		Common::String gameid(iter->_value.getVal("gameid"));
+		Common::String path(iter->_value.getVal("path"));
 		printf("Looking at target '%s', gameid '%s', path '%s' ...\n",
 				name.c_str(), gameid.c_str(), path.c_str());
 		if (path.empty()) {
@@ -748,8 +748,8 @@
 	for (iter = domains.begin(); iter != domains.end(); ++iter) {
 		Common::ConfigManager::Domain &dom = iter->_value;
 		Common::String name(iter->_key);
-		Common::String gameid(dom.get("gameid"));
-		Common::String path(dom.get("path"));
+		Common::String gameid(dom.getVal("gameid"));
+		Common::String path(dom.getVal("path"));
 		printf("Looking at target '%s', gameid '%s' ...\n",
 				name.c_str(), gameid.c_str());
 		if (path.empty()) {
@@ -768,9 +768,9 @@
 			continue;
 		}
 
-		Common::Language lang = Common::parseLanguage(dom.get("language"));
-		Common::Platform plat = Common::parsePlatform(dom.get("platform"));
-		Common::String desc(dom.get("description"));
+		Common::Language lang = Common::parseLanguage(dom.getVal("language"));
+		Common::Platform plat = Common::parsePlatform(dom.getVal("platform"));
+		Common::String desc(dom.getVal("description"));
 
 		GameList candidates(EngineMan.detectGames(files));
 		GameDescriptor *g = 0;

Modified: scummvm/trunk/common/config-manager.cpp
===================================================================
--- scummvm/trunk/common/config-manager.cpp	2010-03-29 18:58:47 UTC (rev 48416)
+++ scummvm/trunk/common/config-manager.cpp	2010-03-29 20:31:23 UTC (rev 48417)
@@ -390,10 +390,8 @@
 		return (*_activeDomain)[key];
 	else if (_appDomain.contains(key))
 		return _appDomain[key];
-	else if (_defaultsDomain.contains(key))
-		return _defaultsDomain[key];
 
-	return _emptyString;
+	return _defaultsDomain.getVal(key);
 }
 
 const String & ConfigManager::get(const String &key, const String &domName) const {
@@ -412,18 +410,7 @@
 	if (domain->contains(key))
 		return (*domain)[key];
 
-	return _defaultsDomain.get(key);
-
-	if (!domain->contains(key)) {
-#if 1
-		return _emptyString;
-#else
-		error("ConfigManager::get(%s,%s) called on non-existent key",
-					key.c_str(), domName.c_str());
-#endif
-	}
-
-	return (*domain)[key];
+	return _defaultsDomain.getVal(key);
 }
 
 int ConfigManager::getInt(const String &key, const String &domName) const {
@@ -614,14 +601,6 @@
 #pragma mark -
 
 
-const String &ConfigManager::Domain::get(const String &key) const {
-	const_iterator iter(find(key));
-	if (iter != end())
-		return iter->_value;
-
-	return ConfMan._emptyString;
-}
-
 void ConfigManager::Domain::setDomainComment(const String &comment) {
 	_domainComment = comment;
 }

Modified: scummvm/trunk/common/config-manager.h
===================================================================
--- scummvm/trunk/common/config-manager.h	2010-03-29 18:58:47 UTC (rev 48416)
+++ scummvm/trunk/common/config-manager.h	2010-03-29 20:31:23 UTC (rev 48417)
@@ -56,8 +56,6 @@
 		String _domainComment;
 
 	public:
-		const String &get(const String &key) const;
-
 		void setDomainComment(const String &comment);
 		const String &getDomainComment() const;
 
@@ -165,8 +163,6 @@
 	Domain *		_activeDomain;
 
 	String			_filename;
-
-	const String	_emptyString;
 };
 
 }	// End of namespace Common

Modified: scummvm/trunk/engines/engine.cpp
===================================================================
--- scummvm/trunk/engines/engine.cpp	2010-03-29 18:58:47 UTC (rev 48416)
+++ scummvm/trunk/engines/engine.cpp	2010-03-29 20:31:23 UTC (rev 48417)
@@ -123,8 +123,8 @@
 		(
 		!gameDomain ||
 		!gameDomain->contains("gfx_mode") ||
-		!scumm_stricmp(gameDomain->get("gfx_mode").c_str(), "normal") ||
-		!scumm_stricmp(gameDomain->get("gfx_mode").c_str(), "default")
+		!scumm_stricmp(gameDomain->getVal("gfx_mode").c_str(), "normal") ||
+		!scumm_stricmp(gameDomain->getVal("gfx_mode").c_str(), "default")
 		);
 
 	// See if the game should default to 1x scaler

Modified: scummvm/trunk/engines/kyra/detection.cpp
===================================================================
--- scummvm/trunk/engines/kyra/detection.cpp	2010-03-29 18:58:47 UTC (rev 48416)
+++ scummvm/trunk/engines/kyra/detection.cpp	2010-03-29 20:31:23 UTC (rev 48417)
@@ -1355,7 +1355,7 @@
 	// In Kyra games slot 0 can't be deleted, it's for restarting the game(s).
 	// An exception makes Lands of Lore here, it does not have any way to restart the
 	// game except via its main menu.
-	if (slot == 0 && !ConfMan.getDomain(target)->get("gameid").equalsIgnoreCase("lol"))
+	if (slot == 0 && !ConfMan.getDomain(target)->getVal("gameid").equalsIgnoreCase("lol"))
 		return;
 
 	Common::String filename = Kyra::KyraEngine_v1::getSavegameFilename(target, slot);
@@ -1376,7 +1376,7 @@
 		if (error == Kyra::KyraEngine_v1::kRSHENoError) {
 			SaveStateDescriptor desc(slot, header.description);
 
-			bool lolGame = ConfMan.getDomain(target)->get("gameid").equalsIgnoreCase("lol");
+			bool lolGame = ConfMan.getDomain(target)->getVal("gameid").equalsIgnoreCase("lol");
 
 			// Slot 0 is used for the 'restart game' save in all three Kyrandia games, thus
 			// we prevent it from being deleted.

Modified: scummvm/trunk/engines/kyra/kyra_v1.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra_v1.cpp	2010-03-29 18:58:47 UTC (rev 48416)
+++ scummvm/trunk/engines/kyra/kyra_v1.cpp	2010-03-29 20:31:23 UTC (rev 48417)
@@ -489,7 +489,7 @@
 		// the global subtitles settings, we're using this hack to enable subtitles
 		// for fan translations
 		const Common::ConfigManager::Domain *cur = ConfMan.getActiveDomain();
-		if (!cur || (cur && cur->get("subtitles").empty()))
+		if (!cur || (cur && cur->getVal("subtitles").empty()))
 			ConfMan.setBool("subtitles", true);
 	}
 }

Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp	2010-03-29 18:58:47 UTC (rev 48416)
+++ scummvm/trunk/gui/launcher.cpp	2010-03-29 20:31:23 UTC (rev 48417)
@@ -608,8 +608,8 @@
 		}
 #endif
 
-		String gameid(iter->_value.get("gameid"));
-		String description(iter->_value.get("description"));
+		String gameid(iter->_value.getVal("gameid"));
+		String description(iter->_value.getVal("description"));
 
 		if (gameid.empty())
 			gameid = iter->_key;

Modified: scummvm/trunk/gui/massadd.cpp
===================================================================
--- scummvm/trunk/gui/massadd.cpp	2010-03-29 18:58:47 UTC (rev 48416)
+++ scummvm/trunk/gui/massadd.cpp	2010-03-29 20:31:23 UTC (rev 48417)
@@ -106,7 +106,7 @@
 		}
 #endif
 
-		Common::String path(iter->_value.get("path"));
+		Common::String path(iter->_value.getVal("path"));
 		// Remove trailing slash, so that "/foo" and "/foo/" match.
 		// This works around a bug in the POSIX FS code (and others?)
 		// where paths are not normalized (so FSNodes refering to identical


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list