diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-03-28 08:56:05 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-03-28 09:07:17 +0200 |
commit | 2ebda60bfe7897ac371dd7ee97c4309e72f20e4b (patch) | |
tree | f6f42a14ccd351201aae4a9f316617f8cec50b3d /sal/inc/rtl | |
parent | 86ebc8471d5e056a1240e5f9d487c5b1c9b3d423 (diff) |
more SFINAE to distinguish between const char* and const char[]
Diffstat (limited to 'sal/inc/rtl')
-rw-r--r-- | sal/inc/rtl/string.hxx | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index e7db97b6ed4e..0593ddf25eec 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -799,18 +799,8 @@ public: friend sal_Bool operator == ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(()) { return rStr1.getLength() == rStr2.getLength() && rStr1.compareTo( rStr2 ) == 0; } - friend sal_Bool operator == ( const OString& rStr1, const sal_Char * pStr2 ) SAL_THROW(()) - { return rStr1.compareTo( pStr2 ) == 0; } - friend sal_Bool operator == ( const sal_Char * pStr1, const OString& rStr2 ) SAL_THROW(()) - { return OString( pStr1 ).compareTo( rStr2 ) == 0; } - friend sal_Bool operator != ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(()) { return !(operator == ( rStr1, rStr2 )); } - friend sal_Bool operator != ( const OString& rStr1, const sal_Char * pStr2 ) SAL_THROW(()) - { return !(operator == ( rStr1, pStr2 )); } - friend sal_Bool operator != ( const sal_Char * pStr1, const OString& rStr2 ) SAL_THROW(()) - { return !(operator == ( pStr1, rStr2 )); } - friend sal_Bool operator < ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(()) { return rStr1.compareTo( rStr2 ) < 0; } friend sal_Bool operator > ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(()) @@ -820,6 +810,18 @@ public: friend sal_Bool operator >= ( const OString& rStr1, const OString& rStr2 ) SAL_THROW(()) { return rStr1.compareTo( rStr2 ) >= 0; } + template< typename T > + friend typename internal::CharPtrDetector< T, bool >::Type operator==( const OString& rStr1, const T& value ) SAL_THROW(()) + { + return rStr1.compareTo( value ) == 0; + } + + template< typename T > + friend typename internal::CharPtrDetector< T, bool >::Type operator==( const T& value, const OString& rStr2 ) SAL_THROW(()) + { + return rStr2.compareTo( value ) == 0; + } + /** @overload This function accepts an ASCII string literal as its argument. @@ -829,8 +831,8 @@ public: friend bool operator == ( const OString& rStr, const char (&literal)[ N ] ) SAL_THROW(()) { RTL_STRING_CONST_FUNCTION - return rStr.getLength() == N - 1 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, - literal, N - 1 ); + return rStr.getLength() == N - 1 + && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal, N - 1 ) == 0; } /** @@ -856,8 +858,8 @@ public: friend bool operator == ( const char (&literal)[ N ], const OString& rStr ) SAL_THROW(()) { RTL_STRING_CONST_FUNCTION - return rStr.getLength() == N - 1 && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, - literal, N - 1 ); + return rStr.getLength() == N - 1 + && rtl_str_compare_WithLength( rStr.pData->buffer, rStr.pData->length, literal, N - 1 ) == 0; } /** @@ -874,6 +876,18 @@ public: return rStr.compareTo( value ) == 0; } + template< typename T > + friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const OString& rStr1, const T& value ) SAL_THROW(()) + { + return !(operator == ( rStr1, value )); + } + + template< typename T > + friend typename internal::CharPtrDetector< T, bool >::Type operator!=( const T& value, const OString& rStr2 ) SAL_THROW(()) + { + return !(operator == ( value, rStr2 )); + } + /** @overload This function accepts an ASCII string literal as its argument. |