[Scummvm-git-logs] scummvm master -> 623585674b232ef4689b9daeea57ef9d83f041f3

OMGPizzaGuy noreply at scummvm.org
Tue Dec 5 03:47:15 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
623585674b ULTIMA8: Remove istring class in favor of explicit ignore case comparisons


Commit: 623585674b232ef4689b9daeea57ef9d83f041f3
    https://github.com/scummvm/scummvm/commit/623585674b232ef4689b9daeea57ef9d83f041f3
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2023-12-04T21:46:54-06:00

Commit Message:
ULTIMA8: Remove istring class in favor of explicit ignore case comparisons

Changed paths:
  R engines/ultima/ultima8/misc/istring.h
    engines/ultima/ultima8/audio/speech_flex.cpp
    engines/ultima/ultima8/audio/speech_flex.h
    engines/ultima/ultima8/conf/config_file_manager.cpp
    engines/ultima/ultima8/conf/config_file_manager.h
    engines/ultima/ultima8/games/game_data.cpp
    engines/ultima/ultima8/games/game_info.h
    engines/ultima/ultima8/games/treasure_loader.cpp
    engines/ultima/ultima8/games/treasure_loader.h
    engines/ultima/ultima8/graphics/type_flags.cpp
    engines/ultima/ultima8/misc/util.cpp


