From f07a22ff6fb6c4bb131eacc9c3298b076361cee5 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 9 Feb 2012 15:22:47 +0100 Subject: gsicheck now only depends on sal --- l10ntools/source/helper.hxx | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'l10ntools/source/helper.hxx') diff --git a/l10ntools/source/helper.hxx b/l10ntools/source/helper.hxx index 27ee642dfd92..edd2d0fa3be1 100644 --- a/l10ntools/source/helper.hxx +++ b/l10ntools/source/helper.hxx @@ -35,15 +35,62 @@ #include #include "rtl/string.hxx" +#include "rtl/ustring.hxx" #include "sal/types.h" namespace helper { +inline bool isAsciiWhitespace(char c) { + return (c >= 0x09 && c <= 0x0D) || c == ' '; // HT, LF, VT, FF, CR +} + +// cf. comphelper::string::isdigitAsciiString: +inline bool isAllAsciiDigits(rtl::OString const & text) { + for (sal_Int32 i = 0; i != text.getLength(); ++i) { + if (text[i] < '0' || text[i] > '9') { + return false; + } + } + return true; +} + +// cf. comphelper::string::isupperAsciiString: +inline bool isAllAsciiUpperCase(rtl::OString const & text) { + for (sal_Int32 i = 0; i != text.getLength(); ++i) { + if (text[i] < 'A' || text[i] > 'Z') { + return false; + } + } + return true; +} + +// cf. comphelper::string::islowerAsciiString: +inline bool isAllAsciiLowerCase(rtl::OString const & text) { + for (sal_Int32 i = 0; i != text.getLength(); ++i) { + if (text[i] < 'a' || text[i] > 'z') { + return false; + } + } + return true; +} + inline bool endsWith(rtl::OString const & text, rtl::OString const & search) { return text.getLength() >= search.getLength() && text.match(search, text.getLength() - search.getLength()); } +inline rtl::OString trimAscii(rtl::OString const & text) { + sal_Int32 i1 = 0; + while (i1 != text.getLength() && isAsciiWhitespace(text[i1])) { + ++i1; + } + sal_Int32 i2 = text.getLength(); + while (i2 != i1 && isAsciiWhitespace(text[i2 - 1])) { + --i2; + } + return text.copy(i1, i2 - i1); +} + inline sal_Int32 searchAndReplace( rtl::OString * text, rtl::OString const & search, rtl::OString const & replace) -- cgit