diff options
author | Arnaud Versini <arnaud.versini@libreoffice.org> | 2013-08-10 12:41:03 +0200 |
---|---|---|
committer | Petr Mladek <pmladek@suse.cz> | 2013-08-19 15:49:18 +0000 |
commit | c8e39e66528affb66f1ae121fa36dd4ab31a9b0b (patch) | |
tree | 227691ebad802e87695bfffb96889a1ccfe147a4 /include | |
parent | 2e45813b7e5757bc050e121acfe942763b9544ff (diff) |
Introduce rtl::compareIgnoreCase and deprecate rtl/character.hxx equivalents.
Change-Id: Id90935fd2b0f904f89477792edc8140cfc31e91f
Reviewed-on: https://gerrit.libreoffice.org/5412
Reviewed-by: Petr Mladek <pmladek@suse.cz>
Tested-by: Petr Mladek <pmladek@suse.cz>
Diffstat (limited to 'include')
-rw-r--r-- | include/rtl/character.hxx | 27 | ||||
-rw-r--r-- | include/unotools/charclass.hxx | 5 |
2 files changed, 30 insertions, 2 deletions
diff --git a/include/rtl/character.hxx b/include/rtl/character.hxx index 0ba86d6c065b..01350e19ee78 100644 --- a/include/rtl/character.hxx +++ b/include/rtl/character.hxx @@ -21,8 +21,10 @@ #define INCLUDED_RTL_CHARACTER_HXX #include "sal/config.h" - #include "sal/types.h" +#include "sal/log.hxx" + +#include <assert.h> namespace rtl { @@ -137,6 +139,29 @@ inline bool isAsciiHexDigit(sal_uInt32 nUtf32) return isAsciiCanonicHexDigit(nUtf32) || (nUtf32 >= 'a' && nUtf32 <= 'f'); } +/** Compare two US-ASCII characters. + + @param nChar1 A Unicode scalar value (represented as a UTF-32 code unit). + @param nChar2 A unicode scalar value (represented as a UTF-32 code unit). + + @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 + + @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; +} + + }//rtl namespace #endif diff --git a/include/unotools/charclass.hxx b/include/unotools/charclass.hxx index 1eb2954a0491..0522df360ce2 100644 --- a/include/unotools/charclass.hxx +++ b/include/unotools/charclass.hxx @@ -16,6 +16,7 @@ * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ + #include "unotools/unotoolsdllapi.h" #ifndef _UNOTOOLS_CHARCLASS_HXX @@ -33,7 +34,6 @@ #include <osl/mutex.hxx> #include <rtl/character.hxx> - namespace com { namespace sun { namespace star { namespace uno { class XComponentContext; @@ -93,18 +93,21 @@ public: /// isdigit() on ascii values + SAL_DEPRECATED("Use rtl::isAsciiDigit instead") static inline bool isAsciiDigit( sal_Unicode c ) { return rtl::isAsciiDigit( c ); } /// isalpha() on ascii values + SAL_DEPRECATED("Use rtl::isAsciiAlpha instead") static inline bool isAsciiAlpha( sal_Unicode c ) { return rtl::isAsciiAlpha( c ); } /// isalnum() on ascii values + SAL_DEPRECATED("Use rtl::isAsciiAlphanumeric instead") static inline bool isAsciiAlphaNumeric( sal_Unicode c ) { return rtl::isAsciiAlphanumeric( c ); |