26#ifndef DUMUX_COMMON_STRING_UTILITIES_HH
27#define DUMUX_COMMON_STRING_UTILITIES_HH
50std::vector<std::string_view>
tokenize(std::string_view str, std::string_view delim)
52 const auto token = [&](std::size_t pos){
53 const auto start = str.find_first_not_of(delim, pos);
54 const auto end = str.find_first_of(delim, start);
55 return std::make_pair(start, end);
58 std::vector<std::string_view> tokens;
59 for (
auto [start, end] = token(0); start != end; std::tie(start, end) = token(end))
60 tokens.emplace_back(str.substr(start, end-start));
80std::vector<std::string_view>
split(std::string_view str, std::string_view delim,
bool removeEmpty =
false)
82 const auto token = [&](std::size_t pos){
83 const auto end = str.find(delim, pos);
84 return std::make_pair(pos, end);
87 std::vector<std::string_view>
split;
88 for (
auto [start, end] = token(0); start != std::string::npos; std::tie(start, end) = token(start))
90 if (
auto&& sub = str.substr(start, end-start); !removeEmpty || !sub.empty())
91 split.emplace_back(std::move(sub));
94 start = (end != std::string::npos) ? end + delim.size() : end;
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
std::vector< std::string_view > split(std::string_view str, std::string_view delim, bool removeEmpty=false)
Definition: stringutilities.hh:80
std::vector< std::string_view > tokenize(std::string_view str, std::string_view delim)
Definition: stringutilities.hh:50