summaryrefslogtreecommitdiff
path: root/include/rtl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-06-26 13:49:25 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-06-26 13:55:30 +0200
commitedc96a157e3ab8b54046ee28df947a43330d3d3f (patch)
treef941a95670bcaed98194babba77fee143f57e1b1 /include/rtl
parent1de776a4927aa2c1e525ce28764f076061f2c8cd (diff)
Add optimized OUString += literal overload
Change-Id: Ib34196185f90204a71598f2c659c3fddce7a0e4d
Diffstat (limited to 'include/rtl')
-rw-r--r--include/rtl/ustring.h24
-rw-r--r--include/rtl/ustring.hxx18
2 files changed, 42 insertions, 0 deletions
diff --git a/include/rtl/ustring.h b/include/rtl/ustring.h
index 700393694b60..2a8cd933e3e0 100644
--- a/include/rtl/ustring.h
+++ b/include/rtl/ustring.h
@@ -1434,6 +1434,30 @@ SAL_DLLPUBLIC sal_Unicode * SAL_CALL rtl_uString_getStr(
SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcat(
rtl_uString ** newStr, rtl_uString * left, rtl_uString * right ) SAL_THROW_EXTERN_C();
+/** Create a new string that is the concatenation of two other strings.
+
+ The new string does not necessarily have a reference count of 1 (in cases
+ where the ASCII string is empty), so it must not be modified without
+ checking the reference count.
+
+ @param newString
+ pointer to the new string. The pointed-to data must be null or a valid
+ string.
+
+ @param left
+ a valid string.
+
+ @param right must not be null and must point to memory of at least
+ \p rightLength ASCII bytes
+
+ @param rightLength the length of the \p right string; must be non-negative
+
+ @since LibreOffice 5.1
+ */
+SAL_DLLPUBLIC void SAL_CALL rtl_uString_newConcatAsciiL(
+ rtl_uString ** newString, rtl_uString * left, char const * right,
+ sal_Int32 rightLength);
+
/** Create a new string by replacing a substring of another string.
The new string results from replacing a number of characters (count),
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 387a6e8099eb..d5142afc4139 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -424,6 +424,24 @@ public:
return *this;
}
+ /** Append an ASCII string literal to this string.
+
+ @param literal an 8-bit ASCII-only string literal
+
+ @since LibreOffice 5.1
+ */
+ template<typename T>
+ typename libreoffice_internal::ConstCharArrayDetector<T, OUString &>::Type
+ operator +=(T & literal) {
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ rtl_uString_newConcatAsciiL(
+ &pData, pData,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ libreoffice_internal::ConstCharArrayDetector<T>::length);
+ return *this;
+ }
+
#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
/**
@overload