summaryrefslogtreecommitdiff
path: root/include/rtl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-07 10:34:54 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-14 08:35:00 +0200
commitcd66852f6dd08631a25d15a1527a647e69ab8ce3 (patch)
tree0ac1fab1d063046376e31e21d6656ee05eebb627 /include/rtl
parent095e1ca4372d90da7fc56051f1271ddd975a9e3a (diff)
create appendCopy method in OUStringBuffer
so we can avoid temporary copies when appending a substring of an OUString to the buffer. I would have preferred to call the method just "append" but that results in ambiguous method errors when the callsite is something like sal_Int32 n; OUStringBuffer s; s.append(n, 10); I'm not sure why Change-Id: I6b5b6641fcb5b26ce2269f89ef06e03c0b6aa76f Reviewed-on: https://gerrit.libreoffice.org/58666 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/ustrbuf.hxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx
index 6958093e71c8..e504cb894755 100644
--- a/include/rtl/ustrbuf.hxx
+++ b/include/rtl/ustrbuf.hxx
@@ -530,6 +530,47 @@ 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 );
+ }
+#endif // LIBO_INTERNAL_ONLY
+
/**
Appends the content of a stringbuffer to this string buffer.