Commit 23f03192 authored by Daniel Krebs's avatar Daniel Krebs

utils: add string joining helper

parent cad2103b
......@@ -9,6 +9,8 @@ namespace utils {
std::vector<std::string>
tokenize(std::string s, std::string delimiter);
std::string
join(std::vector<std::string> strings, std::string delimiter);
template<typename T>
void
......
......@@ -31,5 +31,24 @@ tokenize(std::string s, std::string delimiter)
return tokens;
}
std::string
join(std::vector<std::string> strings, std::string delimiter)
{
std::string out;
for(size_t i = 0; i < strings.size(); i++) {
const auto& s = strings[i];
if(s.length() > 0) {
out += strings[i];
if(i < (strings.size() - 1) and strings[i+1].length() > 0)
out += delimiter;
}
}
return out;
}
} // namespace utils
} // namespace villas
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment