diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-12-17 16:27:22 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-12-17 16:27:56 +0100 |
commit | c075b8068bff1b3c6025638aaf0acab5bbebab4d (patch) | |
tree | aa5f59bde99feb0bfefe3bfec34caceebe414a14 /sal | |
parent | 1b0591e934540db3bb31342ccc7849ed49338a96 (diff) |
OUString::reverseCompareTo() string literal overload to match the AsciiL one
Change-Id: Id5ca706aa3fd1831990db2310933c6b94ca376cb
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 13 | ||||
-rw-r--r-- | sal/qa/rtl/strings/test_oustring_stringliterals.cxx | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 5760914fcc3f..c9fe25ec6131 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -528,6 +528,19 @@ public: } /** + @overload + This function accepts an ASCII string literal as its argument. + @since LibreOffice 4.1 + */ + template< typename T > + typename internal::ConstCharArrayDetector< T, sal_Int32 >::Type reverseCompareTo( T& literal ) const SAL_THROW(()) + { + assert( strlen( literal ) == internal::ConstCharArrayDetector< T >::size - 1 ); + return rtl_ustr_asciil_reverseCompare_WithLength( pData->buffer, pData->length, + literal, internal::ConstCharArrayDetector< T, void >::size - 1 ); + } + + /** Perform a comparison of two strings. The result is true if and only if second string diff --git a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx index a6d7145b9700..873b5366f6a5 100644 --- a/sal/qa/rtl/strings/test_oustring_stringliterals.cxx +++ b/sal/qa/rtl/strings/test_oustring_stringliterals.cxx @@ -145,6 +145,7 @@ void test::oustring::StringLiterals::checkUsage() CPPUNIT_ASSERT( foobarfoo.replaceFirst( "foo", "test" ) == "testbarfoo" ); CPPUNIT_ASSERT( foobarfoo.replaceAll( "foo", test ) == "testbartest" ); CPPUNIT_ASSERT( foobarfoo.replaceAll( "foo", "test" ) == "testbartest" ); + CPPUNIT_ASSERT( foo.reverseCompareTo( "foo" ) == 0 ); // if this is not true, some of the calls above converted to OUString CPPUNIT_ASSERT( rtl_string_unittest_const_literal == false ); } |