diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-10-21 17:04:11 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-10-21 20:57:30 +0200 |
commit | 349386559c4283317321772018086e613a5a7b03 (patch) | |
tree | 47db43be1c23dd42b613f213f3a75e52378508d9 /include | |
parent | 61dc9b6aab2870faeb7cf26cdfb3d3e941642a59 (diff) |
Actually choose the OUStringBuffer::append overload for UTF-16 string literals
...instead of prefering the `const sal_Unicode *` overload
Change-Id: Idc8fd0a2188e2b3399965f303faa2aae8dcd6fd0
Reviewed-on: https://gerrit.libreoffice.org/81251
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/rtl/stringutils.hxx | 11 | ||||
-rw-r--r-- | include/rtl/ustrbuf.hxx | 10 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/rtl/stringutils.hxx b/include/rtl/stringutils.hxx index a043f753ccce..3ed4bfc8e950 100644 --- a/include/rtl/stringutils.hxx +++ b/include/rtl/stringutils.hxx @@ -133,6 +133,12 @@ struct CharPtrDetector< char*, T > typedef T Type; static const bool ok = true; }; +#if defined LIBO_INTERNAL_ONLY +template<typename T> struct CharPtrDetector<sal_Unicode *, T> { using TypeUtf16 = T; }; +template<typename T> struct CharPtrDetector<sal_Unicode const *, T> { using TypeUtf16 = T; }; +template<typename T> struct CharPtrDetector<sal_Unicode[], T> { using TypeUtf16 = T; }; +template<typename T> struct CharPtrDetector<sal_Unicode const[], T> { using TypeUtf16 = T; }; +#endif template< typename T1, typename T2 > struct NonConstCharArrayDetector @@ -156,6 +162,11 @@ struct NonConstCharArrayDetector< const char[], T > typedef T Type; }; #endif +#if defined LIBO_INTERNAL_ONLY +template<typename T, std::size_t N> struct NonConstCharArrayDetector<sal_Unicode[N], T> { + using TypeUtf16 = T; +}; +#endif template< typename T1, typename T2 = void > struct ConstCharArrayDetector diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx index 14e5fc6dda6f..a1b477498f6e 100644 --- a/include/rtl/ustrbuf.hxx +++ b/include/rtl/ustrbuf.hxx @@ -596,7 +596,13 @@ public: @param str the characters to be appended. @return this string buffer. */ +#if defined LIBO_INTERNAL_ONLY + template<typename T> + typename libreoffice_internal::CharPtrDetector<T, OUStringBuffer &>::TypeUtf16 + append(T const & str) +#else OUStringBuffer & append( const sal_Unicode * str ) +#endif { return append( str, rtl_ustr_getLength( str ) ); } @@ -637,6 +643,10 @@ public: } #if defined LIBO_INTERNAL_ONLY + template<typename T> + typename libreoffice_internal::NonConstCharArrayDetector<T, OUStringBuffer &>::TypeUtf16 + append(T & value) { return append(static_cast<sal_Unicode *>(value)); } + /** @overload @since LibreOffice 5.3 */ template<typename T> typename libreoffice_internal::ConstCharArrayDetector< |