From fb3db14135d6f3c9d5a4857ac4af5b556dce4888 Mon Sep 17 00:00:00 2001 From: paulc Date: Fri, 24 Dec 2004 03:26:13 +0000 Subject: [PATCH] Added toUpper and toLower methods in String. git-svn-id: http://voip.null.ro/svn/yate@139 acf43c95-373e-0410-b603-e72c3f656dc1 --- engine/String.cpp | 22 ++++++++++++++++++++++ yatengine.h | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/engine/String.cpp b/engine/String.cpp index 45cbf06c..8f9263c2 100644 --- a/engine/String.cpp +++ b/engine/String.cpp @@ -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) { diff --git a/yatengine.h b/yatengine.h index a8da3b14..97783a9e 100644 --- a/yatengine.h +++ b/yatengine.h @@ -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