Mercurial > minori
diff src/core/strings.cc @ 231:69f4768a820c
chore: merge divergent branches
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sat, 13 Jan 2024 09:43:41 -0500 |
parents | 2f5a9247e501 f784b5b1914c |
children | c130f47f6f48 |
line wrap: on
line diff
--- a/src/core/strings.cc Sat Jan 13 09:42:02 2024 -0500 +++ b/src/core/strings.cc Sat Jan 13 09:43:41 2024 -0500 @@ -36,6 +36,21 @@ return out; } +std::string Implode(const std::set<std::string>& set, const std::string& delimiter) { + if (set.size() < 1) + return "-"; + + std::string out; + + for (auto it = set.cbegin(); it != set.cend(); it++) { + out.append(*it); + if (it != std::prev(set.cend(), 1)) + out.append(delimiter); + } + + return out; +} + std::vector<std::string> Split(const std::string &text, const std::string& delimiter) { std::vector<std::string> tokens;