summaryrefslogtreecommitdiff
path: root/comphelper/source/misc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-08-28 23:08:39 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-08-29 09:56:08 +0100
commit313332e76bd17c0a5a6bd67c0abc467877948a3a (patch)
tree217b63800be13ef2ebbae21c0f919467d782a287 /comphelper/source/misc
parent3422a02b5e9bd3a50518198c6ae9a9df0008edac (diff)
various centralized isFOOAsciiStrings
Diffstat (limited to 'comphelper/source/misc')
-rw-r--r--comphelper/source/misc/string.cxx45
1 files changed, 29 insertions, 16 deletions
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index 0138cc672ed8..873a1ffe34e9 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -354,21 +354,14 @@ NaturalStringSorter::NaturalStringSorter(
namespace
{
- template <typename T> bool tmpl_isalnumAsciiString(const T &rString)
+ //do OPER on each element of the string, return false
+ //if any OPER is false, true otherwise
+ template <bool (*OPER)(sal_Unicode), typename T>
+ bool tmpl_is_OPER_AsciiString(const T &rString)
{
for (sal_Int32 i = 0; i < rString.getLength(); ++i)
{
- if (!isalnumAscii(rString[i]))
- return false;
- }
- return true;
- }
-
- template <typename T> bool tmpl_isdigitAsciiString(const T &rString)
- {
- for (sal_Int32 i = 0; i < rString.getLength(); ++i)
- {
- if (!isdigitAscii(rString[i]))
+ if (!OPER(rString[i]))
return false;
}
return true;
@@ -377,22 +370,42 @@ namespace
bool isalnumAsciiString(const rtl::OString &rString)
{
- return tmpl_isalnumAsciiString(rString);
+ return tmpl_is_OPER_AsciiString<isalnumAscii>(rString);
}
bool isalnumAsciiString(const rtl::OUString &rString)
{
- return tmpl_isalnumAsciiString(rString);
+ return tmpl_is_OPER_AsciiString<isalnumAscii>(rString);
}
bool isdigitAsciiString(const rtl::OString &rString)
{
- return tmpl_isdigitAsciiString(rString);
+ return tmpl_is_OPER_AsciiString<isdigitAscii>(rString);
}
bool isdigitAsciiString(const rtl::OUString &rString)
{
- return tmpl_isdigitAsciiString(rString);
+ return tmpl_is_OPER_AsciiString<isdigitAscii>(rString);
+}
+
+bool islowerAsciiString(const rtl::OString &rString)
+{
+ return tmpl_is_OPER_AsciiString<islowerAscii>(rString);
+}
+
+bool islowerAsciiString(const rtl::OUString &rString)
+{
+ return tmpl_is_OPER_AsciiString<islowerAscii>(rString);
+}
+
+bool isupperAsciiString(const rtl::OString &rString)
+{
+ return tmpl_is_OPER_AsciiString<isupperAscii>(rString);
+}
+
+bool isupperAsciiString(const rtl::OUString &rString)
+{
+ return tmpl_is_OPER_AsciiString<isupperAscii>(rString);
}
} }