f325b2
From b038b07bec23311c246fb71aac1d38431bc50fc4 Mon Sep 17 00:00:00 2001
f325b2
From: Miklos Vajna <vmiklos@collabora.co.uk>
f325b2
Date: Thu, 8 Oct 2015 08:33:09 +0200
f325b2
Subject: [PATCH 191/398] comphelper: add string::join()
f325b2
f325b2
If there is a need for it, this could be extended later to work with uno
f325b2
sequences and/or OUStrings as well.
f325b2
f325b2
Change-Id: Id0af8b1755c8e4b668720563d10a052337e1b2c9
f325b2
(cherry picked from commit fce720b3e4691eb3b7deef1d005d76b23123a5cb)
f325b2
---
f325b2
 comphelper/source/misc/string.cxx | 11 +++++++++++
f325b2
 include/comphelper/string.hxx     |  4 ++++
f325b2
 2 files changed, 15 insertions(+)
f325b2
f325b2
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
f325b2
index 98391741a13d..c6fa2fdde270 100644
f325b2
--- a/comphelper/source/misc/string.cxx
f325b2
+++ b/comphelper/source/misc/string.cxx
f325b2
@@ -269,6 +269,17 @@ uno::Sequence< OUString >
f325b2
     return kws;
f325b2
 }
f325b2
 
f325b2
+OString join(const OString& rSeparator, const std::vector<OString>& rSequence)
f325b2
+{
f325b2
+    OStringBuffer aBuffer;
f325b2
+    for (size_t i = 0; i < rSequence.size(); ++i)
f325b2
+    {
f325b2
+        if (i != 0)
f325b2
+            aBuffer.append(rSeparator);
f325b2
+        aBuffer.append(rSequence[i]);
f325b2
+    }
f325b2
+    return aBuffer.makeStringAndClear();
f325b2
+}
f325b2
 
f325b2
 sal_Int32 compareNatural( const OUString & rLHS, const OUString & rRHS,
f325b2
     const uno::Reference< i18n::XCollator > &rCollator,
f325b2
diff --git a/include/comphelper/string.hxx b/include/comphelper/string.hxx
f325b2
index b9680372c21b..8d2552266cf2 100644
f325b2
--- a/include/comphelper/string.hxx
f325b2
+++ b/include/comphelper/string.hxx
f325b2
@@ -23,6 +23,7 @@
f325b2
 #include <sal/config.h>
f325b2
 
f325b2
 #include <cstddef>
f325b2
+#include <vector>
f325b2
 #include <comphelper/comphelperdllapi.h>
f325b2
 #include <sal/types.h>
f325b2
 #include <rtl/strbuf.hxx>
f325b2
@@ -310,6 +311,9 @@ COMPHELPER_DLLPUBLIC sal_Int32 indexOfAny(OUString const& rIn,
f325b2
 COMPHELPER_DLLPUBLIC OUString convertCommaSeparated(
f325b2
     ::com::sun::star::uno::Sequence< OUString > const & i_rSeq);
f325b2
 
f325b2
+/// Return a string which is the concatenation of the strings in the sequence.
f325b2
+COMPHELPER_DLLPUBLIC OString join(const OString& rSeparator, const std::vector<OString>& rSequence);
f325b2
+
f325b2
 /** Convert a decimal string to a number.
f325b2
 
f325b2
     The string must be base-10, no sign but can contain any
f325b2
-- 
f325b2
2.12.0
f325b2