summaryrefslogtreecommitdiffstats
path: root/src/StringUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/StringUtils.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index 42d736a8c..b7e446d53 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -228,6 +228,42 @@ AStringVector StringSplitWithQuotes(const AString & str, const AString & delim)
+
+AString StringJoin(const AStringVector & a_Strings, const AString & a_Delimeter)
+{
+ if (a_Strings.empty())
+ {
+ return {};
+ }
+
+ // Do a dry run to gather the size
+ const auto DelimSize = a_Delimeter.size();
+ size_t ResultSize = a_Strings[0].size();
+ std::for_each(a_Strings.begin() + 1, a_Strings.end(),
+ [&](const AString & a_String)
+ {
+ ResultSize += DelimSize;
+ ResultSize += a_String.size();
+ }
+ );
+
+ // Now do the actual join
+ AString Result;
+ Result.reserve(ResultSize);
+ Result.append(a_Strings[0]);
+ std::for_each(a_Strings.begin() + 1, a_Strings.end(),
+ [&](const AString & a_String)
+ {
+ Result += a_Delimeter;
+ Result += a_String;
+ }
+ );
+ return Result;
+}
+
+
+
+
AStringVector StringSplitAndTrim(const AString & str, const AString & delim)
{
AStringVector results;