blob: 7142583ee269b8f16337d24ff59f3dfe034d12af [file] [log] [blame]
Ed Tanous50ebd4a2023-01-19 19:03:17 -08001#pragma once
2
3#include <string>
4#include <string_view>
5#include <vector>
6
7namespace bmcweb
8{
9// This is a naive replacement for boost::split until
10// https://github.com/llvm/llvm-project/issues/40486
11// is resolved
12inline 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 Tanousb64c6262023-02-21 10:27:14 -080017 while (end <= str.size())
Ed Tanous50ebd4a2023-01-19 19:03:17 -080018 {
19 end = str.find(delim, start);
20 strings.emplace_back(str.substr(start, end - start));
Ed Tanousb64c6262023-02-21 10:27:14 -080021 start = end + 1;
Ed Tanous50ebd4a2023-01-19 19:03:17 -080022 }
23}
24} // namespace bmcweb