Drop the OUString vs. OUStringLiteral comparison operator overloads
...which can be subsumed by their OUString vs. OUString counterparts now that
conversion from OUStringLiteral to OUString is cheap since
e6dfaf9f44
"Turn OUStringLiteral into a
consteval'ed, static-refcound rtl_uString". (The only place that needed
adaption was the dubious use of temporary OUStringLiteral instances in
sal/qa/rtl/strings/test_oustring_stringliterals.cxx, which now caused "error:
conversion function from 'rtlunittest::OUStringLiteral<6>' to
'const rtlunittest::OUString' invokes a deleted function".)
Change-Id: I4f0f96efa2d5331ed5cbc9a29bdfdf3c0f4148a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125020
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
parent
2875c65946
commit
1ef0261539
2 changed files with 6 additions and 111 deletions
|
@ -1845,113 +1845,6 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined LIBO_INTERNAL_ONLY
|
||||
/// @cond INTERNAL
|
||||
|
||||
/* Comparison between OUString and OUStringLiteral.
|
||||
|
||||
@since LibreOffice 5.0
|
||||
*/
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator ==(OUString const & lhs, OUStringLiteral<N> const & rhs) {
|
||||
return
|
||||
rtl_ustr_reverseCompare_WithLength(
|
||||
lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength())
|
||||
== 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator !=(OUString const & lhs, OUStringLiteral<N> const & rhs) {
|
||||
return
|
||||
rtl_ustr_reverseCompare_WithLength(
|
||||
lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength())
|
||||
!= 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator <(OUString const & lhs, OUStringLiteral<N> const & rhs) {
|
||||
return
|
||||
(rtl_ustr_compare_WithLength(
|
||||
lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
|
||||
< 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator <=(OUString const & lhs, OUStringLiteral<N> const & rhs) {
|
||||
return
|
||||
(rtl_ustr_compare_WithLength(
|
||||
lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
|
||||
<= 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator >(OUString const & lhs, OUStringLiteral<N> const & rhs) {
|
||||
return
|
||||
(rtl_ustr_compare_WithLength(
|
||||
lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
|
||||
> 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator >=(OUString const & lhs, OUStringLiteral<N> const & rhs) {
|
||||
return
|
||||
(rtl_ustr_compare_WithLength(
|
||||
lhs.pData->buffer, lhs.pData->length, rhs.getStr(), rhs.getLength()))
|
||||
>= 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator ==(OUStringLiteral<N> const & lhs, OUString const & rhs) {
|
||||
return
|
||||
rtl_ustr_reverseCompare_WithLength(
|
||||
lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length)
|
||||
== 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator !=(OUStringLiteral<N> const & lhs, OUString const & rhs) {
|
||||
return
|
||||
rtl_ustr_reverseCompare_WithLength(
|
||||
lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length)
|
||||
!= 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator <(OUStringLiteral<N> const & lhs, OUString const & rhs) {
|
||||
return
|
||||
(rtl_ustr_compare_WithLength(
|
||||
lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
|
||||
< 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator <=(OUStringLiteral<N> const & lhs, OUString const & rhs) {
|
||||
return
|
||||
(rtl_ustr_compare_WithLength(
|
||||
lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
|
||||
<= 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator >(OUStringLiteral<N> const & lhs, OUString const & rhs) {
|
||||
return
|
||||
(rtl_ustr_compare_WithLength(
|
||||
lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
|
||||
> 0;
|
||||
}
|
||||
|
||||
template<std::size_t N>
|
||||
friend bool operator >=(OUStringLiteral<N> const & lhs, OUString const & rhs) {
|
||||
return
|
||||
(rtl_ustr_compare_WithLength(
|
||||
lhs.getStr(), lhs.getLength(), rhs.pData->buffer, rhs.pData->length))
|
||||
>= 0;
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
#endif
|
||||
|
||||
/**
|
||||
Returns a hashcode for this string.
|
||||
|
||||
|
|
|
@ -213,10 +213,12 @@ void test::oustring::StringLiterals::checkOUStringLiteral()
|
|||
CPPUNIT_ASSERT(
|
||||
s1.endsWithIgnoreAsciiCase(rtlunittest::OUStringLiteral(u"EFDE"), &s2));
|
||||
CPPUNIT_ASSERT_EQUAL(rtl::OUString("d"), s2);
|
||||
CPPUNIT_ASSERT(bool(s1 == rtlunittest::OUStringLiteral(u"defde")));
|
||||
CPPUNIT_ASSERT(bool(rtlunittest::OUStringLiteral(u"defde") == s1));
|
||||
CPPUNIT_ASSERT(s1 != rtlunittest::OUStringLiteral(u"abc"));
|
||||
CPPUNIT_ASSERT(rtlunittest::OUStringLiteral(u"abc") != s1);
|
||||
static constexpr rtlunittest::OUStringLiteral defde(u"defde");
|
||||
CPPUNIT_ASSERT(bool(s1 == defde));
|
||||
CPPUNIT_ASSERT(bool(defde == s1));
|
||||
static constexpr rtlunittest::OUStringLiteral abc(u"abc");
|
||||
CPPUNIT_ASSERT(s1 != abc);
|
||||
CPPUNIT_ASSERT(abc != s1);
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
sal_Int32(3), s1.indexOf(rtlunittest::OUStringLiteral(u"de"), 1));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
|
|
Loading…
Reference in a new issue