diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-06-23 15:49:30 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-06-24 15:27:27 +0200 |
commit | 3fb56b38c46849569fe2035a3f377a396e2ec8fd (patch) | |
tree | ff5f07abb31c4ca1ff653111fd523c6498032e09 /comphelper | |
parent | a9833ee9c27fef2f34ce1061ebfdf44d525c35ca (diff) |
Simplify comphelper::string::isdigitAsciiString definitions
Change-Id: I26c889e51287a239ef92a798a6899266837064d9
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/string.cxx | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx index 98391741a13d..c5637966f5a2 100644 --- a/comphelper/source/misc/string.cxx +++ b/comphelper/source/misc/string.cxx @@ -24,6 +24,7 @@ #include <vector> #include <algorithm> +#include <rtl/character.hxx> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/string.hxx> @@ -342,30 +343,18 @@ NaturalStringSorter::NaturalStringSorter( m_xBI = i18n::BreakIterator::create( rContext ); } -namespace -{ - //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 (!OPER(rString[i])) - return false; - } - return true; - } -} - bool isdigitAsciiString(const OString &rString) { - return tmpl_is_OPER_AsciiString<isdigitAscii>(rString); + return std::all_of( + rString.getStr(), rString.getStr() + rString.getLength(), + [](unsigned char c){ return rtl::isAsciiDigit(c); }); } bool isdigitAsciiString(const OUString &rString) { - return tmpl_is_OPER_AsciiString<isdigitAscii>(rString); + return std::all_of( + rString.getStr(), rString.getStr() + rString.getLength(), + rtl::isAsciiDigit); } namespace |