2024-05-31 22:59:00 -04:00
|
|
|
#ifndef RFL_INTERNAL_STRINGS_SPLIT_HPP_
|
|
|
|
#define RFL_INTERNAL_STRINGS_SPLIT_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
|
|
|
/// Splits a string alongside the delimiter
|
|
|
|
inline std::vector<std::string> split(const std::string& _str,
|
|
|
|
const std::string& _delimiter) {
|
|
|
|
auto str = _str;
|
|
|
|
size_t pos = 0;
|
|
|
|
std::vector<std::string> result;
|
|
|
|
while ((pos = str.find(_delimiter)) != std::string::npos) {
|
|
|
|
result.emplace_back(str.substr(0, pos));
|
|
|
|
str.erase(0, pos + _delimiter.length());
|
|
|
|
}
|
|
|
|
result.emplace_back(std::move(str));
|
|
|
|
return result;
|
|
|
|
}
|
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
|