xref: /openbmc/bmcweb/include/str_utility.hpp (revision f263e09c)
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;
17     while (end <= str.size())
18     {
19         end = str.find(delim, start);
20         strings.emplace_back(str.substr(start, end - start));
21         start = end + 1;
22     }
23 }
24 } // namespace bmcweb
25