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