mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 19:32:11 +00:00
WINTERMUTE: Cleanup and simplify StringUtil a bit.
This commit is contained in:
parent
7c984d24a8
commit
01d6ff2121
engines/wintermute
@ -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;
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -33,35 +33,9 @@
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user