From 8cfa7f4dc00f3dd37e57917ef25c806b0e9e6e73 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 27 Mar 2019 14:52:05 +0200 Subject: add more append methods to *StringBuffer which performs the append without needing the creation of a temporary *String Change-Id: If9ad3222275f26659db2e7df8d34f068977c4d17 Reviewed-on: https://gerrit.libreoffice.org/69826 Tested-by: Jenkins Reviewed-by: Noel Grandin --- include/rtl/strbuf.hxx | 20 ++++++++++++++++++++ include/rtl/ustrbuf.hxx | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'include') diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx index c674f34d997c..81100919353b 100644 --- a/include/rtl/strbuf.hxx +++ b/include/rtl/strbuf.hxx @@ -481,6 +481,26 @@ public: return append( str.getStr(), str.getLength() ); } + /** + Appends a portion of the string to this string buffer. + + The characters of the OUString argument are appended, in + order, to the contents of this string buffer, increasing the + length of this string buffer by the length of the argument. + + @param str a string. + @param beginIndex the beginning index, inclusive. + @param count the number of characters. + @return this string buffer. + @since Libreoffice 6.4 + */ + OStringBuffer & append(const OString &str, sal_Int32 beginIndex, sal_Int32 count) + { + assert( count == 0 || (beginIndex >= 0 && beginIndex < str.getLength()) ); + assert( beginIndex <= str.getLength() - count ); + return append( str.getStr() + beginIndex, count ); + } + /** Appends the string representation of the char array argument to this string buffer. diff --git a/include/rtl/ustrbuf.hxx b/include/rtl/ustrbuf.hxx index 62ba9f6b2cd7..9f3c8d1650ff 100644 --- a/include/rtl/ustrbuf.hxx +++ b/include/rtl/ustrbuf.hxx @@ -536,6 +536,26 @@ public: return append( str.getStr(), str.getLength() ); } + /** + Appends a portion of the string to this string buffer. + + The characters of the OUString argument are appended, in + order, to the contents of this string buffer, increasing the + length of this string buffer by the length of the argument. + + @param str a string. + @param beginIndex the beginning index, inclusive. + @param count the number of characters. + @return this string buffer. + @since Libreoffice 6.4 + */ + OUStringBuffer & append(const OUString &str, sal_Int32 beginIndex, sal_Int32 count) + { + assert( count == 0 || (beginIndex >= 0 && beginIndex < str.getLength()) ); + assert( beginIndex <= str.getLength() - count ); + 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())) { -- cgit