summaryrefslogtreecommitdiff
path: root/stoc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-08-29 00:36:22 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-08-29 09:56:08 +0100
commit3829892dbc5475a49250729541be369ea9532d28 (patch)
tree9a57bc4865772c6613db2c71c6fde609d8563e09 /stoc
parentde82a40f84c69081a517617989c344ec9597cb45 (diff)
merge together 5 or ascii isalpha/isalnum/isdigit implementations
Diffstat (limited to 'stoc')
-rw-r--r--stoc/prj/build.lst2
-rw-r--r--stoc/source/uriproc/UriReferenceFactory.cxx41
2 files changed, 15 insertions, 28 deletions
diff --git a/stoc/prj/build.lst b/stoc/prj/build.lst
index c7a1fe693919..f55be3005116 100644
--- a/stoc/prj/build.lst
+++ b/stoc/prj/build.lst
@@ -1,4 +1,4 @@
-tc stoc : DESKTOP:rdbmaker cppuhelper cppu jvmaccess sal salhelper jvmfwk xmlreader LIBXSTL:libxslt registry NULL
+tc stoc : DESKTOP:rdbmaker cppuhelper comphelper cppu jvmaccess sal salhelper jvmfwk xmlreader LIBXSTL:libxslt registry NULL
tc stoc usr1 - all tc_mkout NULL
tc stoc\inc nmake - all tc_inc NULL
tc stoc\source\defaultregistry nmake - all tc_defr tc_boot tc_inc NULL
diff --git a/stoc/source/uriproc/UriReferenceFactory.cxx b/stoc/source/uriproc/UriReferenceFactory.cxx
index 1d87c69ab07c..afba3ca4da7c 100644
--- a/stoc/source/uriproc/UriReferenceFactory.cxx
+++ b/stoc/source/uriproc/UriReferenceFactory.cxx
@@ -51,6 +51,7 @@
#include "cppuhelper/implbase1.hxx"
#include "cppuhelper/implbase2.hxx"
#include "cppuhelper/weak.hxx"
+#include "comphelper/string.hxx"
#include "osl/diagnose.h"
#include "rtl/string.h"
#include "rtl/ustrbuf.hxx"
@@ -64,30 +65,16 @@
namespace css = com::sun::star;
-namespace {
-
-bool isDigit(sal_Unicode c) { //TODO: generally available?
- return c >= '0' && c <= '9';
-}
+using comphelper::string::isalphaAscii;
+using comphelper::string::isdigitAscii;
+using comphelper::string::isxdigitAscii;
+using comphelper::string::islowerAscii;
+using comphelper::string::isupperAscii;
-bool isUpperCase(sal_Unicode c) { //TODO: generally available?
- return c >= 'A' && c <= 'Z';
-}
-
-bool isLowerCase(sal_Unicode c) { //TODO: generally available?
- return c >= 'a' && c <= 'z';
-}
-
-bool isAlpha(sal_Unicode c) { //TODO: generally available?
- return isUpperCase(c) || isLowerCase(c);
-}
-
-bool isHexDigit(sal_Unicode c) { //TODO: generally available?
- return isDigit(c) || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
-}
+namespace {
sal_Unicode toLowerCase(sal_Unicode c) { //TODO: generally available?
- return isUpperCase(c) ? c + ('a' - 'A') : c;
+ return isupperAscii(c) ? c + ('a' - 'A') : c;
}
bool equalIgnoreCase(sal_Unicode c1, sal_Unicode c2) {
@@ -99,8 +86,8 @@ bool equalIgnoreEscapeCase(rtl::OUString const & s1, rtl::OUString const & s2) {
if (s1.getLength() == s2.getLength()) {
for (sal_Int32 i = 0; i < s1.getLength();) {
if (s1[i] == '%' && s2[i] == '%' && s1.getLength() - i > 2
- && isHexDigit(s1[i + 1]) && isHexDigit(s1[i + 2])
- && isHexDigit(s2[i + 1]) && isHexDigit(s2[i + 2])
+ && isxdigitAscii(s1[i + 1]) && isxdigitAscii(s1[i + 2])
+ && isxdigitAscii(s2[i + 1]) && isxdigitAscii(s2[i + 2])
&& equalIgnoreCase(s1[i + 1], s2[i + 1])
&& equalIgnoreCase(s1[i + 2], s2[i + 2]))
{
@@ -118,12 +105,12 @@ bool equalIgnoreEscapeCase(rtl::OUString const & s1, rtl::OUString const & s2) {
}
sal_Int32 parseScheme(rtl::OUString const & uriReference) {
- if (uriReference.getLength() >= 2 && isAlpha(uriReference[0])) {
+ if (uriReference.getLength() >= 2 && isalphaAscii(uriReference[0])) {
for (sal_Int32 i = 0; i < uriReference.getLength(); ++i) {
sal_Unicode c = uriReference[i];
if (c == ':') {
return i;
- } else if (!isAlpha(c) && !isDigit(c) && c != '+' && c != '-'
+ } else if (!isalphaAscii(c) && !isdigitAscii(c) && c != '+' && c != '-'
&& c != '.')
{
break;
@@ -392,7 +379,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse(
RTL_CONSTASCII_STRINGPARAM("com.sun.star.uri.UriSchemeParser_"));
for (sal_Int32 i = 0; i < scheme.getLength(); ++i) {
sal_Unicode c = scheme[i];
- if (isUpperCase(c)) {
+ if (isupperAscii(c)) {
buf.append(toLowerCase(c));
} else if (c == '+') {
buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("PLUS"));
@@ -401,7 +388,7 @@ css::uno::Reference< css::uri::XUriReference > Factory::parse(
} else if (c == '.') {
buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("DOT"));
} else {
- OSL_ASSERT(isLowerCase(c) || isDigit(c));
+ OSL_ASSERT(islowerAscii(c) || isdigitAscii(c));
buf.append(c);
}
}