added methods to String class that convert a string to upper/lower case; changed config class to keep all domains as lower case (fixes bug #scummvm)
svn-id: r5104
This commit is contained in:
parent
82f3e17cb5
commit
8a7637cfc1
4 changed files with 28 additions and 3 deletions
2
Makefile
2
Makefile
|
@ -13,7 +13,7 @@ RM_REC = $(RM) -r
|
||||||
ZIP = zip -q
|
ZIP = zip -q
|
||||||
CP = cp
|
CP = cp
|
||||||
|
|
||||||
CFLAGS = -g -O -Wall -Wstrict-prototypes -Wuninitialized -Wno-long-long -Wno-multichar -Wno-unknown-pragmas
|
CFLAGS = -g -Wall -Wstrict-prototypes -Wuninitialized -Wno-long-long -Wno-multichar -Wno-unknown-pragmas
|
||||||
DEFINES =
|
DEFINES =
|
||||||
LDFLAGS :=
|
LDFLAGS :=
|
||||||
INCLUDES:= -I. -Icommon
|
INCLUDES:= -I. -Icommon
|
||||||
|
|
|
@ -164,6 +164,7 @@ void Config::setBool(const String &key, bool value_b, const String &d)
|
||||||
void Config::set_domain(const String &d)
|
void Config::set_domain(const String &d)
|
||||||
{
|
{
|
||||||
defaultDomain = d;
|
defaultDomain = d;
|
||||||
|
defaultDomain.toLowercase();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Config::has_domain(const String &d) const
|
bool Config::has_domain(const String &d) const
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "str.h"
|
#include "str.h"
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma warning( disable : 4068 ) // unknown pragmas
|
# pragma warning( disable : 4068 ) // unknown pragmas
|
||||||
|
@ -171,6 +172,24 @@ void String::clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void String::toLowercase()
|
||||||
|
{
|
||||||
|
if (_str == 0 || _len == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < _len; ++i)
|
||||||
|
_str[i] = tolower(_str[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void String::toUppercase()
|
||||||
|
{
|
||||||
|
if (_str == 0 || _len == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < _len; ++i)
|
||||||
|
_str[i] = toupper(_str[i]);
|
||||||
|
}
|
||||||
|
|
||||||
void String::ensureCapacity(int new_len, bool keep_old)
|
void String::ensureCapacity(int new_len, bool keep_old)
|
||||||
{
|
{
|
||||||
// If there is not enough space, or if we are not the only owner
|
// If there is not enough space, or if we are not the only owner
|
||||||
|
|
|
@ -83,10 +83,12 @@ public:
|
||||||
virtual ~String();
|
virtual ~String();
|
||||||
|
|
||||||
String& operator =(const char* str);
|
String& operator =(const char* str);
|
||||||
// TODO - We should use RTTI here - that is, not real C++ RTTI but some magic
|
// TODO - We should use RTTI here - that is, not real C++ RTTI but maybe some magic
|
||||||
// constant in each string object. We want to be able to optimize the case when
|
// constant in each string object. We want to be able to optimize the case when
|
||||||
// a real 'String' object is passed to a function as a ConstString obj and then
|
// a real 'String' object is passed to a function as a ConstString obj and then
|
||||||
// assigned to a 'String' object
|
// assigned to a 'String' object.
|
||||||
|
// An alternative would be to add private clone() and cloneMutable methods that
|
||||||
|
// would do the right thing.
|
||||||
String& operator =(const String& str);
|
String& operator =(const String& str);
|
||||||
String& operator +=(const char* str);
|
String& operator +=(const char* str);
|
||||||
String& operator +=(const String& str);
|
String& operator +=(const String& str);
|
||||||
|
@ -106,6 +108,9 @@ public:
|
||||||
|
|
||||||
void deleteLastChar();
|
void deleteLastChar();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
void toLowercase();
|
||||||
|
void toUppercase();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ensureCapacity(int new_len, bool keep_old);
|
void ensureCapacity(int new_len, bool keep_old);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue