diff options
Diffstat (limited to 'Source/kwsys/SystemTools.cxx')
-rw-r--r-- | Source/kwsys/SystemTools.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 930d84c..bd900fe 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -3767,6 +3767,32 @@ bool SystemTools::Split(const std::string& str, return true; } +std::string SystemTools::Join(const std::vector<std::string>& list, + const std::string& separator) +{ + std::string result; + if (list.empty()) { + return result; + } + + size_t total_size = separator.size() * (list.size() - 1); + for (const std::string& string : list) { + total_size += string.size(); + } + + result.reserve(total_size); + bool needs_separator = false; + for (const std::string& string : list) { + if (needs_separator) { + result += separator; + } + result += string; + needs_separator = true; + } + + return result; +} + /** * Return path of a full filename (no trailing slashes). * Warning: returned path is converted to Unix slashes format. |