diff --git a/engines/ultima/ultima8/audio/speech_flex.cpp b/engines/ultima/ultima8/audio/speech_flex.cpp
index 670addb1294..8ce805ffdeb 100644
--- a/engines/ultima/ultima8/audio/speech_flex.cpp
+++ b/engines/ultima/ultima8/audio/speech_flex.cpp
@@ -41,7 +41,7 @@ SpeechFlex::SpeechFlex(Common::SeekableReadStream *rs) : SoundFlex(rs) {
 		unsigned int slen = 0;
 		while (off + slen < size && cbuf[off + slen])
 			slen++;
-		istring str(cbuf + off, slen);
+		Std::string str(cbuf + off, slen);
 		off += slen + 1;
 
 		TabsToSpaces(str, 1);
@@ -61,7 +61,7 @@ SpeechFlex::~SpeechFlex(void) {
 
 int SpeechFlex::getIndexForPhrase(const Std::string &phrase,
 								  uint32 start, uint32 &end) const {
-	Std::vector<istring>::const_iterator it;
+	Std::vector<Std::string>::const_iterator it;
 	int i = 1;
 
 	Std::string text = phrase.substr(start);
@@ -76,7 +76,7 @@ int SpeechFlex::getIndexForPhrase(const Std::string &phrase,
 	//debug(MM_INFO, "Looking for string: \"%s\"", text.c_str());
 
 	for (it = _phrases.begin(); it != _phrases.end(); ++it) {
-		if (text.find(it->c_str()) == 0) {
+		if (text.hasPrefixIgnoreCase(*it)) {
 			//debug(MM_INFO, "Found: %d", i);
 			end = (*it).size() + start + pos1;
 			if (end >= start + pos2)
diff --git a/engines/ultima/ultima8/audio/speech_flex.h b/engines/ultima/ultima8/audio/speech_flex.h
index 781851316a7..49127f5354c 100644
--- a/engines/ultima/ultima8/audio/speech_flex.h
+++ b/engines/ultima/ultima8/audio/speech_flex.h
@@ -24,13 +24,12 @@
 
 #include "ultima/ultima8/audio/sound_flex.h"
 #include "ultima/shared/std/containers.h"
-#include "ultima/ultima8/misc/istring.h"
 
 namespace Ultima {
 namespace Ultima8 {
 
 class SpeechFlex : public SoundFlex {
-	Std::vector<istring> _phrases;
+	Std::vector<Std::string> _phrases;
 
 public:
 	SpeechFlex(Common::SeekableReadStream *rs);
diff --git a/engines/ultima/ultima8/conf/config_file_manager.cpp b/engines/ultima/ultima8/conf/config_file_manager.cpp
index 02983f00fe3..35c968dee0a 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.cpp
+++ b/engines/ultima/ultima8/conf/config_file_manager.cpp
@@ -43,7 +43,7 @@ ConfigFileManager::~ConfigFileManager() {
 	_configFileManager = nullptr;
 }
 
-bool ConfigFileManager::readConfigFile(string fname, const istring &category) {
+bool ConfigFileManager::readConfigFile(string fname, const Std::string &category) {
 	Common::SeekableReadStream *f = FileSystem::get_instance()->ReadFile(fname);
 	if (!f) return false;
 
@@ -70,11 +70,11 @@ void ConfigFileManager::clear() {
 	_configFiles.clear();
 }
 
-void ConfigFileManager::clearRoot(const istring &category) {
+void ConfigFileManager::clearRoot(const Std::string &category) {
 	Std::vector<ConfigFile *>::iterator i = _configFiles.begin();
 
 	while (i != _configFiles.end()) {
-		if ((*i)->_category == category) {
+		if (category.equalsIgnoreCase((*i)->_category)) {
 			delete(*i);
 			i = _configFiles.erase(i);
 		} else {
@@ -83,10 +83,10 @@ void ConfigFileManager::clearRoot(const istring &category) {
 	}
 }
 
-bool ConfigFileManager::get(const istring &category, const istring &section, const istring &key, string &ret) {
+bool ConfigFileManager::get(const Std::string &category, const Std::string &section, const Std::string &key, string &ret) {
 	Std::vector<ConfigFile*>::reverse_iterator i;
 	for (i = _configFiles.rbegin(); i != _configFiles.rend(); ++i) {
-		if ((*i)->_category == category) {
+		if (category.equalsIgnoreCase((*i)->_category)) {
 			if ((*i)->_iniFile.getKey(key, section, ret)) {
 				return true;
 			}
@@ -97,7 +97,7 @@ bool ConfigFileManager::get(const istring &category, const istring &section, con
 }
 
 
-bool ConfigFileManager::get(const istring &category, const istring &section, const istring &key, int &ret) {
+bool ConfigFileManager::get(const Std::string &category, const Std::string &section, const Std::string &key, int &ret) {
 	string stringval;
 	if (!get(category, section, key, stringval))
 		return false;
@@ -106,7 +106,7 @@ bool ConfigFileManager::get(const istring &category, const istring &section, con
 	return true;
 }
 
-bool ConfigFileManager::get(const istring &category, const istring &section, const istring &key, bool &ret) {
+bool ConfigFileManager::get(const Std::string &category, const Std::string &section, const Std::string &key, bool &ret) {
 	string stringval;
 	if (!get(category, section, key, stringval))
 		return false;
@@ -115,12 +115,12 @@ bool ConfigFileManager::get(const istring &category, const istring &section, con
 	return true;
 }
 
-Std::vector<istring> ConfigFileManager::listSections(const istring &category) {
-	Std::vector<istring> sections;
+Std::vector<Std::string> ConfigFileManager::listSections(const Std::string &category) {
+	Std::vector<Std::string> sections;
 	Std::vector<ConfigFile*>::const_iterator i;
 
 	for ( i = _configFiles.begin(); i != _configFiles.end(); ++i) {
-		if ((*i)->_category == category) {
+		if (category.equalsIgnoreCase((*i)->_category)) {
 			Common::INIFile::SectionList sectionList = (*i)->_iniFile.getSections();
 			Common::INIFile::SectionList::const_iterator j;
 			for (j = sectionList.begin(); j != sectionList.end(); ++j) {
@@ -132,13 +132,13 @@ Std::vector<istring> ConfigFileManager::listSections(const istring &category) {
 	return sections;
 }
 
-KeyMap ConfigFileManager::listKeyValues(const istring &category, const istring &section) {
+KeyMap ConfigFileManager::listKeyValues(const Std::string &category, const Std::string &section) {
 	KeyMap values;
 	Std::vector<ConfigFile*>::const_iterator i;
 
 	for (i = _configFiles.begin(); i != _configFiles.end(); ++i) {
 		const ConfigFile *c = *i;
-		if (c->_category == category && c->_iniFile.hasSection(section)) {
+		if (category.equalsIgnoreCase((*i)->_category) && c->_iniFile.hasSection(section)) {
 			Common::INIFile::SectionKeyList keys = c->_iniFile.getKeys(section);
 			Common::INIFile::SectionKeyList::const_iterator j;
 			for (j = keys.begin(); j != keys.end(); ++j) {
diff --git a/engines/ultima/ultima8/conf/config_file_manager.h b/engines/ultima/ultima8/conf/config_file_manager.h
index dddb32cb793..d4030d7eb5d 100644
--- a/engines/ultima/ultima8/conf/config_file_manager.h
+++ b/engines/ultima/ultima8/conf/config_file_manager.h
@@ -24,13 +24,12 @@
 
 #include "common/formats/ini-file.h"
 #include "ultima/shared/std/string.h"
-#include "ultima/ultima8/misc/istring.h"
 #include "ultima/shared/std/containers.h"
 
 namespace Ultima {
 namespace Ultima8 {
 
-typedef Common::HashMap<istring, Std::string, Common::IgnoreCase_Hash> KeyMap;
+typedef Common::HashMap<Std::string, Std::string, Common::IgnoreCase_Hash> KeyMap;
 
 class ConfigFileManager {
 public:
@@ -38,7 +37,7 @@ public:
 	~ConfigFileManager();
 
 	struct ConfigFile {
-		istring _category;
+		Std::string _category;
 		Common::INIFile _iniFile;
 	};
 
@@ -51,30 +50,30 @@ public:
 	//! \param root The name of the root node in the file
 	//! \param readonly If true, don't write to this file's tree (or the file)
 	//! \return true if successful
-	bool readConfigFile(Std::string fname, const istring &category);
+	bool readConfigFile(Std::string fname, const Std::string &category);
 
 	//! clear everything
 	void clear();
 
 	//! clear everything in a root
-	void clearRoot(const istring &category);
+	void clearRoot(const Std::string &category);
 
 	//! get value
-	bool get(const istring &category, const istring &section, const istring &key, Std::string &ret);
+	bool get(const Std::string &category, const Std::string &section, const Std::string &key, Std::string &ret);
 	//! get value
-	bool get(const istring &category, const istring &section, const istring &key, int &ret);
+	bool get(const Std::string &category, const Std::string &section, const Std::string &key, int &ret);
 	//! get value
-	bool get(const istring &category, const istring &section, const istring &key, bool &ret);
+	bool get(const Std::string &category, const Std::string &section, const Std::string &key, bool &ret);
 
 	//! list all sections
 	//! \param category The config category to list all sections in
 	//! \return the sections. They have no guaranteed order.
-	Std::vector<istring> listSections(const istring &category);
+	Std::vector<Std::string> listSections(const Std::string &category);
 	//! list all key-value pairs in the given section.
 	//! \param category The config category for the section to list
 	//! \param section The section to list
 	//! \return the key-value pairs. They have no guaranteed order.
-	KeyMap listKeyValues(const istring &category, const istring &section);
+	KeyMap listKeyValues(const Std::string &category, const Std::string &section);
 
 private:
 	Std::vector<ConfigFile *> _configFiles;
diff --git a/engines/ultima/ultima8/games/game_data.cpp b/engines/ultima/ultima8/games/game_data.cpp
index 4db0475c811..3babd038bd2 100644
--- a/engines/ultima/ultima8/games/game_data.cpp
+++ b/engines/ultima/ultima8/games/game_data.cpp
@@ -193,8 +193,8 @@ FrameID GameData::translate(FrameID f) {
 	// TODO: allow translations to be in another shapeflex
 
 	ConfigFileManager *config = ConfigFileManager::get_instance();
-	istring category = "language";
-	istring section;
+	Std::string category = "language";
+	Std::string section;
 
 	switch (f._flexId) {
 	case GUMPS:
@@ -207,7 +207,7 @@ FrameID GameData::translate(FrameID f) {
 	char buf[100];
 	Common::sprintf_s(buf, "%d,%d", f._shapeNum, f._frameNum);
 
-	istring key = buf;
+	Std::string key = buf;
 	Std::string trans;
 	if (!config->get(category, section, key, trans)) {
 		return f;
diff --git a/engines/ultima/ultima8/games/game_info.h b/engines/ultima/ultima8/games/game_info.h
index 529c511e245..d883521d42f 100644
--- a/engines/ultima/ultima8/games/game_info.h
+++ b/engines/ultima/ultima8/games/game_info.h
@@ -22,7 +22,7 @@
 #ifndef ULTIMA8_GAMES_GAMEINFO_H
 #define ULTIMA8_GAMES_GAMEINFO_H
 
-#include "ultima/ultima8/misc/istring.h"
+#include "ultima/shared/std/string.h"
 
 namespace Ultima {
 namespace Ultima8 {
@@ -33,7 +33,7 @@ class IDataSource;
 struct GameInfo {
 	GameInfo();
 
-	istring _name;
+	Std::string _name;
 
 	enum GameType {
 		GAME_UNKNOWN = 0,
diff --git a/engines/ultima/ultima8/games/treasure_loader.cpp b/engines/ultima/ultima8/games/treasure_loader.cpp
index 447b3331d37..f8e361a144d 100644
--- a/engines/ultima/ultima8/games/treasure_loader.cpp
+++ b/engines/ultima/ultima8/games/treasure_loader.cpp
@@ -45,7 +45,7 @@ void TreasureLoader::loadDefaults() {
 	for (defaultiter = lootkeyvals.begin();
 	        defaultiter != lootkeyvals.end(); ++defaultiter) {
 		TreasureInfo ti;
-		const istring &key = defaultiter->_key;
+		const Std::string &key = defaultiter->_key;
 		const Std::string &val = defaultiter->_value;
 		bool ok = internalParse(val, ti, true);
 		if (ok) {
diff --git a/engines/ultima/ultima8/games/treasure_loader.h b/engines/ultima/ultima8/games/treasure_loader.h
index 558cf622f08..1ab2871c346 100644
--- a/engines/ultima/ultima8/games/treasure_loader.h
+++ b/engines/ultima/ultima8/games/treasure_loader.h
@@ -23,13 +23,12 @@
 #define ULTIMA8_GAMES_TREASURELOADER_H
 
 #include "ultima/ultima8/world/actors/treasure_info.h"
-#include "ultima/ultima8/misc/istring.h"
 #include "ultima/shared/std/containers.h"
 
 namespace Ultima {
 namespace Ultima8 {
 
-typedef Common::HashMap<istring, TreasureInfo, Common::IgnoreCase_Hash> TreasureMap;
+typedef Common::HashMap<Std::string, TreasureInfo, Common::IgnoreCase_Hash> TreasureMap;
 
 class TreasureLoader {
 public:
diff --git a/engines/ultima/ultima8/graphics/type_flags.cpp b/engines/ultima/ultima8/graphics/type_flags.cpp
index 0589fa9872a..e9dea92593b 100644
--- a/engines/ultima/ultima8/graphics/type_flags.cpp
+++ b/engines/ultima/ultima8/graphics/type_flags.cpp
@@ -181,12 +181,12 @@ void TypeFlags::loadWeaponInfo() {
 	ConfigFileManager *config = ConfigFileManager::get_instance();
 
 	// load weapons
-	Std::vector<istring> weaponkeys;
-	istring category = "weapons";
+	Std::vector<Std::string> weaponkeys;
+	Std::string category = "weapons";
 	weaponkeys = config->listSections(category);
-	for (Std::vector<istring>::const_iterator iter = weaponkeys.begin();
+	for (Std::vector<Std::string>::const_iterator iter = weaponkeys.begin();
 	        iter != weaponkeys.end(); ++iter) {
-		const istring &section = *iter;
+		const Std::string &section = *iter;
 		WeaponInfo *wi = new WeaponInfo;
 
 		int val = 0;
@@ -303,12 +303,12 @@ void TypeFlags::loadArmourInfo() {
 	MainShapeArchive *msf = GameData::get_instance()->getMainShapes();
 
 	// load armour
-	Std::vector<istring> armourkeys;
-	istring category = "armour";
+	Std::vector<Std::string> armourkeys;
+	Std::string category = "armour";
 	armourkeys = config->listSections(category);
-	for (Std::vector<istring>::const_iterator iter = armourkeys.begin();
+	for (Std::vector<Std::string>::const_iterator iter = armourkeys.begin();
 	        iter != armourkeys.end(); ++iter) {
-		const istring &section = *iter;
+		const Std::string &section = *iter;
 		ArmourInfo ai;
 
 		int val;
@@ -361,12 +361,12 @@ void TypeFlags::loadMonsterInfo() {
 	treasureLoader.loadDefaults();
 
 	// load monsters
-	Std::vector<istring> monsterkeys;
-	istring category = "monsters";
+	Std::vector<Std::string> monsterkeys;
+	Std::string category = "monsters";
 	monsterkeys = config->listSections(category);
-	for (Std::vector<istring>::const_iterator iter = monsterkeys.begin();
+	for (Std::vector<Std::string>::const_iterator iter = monsterkeys.begin();
 	        iter != monsterkeys.end(); ++iter) {
-		const istring section = *iter;
+		const Std::string section = *iter;
 		MonsterInfo *mi = new MonsterInfo;
 
 		int val;
diff --git a/engines/ultima/ultima8/misc/istring.h b/engines/ultima/ultima8/misc/istring.h
deleted file mode 100644
index a616e8b5c27..00000000000
--- a/engines/ultima/ultima8/misc/istring.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef ULTIMA8_MISC_ISTRING_H
-#define ULTIMA8_MISC_ISTRING_H
-
-#include "ultima/shared/std/string.h"
-
-namespace Ultima {
-namespace Ultima8 {
-
-class istring : public Std::string {
-public:
-	istring() : Std::string() {}
-	istring(const char *str) : Std::string(str) {}
-	istring(const char *str, uint32 len) : Std::string(str, len) {}
-	istring(const char *beginP, const char *endP) : Std::string(beginP, endP) {}
-	istring(const String &str) : Std::string(str) {}
-	explicit istring(char c) : Std::string(c) {}
-	istring(size_t n, char c) : Std::string(n, c) {}
-	~istring() override {}
-
-	int Compare(const string &s) const override {
-		return compareToIgnoreCase(s);
-	}
-};
-
-} // End of namespace Ultima8
-} // End of namespace Ultima
-
-#endif
diff --git a/engines/ultima/ultima8/misc/util.cpp b/engines/ultima/ultima8/misc/util.cpp
index dc6cfa1ec1b..64432010351 100644
--- a/engines/ultima/ultima8/misc/util.cpp
+++ b/engines/ultima/ultima8/misc/util.cpp
@@ -19,8 +19,8 @@
  *
  */
 
+#include "ultima/shared/std/string.h"
 #include "ultima/ultima8/misc/util.h"
-#include "ultima/ultima8/misc/istring.h"
 
 namespace Ultima {
 namespace Ultima8 {
@@ -102,8 +102,6 @@ template<class T> void TrimSpaces(T &str) {
 }
 
 template void TrimSpaces<Std::string>(Std::string &str);
-template void TrimSpaces<istring>(istring &str);
-
 
 template<class T> void TabsToSpaces(T &str, unsigned int n) {
 	T repl(n, ' ');
@@ -113,8 +111,6 @@ template<class T> void TabsToSpaces(T &str, unsigned int n) {
 }
 
 template void TabsToSpaces<Std::string>(Std::string &str, unsigned int n);
-template void TabsToSpaces<istring>(istring &str, unsigned int n);
-
 
 template<class T> void SplitString(const T &args, char sep,
 								   Std::vector<T> &argv) {
@@ -139,10 +135,6 @@ template<class T> void SplitString(const T &args, char sep,
 
 
 template void SplitString<Std::string>(const Std::string &args, char sep, Std::vector<Std::string> &argv);
-template void SplitString<istring>(const istring &args, char sep, Std::vector<istring> &argv);
-
-
-
 
 template<class T> void SplitStringKV(const T &args, char sep,
 									 Std::vector<Common::Pair<T, T> > &argv) {
@@ -172,7 +164,6 @@ template<class T> void SplitStringKV(const T &args, char sep,
 }
 
 template void SplitStringKV<Std::string>(const Std::string &args, char sep, Std::vector<Common::Pair<Std::string, Std::string> > &argv);
-template void SplitStringKV<istring>(const istring &args, char sep, Std::vector<Common::Pair<istring, istring> > &argv);
 
 } // End of namespace Ultima8
 } // End of namespace Ultima




More information about the Scummvm-git-logs mailing list