aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-09 04:17:28 +0200
committerEinar Johan Trøan Sømåen2012-07-09 04:17:28 +0200
commit01d6ff21212a2d323717a3a1dc9e7b72cdd6adb7 (patch)
treeffa8808ad59b6482e8f66cc0c1fa71ba67b1a237 /engines/wintermute
parent7c984d24a8cd2ebe5a7860e21cda392edada34b3 (diff)
downloadscummvm-rg350-01d6ff21212a2d323717a3a1dc9e7b72cdd6adb7.tar.gz
scummvm-rg350-01d6ff21212a2d323717a3a1dc9e7b72cdd6adb7.tar.bz2
scummvm-rg350-01d6ff21212a2d323717a3a1dc9e7b72cdd6adb7.zip
WINTERMUTE: Cleanup and simplify StringUtil a bit.
Diffstat (limited to 'engines/wintermute')
-rw-r--r--engines/wintermute/Base/BStringTable.cpp10
-rw-r--r--engines/wintermute/Base/scriptables/SXString.cpp4
-rw-r--r--engines/wintermute/Base/scriptables/ScEngine.cpp2
-rw-r--r--engines/wintermute/utils/PathUtil.cpp2
-rw-r--r--engines/wintermute/utils/StringUtil.cpp40
-rw-r--r--engines/wintermute/utils/StringUtil.h4
6 files changed, 10 insertions, 52 deletions
diff --git a/engines/wintermute/Base/BStringTable.cpp b/engines/wintermute/Base/BStringTable.cpp
index 8d8b6b0fd1..9098994054 100644
--- a/engines/wintermute/Base/BStringTable.cpp
+++ b/engines/wintermute/Base/BStringTable.cpp
@@ -58,13 +58,13 @@ ERRORCODE CBStringTable::addString(const char *key, const char *val, bool report
return STATUS_OK;
}
- Common::String final_key = key;
- StringUtil::toLowerCase(final_key);
+ Common::String finalKey = key;
+ finalKey.toLowercase();
- _stringsIter = _strings.find(final_key);
- if (_stringsIter != _strings.end() && reportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", final_key.c_str());
+ _stringsIter = _strings.find(finalKey);
+ if (_stringsIter != _strings.end() && reportDuplicities) Game->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str());
- _strings[final_key] = val;
+ _strings[finalKey] = val;
return STATUS_OK;
}
diff --git a/engines/wintermute/Base/scriptables/SXString.cpp b/engines/wintermute/Base/scriptables/SXString.cpp
index 1ddec89ee6..2ad8a36ff7 100644
--- a/engines/wintermute/Base/scriptables/SXString.cpp
+++ b/engines/wintermute/Base/scriptables/SXString.cpp
@@ -181,7 +181,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
else
str = StringUtil::ansiToWide(_string);
- StringUtil::toUpperCase(str);
+ str.toUppercase();
if (Game->_textEncoding == TEXT_UTF8)
stack->pushString(StringUtil::wideToUtf8(str).c_str());
@@ -203,7 +203,7 @@ ERRORCODE CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *
else
str = StringUtil::ansiToWide(_string);
- StringUtil::toLowerCase(str);
+ str.toLowercase();
if (Game->_textEncoding == TEXT_UTF8)
stack->pushString(StringUtil::wideToUtf8(str).c_str());
diff --git a/engines/wintermute/Base/scriptables/ScEngine.cpp b/engines/wintermute/Base/scriptables/ScEngine.cpp
index 639fd0d6cd..089978ece3 100644
--- a/engines/wintermute/Base/scriptables/ScEngine.cpp
+++ b/engines/wintermute/Base/scriptables/ScEngine.cpp
@@ -658,7 +658,7 @@ void CScEngine::addScriptTime(const char *filename, uint32 time) {
if (!_isProfiling) return;
AnsiString fileName = filename;
- StringUtil::toLowerCase(fileName);
+ fileName.toLowercase();
_scriptTimes[fileName] += time;
}
diff --git a/engines/wintermute/utils/PathUtil.cpp b/engines/wintermute/utils/PathUtil.cpp
index 5c12a71c33..b148c80300 100644
--- a/engines/wintermute/utils/PathUtil.cpp
+++ b/engines/wintermute/utils/PathUtil.cpp
@@ -47,7 +47,7 @@ AnsiString PathUtil::unifySeparators(const AnsiString &path) {
//////////////////////////////////////////////////////////////////////////
AnsiString PathUtil::normalizeFileName(const AnsiString &path) {
AnsiString newPath = unifySeparators(path);
- StringUtil::toLowerCase(newPath);
+ newPath.toLowercase();
return newPath;
}
diff --git a/engines/wintermute/utils/StringUtil.cpp b/engines/wintermute/utils/StringUtil.cpp
index 53ad4c8add..c5ad025939 100644
--- a/engines/wintermute/utils/StringUtil.cpp
+++ b/engines/wintermute/utils/StringUtil.cpp
@@ -34,34 +34,8 @@
namespace WinterMute {
//////////////////////////////////////////////////////////////////////////
-void StringUtil::toLowerCase(AnsiString &str) {
- str.toLowercase();
-}
-
-//////////////////////////////////////////////////////////////////////////
-/*void StringUtil::toLowerCase(WideString &str) {
- std::transform(str.begin(), str.end(), str.begin(), ::towlower);
-}*/
-
-//////////////////////////////////////////////////////////////////////////
-void StringUtil::toUpperCase(AnsiString &str) {
- str.toUppercase();
-}
-
-//////////////////////////////////////////////////////////////////////////
-/*void StringUtil::toUpperCase(WideString &str) {
- std::transform(str.begin(), str.end(), str.begin(), ::towupper);
-}*/
-
-//////////////////////////////////////////////////////////////////////////
bool StringUtil::compareNoCase(const AnsiString &str1, const AnsiString &str2) {
- AnsiString str1lc = str1;
- AnsiString str2lc = str2;
-
- toLowerCase(str1lc);
- toLowerCase(str2lc);
-
- return (str1lc == str2lc);
+ return (str1.compareToIgnoreCase(str2) == 0);
}
//////////////////////////////////////////////////////////////////////////
@@ -369,33 +343,21 @@ int StringUtil::lastIndexOf(const WideString &str, const WideString &toFind, siz
//////////////////////////////////////////////////////////////////////////
AnsiString StringUtil::toString(size_t val) {
- /* std::ostringstream str;
- str << val;
- return str.str();*/
return Common::String::format("%u", (uint32)val);
}
//////////////////////////////////////////////////////////////////////////
AnsiString StringUtil::toString(int val) {
- /* std::ostringstream str;
- str << val;
- return str.str();*/
return Common::String::format("%d", val);
}
//////////////////////////////////////////////////////////////////////////
AnsiString StringUtil::toString(float val) {
- /* std::ostringstream str;
- str << val;
- return str.str();*/
return Common::String::format("%f", val);
}
//////////////////////////////////////////////////////////////////////////
AnsiString StringUtil::toString(double val) {
- /* std::ostringstream str;
- str << val;
- return str.str();*/
return Common::String::format("%f", val);
}
diff --git a/engines/wintermute/utils/StringUtil.h b/engines/wintermute/utils/StringUtil.h
index e06551b09a..794007276b 100644
--- a/engines/wintermute/utils/StringUtil.h
+++ b/engines/wintermute/utils/StringUtil.h
@@ -35,10 +35,6 @@ namespace WinterMute {
class StringUtil {
public:
- static void toLowerCase(AnsiString &str);
- //static void toLowerCase(WideString &str);
- static void toUpperCase(AnsiString &str);
- //static void toUpperCase(WideString &str);
static bool compareNoCase(const AnsiString &str1, const AnsiString &str2);
//static bool compareNoCase(const WideString &str1, const WideString &str2);
static WideString utf8ToWide(const Utf8String &Utf8Str);