diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-09-10 12:19:52 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-09-10 23:04:32 +0200 |
commit | 350b9e36afb764661266ec8850488c6b23471de3 (patch) | |
tree | 341dad3732eab82791c52380361e8be7ac8a095e /include/rtl | |
parent | f9a4123637366d925e79b52123cb11dce1bccf0f (diff) |
Add OString::startsWithIgnoreAsciiCase
...analogous to the existing OUString::startsWihtIgnoreAsciiCase, to be used in
the next commit
Change-Id: Iad6989c16e1bda6b2b0a58e6c768f7852560bb00
Diffstat (limited to 'include/rtl')
-rw-r--r-- | include/rtl/string.hxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx index b83930e1d2c2..5930001ccc96 100644 --- a/include/rtl/string.hxx +++ b/include/rtl/string.hxx @@ -763,6 +763,55 @@ public: } /** + Check whether this string starts with a given string, ignoring the case of + ASCII letters. + + Character values between 65 and 90 (ASCII A-Z) are interpreted as + values between 97 and 122 (ASCII a-z). + This function can't be used for language specific comparison. + + @param str the substring to be compared + + @param rest if non-null, and this function returns true, then assign a + copy of the remainder of this string to *rest. + + @return true if and only if the given str appears as a substring at the + start of this string, ignoring the case of ASCII letters ("A"--"Z" and + "a"--"z") + + @since LibreOffice 5.1 + */ + bool startsWithIgnoreAsciiCase(OString const & str, OString * rest = 0) + const + { + bool b = matchIgnoreAsciiCase(str); + if (b && rest != 0) { + *rest = copy(str.getLength()); + } + return b; + } + + /** + @overload + This function accepts an ASCII string literal as its argument. + @since LibreOffice 5.1 + */ + template< typename T > + typename libreoffice_internal::ConstCharArrayDetector< T, bool >::Type + startsWithIgnoreAsciiCase(T & literal, OString * rest = 0) const + { + RTL_STRING_CONST_FUNCTION + assert( + libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal)); + bool b = matchIgnoreAsciiCase(literal); + if (b && rest != 0) { + *rest = copy( + libreoffice_internal::ConstCharArrayDetector<T>::length); + } + return b; + } + + /** Check whether this string ends with a given substring. @param str the substring to be compared |