2024-05-31 22:59:00 -04:00
|
|
|
#ifndef RFL_INTERNAL_STRINGS_JOIN_HPP_
|
|
|
|
#define RFL_INTERNAL_STRINGS_JOIN_HPP_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace rfl {
|
2024-06-08 14:10:59 -04:00
|
|
|
namespace internal {
|
|
|
|
namespace strings {
|
2024-05-31 22:59:00 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
/// Joins a string using the delimiter
|
2024-06-08 15:53:06 -04:00
|
|
|
inline std::string join(
|
|
|
|
const std::string& _delimiter,
|
|
|
|
const std::vector<std::string>& _strings
|
|
|
|
) {
|
2024-06-09 18:55:00 -04:00
|
|
|
if (_strings.size() == 0) {
|
|
|
|
return "";
|
|
|
|
}
|
2024-06-08 14:10:59 -04:00
|
|
|
auto res = _strings[0];
|
|
|
|
for (size_t i = 1; i < _strings.size(); ++i) {
|
|
|
|
res += _delimiter + _strings[i];
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
2024-05-31 22:59:00 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
} // namespace strings
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace rfl
|
2024-05-31 22:59:00 -04:00
|
|
|
|
|
|
|
#endif
|