Ed Tanous | 50ebd4a | 2023-01-19 19:03:17 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <string> |
| 4 | #include <string_view> |
| 5 | #include <vector> |
| 6 | |
| 7 | namespace bmcweb |
| 8 | { |
| 9 | // This is a naive replacement for boost::split until |
| 10 | // https://github.com/llvm/llvm-project/issues/40486 |
| 11 | // is resolved |
| 12 | inline void split(std::vector<std::string>& strings, std::string_view str, |
| 13 | char delim) |
| 14 | { |
| 15 | size_t start = 0; |
| 16 | size_t end = 0; |
Ed Tanous | b64c626 | 2023-02-21 10:27:14 -0800 | [diff] [blame] | 17 | while (end <= str.size()) |
Ed Tanous | 50ebd4a | 2023-01-19 19:03:17 -0800 | [diff] [blame] | 18 | { |
| 19 | end = str.find(delim, start); |
| 20 | strings.emplace_back(str.substr(start, end - start)); |
Ed Tanous | b64c626 | 2023-02-21 10:27:14 -0800 | [diff] [blame] | 21 | start = end + 1; |
Ed Tanous | 50ebd4a | 2023-01-19 19:03:17 -0800 | [diff] [blame] | 22 | } |
| 23 | } |
| 24 | } // namespace bmcweb |