summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@libreoffice.org>2013-09-07 17:11:44 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-09-30 11:49:22 +0200
commit89de6ba4c65c8709e32fe636ff743d914cf56225 (patch)
treee74c324223f4a8e9550fe778893a7e98a82490c7 /include
parentc1df0ce01b441ffa3e6238d93e49532620a1fc93 (diff)
Introduce ASCII case conversion and use more/rtl/character.hxx.
Also remove all others implementations. Change-Id: I1dc108a9103f087bd8ce591dff2ac5dd254746f8 Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/rtl/character.hxx49
-rw-r--r--include/tools/inetmime.hxx125
2 files changed, 44 insertions, 130 deletions
diff --git a/include/rtl/character.hxx b/include/rtl/character.hxx
index 01350e19ee78..2218158e7ac7 100644
--- a/include/rtl/character.hxx
+++ b/include/rtl/character.hxx
@@ -139,6 +139,40 @@ inline bool isAsciiHexDigit(sal_uInt32 nUtf32)
return isAsciiCanonicHexDigit(nUtf32) || (nUtf32 >= 'a' && nUtf32 <= 'f');
}
+/** Convert a character, if ASCII, to upper case.
+
+ @param nChar A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return
+ nChar converted to ASCII upper case
+
+ @since LibreOffice 4.2
+*/
+inline sal_uInt32 toAsciiUpperCase(sal_uInt32 nChar)
+{
+ if( isAsciiLowerCase(nChar) )
+ nChar -= 32;
+
+ return nChar;
+}
+
+/** Convert a character, if ASCII, to lower case.
+
+ @param nChar A Unicode scalar value (represented as a UTF-32 code unit).
+
+ @return
+ nChar converted to ASCII lower case
+
+ @since LibreOffice 4.2
+*/
+inline sal_uInt32 toAsciiLowerCase(sal_uInt32 nChar)
+{
+ if( isAsciiUpperCase(nChar) )
+ nChar += 32;
+
+ return nChar;
+}
+
/** Compare two US-ASCII characters.
@param nChar1 A Unicode scalar value (represented as a UTF-32 code unit).
@@ -146,21 +180,18 @@ inline bool isAsciiHexDigit(sal_uInt32 nUtf32)
@return
0 if both strings are equal
- < 0 - if this string is less than the string argument
- > 0 - if this string is greater than the string argument
+ < 0 - if this nChar1 is less than nChar2 argument
+ > 0 - if this nChar1 is greater than the nChar2 argument
@since LibreOffice 4.2
*/
inline sal_Int32 compareAsciiIgnoreCase(sal_uInt32 nChar1, sal_uInt32 nChar2)
{
- assert(isAscii(nChar1) && isAscii(nChar2));
- if ( isAsciiUpperCase(nChar1) )
- nChar1 += 32;
- if ( isAsciiUpperCase(nChar2) )
- nChar2 += 32;
- return nChar1 - nChar2;
-}
+ nChar1 = toAsciiLowerCase(nChar1);
+ nChar2 = toAsciiLowerCase(nChar2);
+ return ((sal_Int32) nChar1) - ((sal_Int32) nChar2);
+}
}//rtl namespace
diff --git a/include/tools/inetmime.hxx b/include/tools/inetmime.hxx
index 256f350cb87d..292f7449ba7d 100644
--- a/include/tools/inetmime.hxx
+++ b/include/tools/inetmime.hxx
@@ -137,14 +137,6 @@ public:
HEADER_FIELD_ADDRESS
};
- /** Check for US-ASCII character.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is a US-ASCII character (0x00--0x7F).
- */
- static inline bool isUSASCII(sal_uInt32 nChar);
-
/** Check for ISO 8859-1 character.
@param nChar Some UCS-4 character.
@@ -180,69 +172,6 @@ public:
*/
static inline bool isVisible(sal_uInt32 nChar);
- /** Check for US-ASCII digit character.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is a US-ASCII (decimal) digit character (US-
- ASCII '0'--'9').
- */
- static inline bool isDigit(sal_uInt32 nChar);
-
- /** Check for US-ASCII canonic hexadecimal digit character.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is a US-ASCII canonic (i.e., upper case)
- hexadecimal digit character (US-ASCII '0'--'9' or 'A'--'F').
- */
- static inline bool isCanonicHexDigit(sal_uInt32 nChar);
-
- /** Check for US-ASCII hexadecimal digit character.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is a US-ASCII hexadecimal digit character (US-
- ASCII '0'--'9', 'A'--'F', 'a'--'f').
- */
- static inline bool isHexDigit(sal_uInt32 nChar);
-
- /** Check for US-ASCII upper case character.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is a US-ASCII upper case alphabetic character
- (US-ASCII 'A'--'Z').
- */
- static inline bool isUpperCase(sal_uInt32 nChar);
-
- /** Check for US-ASCII lower case character.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is a US-ASCII lower case alphabetic character
- (US-ASCII 'a'--'z').
- */
- static inline bool isLowerCase(sal_uInt32 nChar);
-
- /** Check for US-ASCII alphabetic character.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is a US-ASCII alphabetic character (US-ASCII
- 'A'--'Z' or 'a'--'z').
- */
- static inline bool isAlpha(sal_uInt32 nChar);
-
- /** Check for US-ASCII alphanumeric character.
-
- @param nChar Some UCS-4 character.
-
- @return True if nChar is a US-ASCII alphanumeric character (US-ASCII
- '0'--'9', 'A'--'Z' or 'a'--'z').
- */
- static inline bool isAlphanumeric(sal_uInt32 nChar);
-
/** Check for US-ASCII Base 64 digit character.
@param nChar Some UCS-4 character.
@@ -301,6 +230,7 @@ public:
'A'--'Z'), return the corresponding US-ASCII lower case character (US-
ASCII 'a'--'z'); otherwise, return nChar unchanged.
*/
+ SAL_DEPRECATED("Use rtl::toAsciiUpperCase instead")
static inline sal_uInt32 toUpperCase(sal_uInt32 nChar);
/** Translate an US-ASCII character to lower case.
@@ -311,6 +241,7 @@ public:
'a'--'z'), return the corresponding US-ASCII upper case character (US-
ASCII 'A'--'Z'); otherwise, return nChar unchanged.
*/
+ SAL_DEPRECATED("Use rtl::toAsciiLowerCase instead")
static inline sal_uInt32 toLowerCase(sal_uInt32 nChar);
/** Get the digit weight of a US-ASCII character.
@@ -536,12 +467,6 @@ public:
};
// static
-inline bool INetMIME::isUSASCII(sal_uInt32 nChar)
-{
- return rtl::isAscii(nChar);
-}
-
-// static
inline bool INetMIME::isISO88591(sal_uInt32 nChar)
{
return nChar <= 0xFF;
@@ -566,48 +491,6 @@ inline bool INetMIME::isVisible(sal_uInt32 nChar)
}
// static
-inline bool INetMIME::isDigit(sal_uInt32 nChar)
-{
- return rtl::isAsciiDigit(nChar);
-}
-
-// static
-inline bool INetMIME::isCanonicHexDigit(sal_uInt32 nChar)
-{
- return rtl::isAsciiCanonicHexDigit(nChar);
-}
-
-// static
-inline bool INetMIME::isHexDigit(sal_uInt32 nChar)
-{
- return rtl::isAsciiHexDigit(nChar);
-}
-
-// static
-inline bool INetMIME::isUpperCase(sal_uInt32 nChar)
-{
- return rtl::isAsciiUpperCase(nChar);
-}
-
-// static
-inline bool INetMIME::isLowerCase(sal_uInt32 nChar)
-{
- return rtl::isAsciiLowerCase(nChar);
-}
-
-// static
-inline bool INetMIME::isAlpha(sal_uInt32 nChar)
-{
- return rtl::isAsciiAlpha(nChar);
-}
-
-// static
-inline bool INetMIME::isAlphanumeric(sal_uInt32 nChar)
-{
- return rtl::isAsciiAlphanumeric(nChar);
-}
-
-// static
inline bool INetMIME::isBase64Digit(sal_uInt32 nChar)
{
return rtl::isAsciiUpperCase(nChar) || rtl::isAsciiLowerCase(nChar) || rtl::isAsciiDigit(nChar)
@@ -617,13 +500,13 @@ inline bool INetMIME::isBase64Digit(sal_uInt32 nChar)
// static
inline sal_uInt32 INetMIME::toUpperCase(sal_uInt32 nChar)
{
- return rtl::isAsciiLowerCase(nChar) ? nChar - ('a' - 'A') : nChar;
+ return rtl::toAsciiUpperCase(nChar);
}
// static
inline sal_uInt32 INetMIME::toLowerCase(sal_uInt32 nChar)
{
- return rtl::isAsciiUpperCase(nChar) ? nChar + ('a' - 'A') : nChar;
+ return rtl::toAsciiLowerCase(nChar);
}
// static