summaryrefslogtreecommitdiffstats
path: root/src/StringUtils.cpp
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2015-02-06 21:52:14 +0100
committerHowaner <franzi.moos@googlemail.com>2015-02-06 21:52:14 +0100
commit2c7925f0adc17d7680ff9791832ab2c349c2301f (patch)
treeef6233b0d9dece6f7520996f2a4d850470e2c2d3 /src/StringUtils.cpp
parentReadded old DistributeStackToAreas() comment. (diff)
parentSwitched LuaState to use sizeof... (diff)
downloadcuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.gz
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.bz2
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.lz
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.xz
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.tar.zst
cuberite-2c7925f0adc17d7680ff9791832ab2c349c2301f.zip
Diffstat (limited to '')
-rw-r--r--src/StringUtils.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index a63525356..4eb2d48b6 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -905,3 +905,47 @@ bool SplitZeroTerminatedStrings(const AString & a_Strings, AStringVector & a_Out
+
+AStringVector MergeStringVectors(const AStringVector & a_Strings1, const AStringVector & a_Strings2)
+{
+ // Initialize the resulting vector by the first vector:
+ AStringVector res = a_Strings1;
+
+ // Add each item from strings2 that is not already present:
+ for (auto item : a_Strings2)
+ {
+ if (std::find(res.begin(), res.end(), item) == res.end())
+ {
+ res.push_back(item);
+ }
+ } // for item - a_Strings2[]
+
+ return res;
+}
+
+
+
+
+
+AString StringsConcat(const AStringVector & a_Strings, char a_Separator)
+{
+ // If the vector is empty, return an empty string:
+ if (a_Strings.empty())
+ {
+ return "";
+ }
+
+ // Concatenate the strings in the vector:
+ AString res;
+ res.append(a_Strings[0]);
+ for (auto itr = a_Strings.cbegin() + 1, end = a_Strings.cend(); itr != end; ++itr)
+ {
+ res.push_back(a_Separator);
+ res.append(*itr);
+ }
+ return res;
+}
+
+
+
+