From 70519a43e0d89a6b5d89859a6851f8c757c6b0c7 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 11 Jan 2019 11:21:46 +0100 Subject: Replace OUStringBuffer::appendCopy with append(std::u16string_view) ...which is more general Change-Id: I94f28f8eda887120cf5f143b4549e0339b60e6a7 Reviewed-on: https://gerrit.libreoffice.org/66155 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- include/rtl/ustrbuf.hxx | 52 +++++++++++++------------------------------------ 1 file changed, 13 insertions(+), 39 deletions(-) (limited to 'include/rtl/ustrbuf.hxx') diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx index e504cb894755..62ba9f6b2cd7 100644 --- a/include/rtl/ustrbuf.hxx +++ b/include/rtl/ustrbuf.hxx @@ -24,6 +24,12 @@ #include #include +#include +#include + +#if defined LIBO_INTERNAL_ONLY +#include +#endif #include "rtl/ustrbuf.h" #include "rtl/ustring.hxx" @@ -530,46 +536,14 @@ public: return append( str.getStr(), str.getLength() ); } -#ifdef LIBO_INTERNAL_ONLY - /** - Appends a substring of an OUString, starting at position beginIndex. - - The characters of the OUString argument are appended, in - order, to the contents of this string buffer. - - @param str a string. - @param beginIndex the beginning index, inclusive. Must be >= 0 and <= the length of str. - @return this string buffer. - - @since LibreOffice 6.2 - */ - OUStringBuffer & appendCopy(const OUString &str, sal_Int32 beginIndex) - { - assert(beginIndex >=0 && beginIndex <= str.getLength()); - return append( str.getStr() + beginIndex, str.getLength() - beginIndex ); - } - - /** - Appends a substring of an OUString, starting at position beginIndex, - running for count characters. - - The characters of the OUString argument are appended, in - order, to the contents of this string buffer. - - @param str a string. - @param beginIndex the beginning index, inclusive. Must be >= 0 and <= the length of str. - @param count must be >= 0 and <= (str.length() - beginIndex). - @return this string buffer. - - @since LibreOffice 6.2 - */ - OUStringBuffer & appendCopy(const OUString &str, sal_Int32 beginIndex, sal_Int32 count) - { - assert(beginIndex >=0 && beginIndex <= str.getLength()); - assert(count >=0 && count <= (str.getLength() - beginIndex)); - return append( str.getStr() + beginIndex, count ); +#if defined LIBO_INTERNAL_ONLY + OUStringBuffer & append(std::u16string_view sv) { + if (sv.size() > sal_uInt32(std::numeric_limits::max())) { + throw std::bad_alloc(); + } + return append(sv.data(), sv.size()); } -#endif // LIBO_INTERNAL_ONLY +#endif /** Appends the content of a stringbuffer to this string buffer. -- cgit