From 349386559c4283317321772018086e613a5a7b03 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Mon, 21 Oct 2019 17:04:11 +0200 Subject: 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 --- include/rtl/stringutils.hxx | 11 +++++++++++ include/rtl/ustrbuf.hxx | 10 ++++++++++ 2 files changed, 21 insertions(+) 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 struct CharPtrDetector { using TypeUtf16 = T; }; +template struct CharPtrDetector { using TypeUtf16 = T; }; +template struct CharPtrDetector { using TypeUtf16 = T; }; +template struct CharPtrDetector { 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 struct NonConstCharArrayDetector { + 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 libreoffice_internal::CharPtrDetector::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 libreoffice_internal::NonConstCharArrayDetector::TypeUtf16 + append(T & value) { return append(static_cast(value)); } + /** @overload @since LibreOffice 5.3 */ template typename libreoffice_internal::ConstCharArrayDetector< -- cgit v1.2.3