summaryrefslogtreecommitdiff
path: root/include/rtl/ustrbuf.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-01-11 11:21:46 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-01-11 13:55:14 +0100
commit70519a43e0d89a6b5d89859a6851f8c757c6b0c7 (patch)
treebc1f4a6b6510e3bff75e9dc54eb71e2fa6cfc3c8 /include/rtl/ustrbuf.hxx
parenta0210c5c5e8fd47b55567a8b18788d57d2b7decb (diff)
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 <sbergman@redhat.com>
Diffstat (limited to 'include/rtl/ustrbuf.hxx')
-rw-r--r--include/rtl/ustrbuf.hxx52
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.