diff options
author | Mattes D <github@xoft.cz> | 2015-01-24 09:39:14 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-01-27 14:53:25 +0100 |
commit | 40e231bc29e453ecb685b02204cec46c458b80d7 (patch) | |
tree | 86f3e902bab424ecc42f56c6a1d80238411b8b7f /src/StringUtils.cpp | |
parent | Debuggers: Logging the os.clock for console-scheduled tasks. (diff) | |
download | cuberite-40e231bc29e453ecb685b02204cec46c458b80d7.tar cuberite-40e231bc29e453ecb685b02204cec46c458b80d7.tar.gz cuberite-40e231bc29e453ecb685b02204cec46c458b80d7.tar.bz2 cuberite-40e231bc29e453ecb685b02204cec46c458b80d7.tar.lz cuberite-40e231bc29e453ecb685b02204cec46c458b80d7.tar.xz cuberite-40e231bc29e453ecb685b02204cec46c458b80d7.tar.zst cuberite-40e231bc29e453ecb685b02204cec46c458b80d7.zip |
Diffstat (limited to 'src/StringUtils.cpp')
-rw-r--r-- | src/StringUtils.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index a63525356..48486a762 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; +} + + + + |