[Libreoffice-commits] core.git: include/rtl
Stephan Bergmann
sbergman at redhat.com
Tue Sep 20 09:38:54 UTC 2016
include/rtl/strbuf.hxx | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
New commits:
commit e1954f5ba5f637c9df801401db3630c8e1138ccf
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Sep 20 11:36:24 2016 +0200
Related cid#1371287: Work around missing OStringBuffer move semantics
...by adding more assign op overloads instead
Change-Id: I3686d6c29adc47b1a8c48be4260614fd53589c8b
diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx
index 2798e92..0fc3284 100644
--- a/include/rtl/strbuf.hxx
+++ b/include/rtl/strbuf.hxx
@@ -24,7 +24,7 @@
#include <cassert>
#include <cstddef>
-#include <string.h>
+#include <cstring>
#include <rtl/strbuf.h>
#include <rtl/string.hxx>
@@ -234,6 +234,57 @@ public:
return *this;
}
+ /** Assign from a string.
+
+ @since LibreOffice 5.3
+ */
+ OStringBuffer & operator =(OString const & string) {
+ sal_Int32 n = string.getLength();
+ if (n >= nCapacity) {
+ ensureCapacity(n + 16); //TODO: check for overflow
+ }
+ std::memcpy(pData->buffer, string.pData->buffer, n + 1);
+ pData->length = n;
+ return *this;
+ }
+
+ /** Assign from a string literal.
+
+ @since LibreOffice 5.3
+ */
+ template<typename T>
+ typename
+ libreoffice_internal::ConstCharArrayDetector<T, OStringBuffer &>::Type
+ operator =(T & literal) {
+ assert(
+ libreoffice_internal::ConstCharArrayDetector<T>::isValid(literal));
+ sal_Int32 const n
+ = libreoffice_internal::ConstCharArrayDetector<T>::length;
+ if (n >= nCapacity) {
+ ensureCapacity(n + 16); //TODO: check for overflow
+ }
+ std::memcpy(
+ pData->buffer,
+ libreoffice_internal::ConstCharArrayDetector<T>::toPointer(literal),
+ n + 1);
+ pData->length = n;
+ return *this;
+ }
+
+#if defined LIBO_INTERNAL_ONLY
+ /** @overload @since LibreOffice 5.3 */
+ template<typename T1, typename T2>
+ OStringBuffer & operator =(OStringConcat<T1, T2> const & concat) {
+ sal_Int32 const n = concat.length();
+ if (n >= nCapacity) {
+ ensureCapacity(n + 16); //TODO: check for overflow
+ }
+ *concat.addData(pData->buffer) = 0;
+ pData->length = n;
+ return *this;
+ }
+#endif
+
/**
Release the string data.
*/
More information about the Libreoffice-commits
mailing list