Added toUpper and toLower methods in String.

git-svn-id: http://voip.null.ro/svn/yate@139 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2004-12-24 03:26:13 +00:00
parent a966742d8e
commit fb3db14135
2 changed files with 34 additions and 0 deletions

View File

@ -320,6 +320,28 @@ bool String::toBoolean(bool defvalue) const
return defvalue;
}
String& String::toUpper()
{
if (m_string) {
for (char *s = m_string; char c = *s; s++) {
if (('a' <= c) && (c <= 'z'))
*s = c + 'A' - 'a';
}
}
return *this;
}
String& String::toLower()
{
if (m_string) {
for (char *s = m_string; char c = *s; s++) {
if (('A' <= c) && (c <= 'Z'))
*s = c + 'a' - 'Z';
}
}
return *this;
}
String& String::trimBlanks()
{
if (m_string) {

View File

@ -586,6 +586,18 @@ public:
*/
bool toBoolean(bool defvalue = false) const;
/**
* Turn the string to an all-uppercase string
* @return A reference to this String
*/
String& toUpper();
/**
* Turn the string to an all-lowercase string
* @return A reference to this String
*/
String& toLower();
/**
* Indexing operator
* @param index Index of character in string