diff options
author | Brad King <brad.king@kitware.com> | 2021-10-12 15:38:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-10-12 15:38:24 (GMT) |
commit | 8d14ca3142d869eed7be953e156718f51a855e02 (patch) | |
tree | 037d24b3eef74bca6b067e3f6416e3f4209ad50e /Source/kwsys/SystemTools.cxx | |
parent | 6f1fe83f865edb276aa78dd9f5dda1dbebcf21e3 (diff) | |
parent | 58f046ba26d67c6e1ceda2a20977e316f1a942ad (diff) | |
download | CMake-8d14ca3142d869eed7be953e156718f51a855e02.zip CMake-8d14ca3142d869eed7be953e156718f51a855e02.tar.gz CMake-8d14ca3142d869eed7be953e156718f51a855e02.tar.bz2 |
Merge branch 'upstream-KWSys' into update-kwsys
# By KWSys Upstream
* upstream-KWSys:
KWSys 2021-10-08 (b8c734ba)
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. |