diff options
Diffstat (limited to 'include/rtl/ustrbuf.hxx')
-rw-r--r-- | include/rtl/ustrbuf.hxx | 52 |
1 files changed, 13 insertions, 39 deletions
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 <cassert> #include <cstring> +#include <limits> +#include <new> + +#if defined LIBO_INTERNAL_ONLY +#include <string_view> +#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 <code>OUString</code> 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 <code>OUString</code> 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<sal_Int32>::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. |