sal/inc/rtl/ustring.hxx | 13 +++++++++++++ sal/qa/rtl/strings/test_oustring_stringliterals.cxx | 1 + 2 files changed, 14 insertions(+)
New commits: commit c075b8068bff1b3c6025638aaf0acab5bbebab4d Author: LuboÅ¡ LuÅák <[email protected]> Date: Mon Dec 17 16:27:22 2012 +0100 OUString::reverseCompareTo() string literal overload to match the AsciiL one Change-Id: Id5ca706aa3fd1831990db2310933c6b94ca376cb diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 5760914..c9fe25e 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 a6d7145..873b536 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 ); }
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
