| 4547 | static constexpr std::string_view regex_for_config = R"(^\s*([^#:\s]+)\s*:\s*([^#:\s]+)\s*$)"; |
| 4548 | |
| 4549 | void config_parse_regex(std::string_view config_text, std::vector<std::pair<std::string, std::string>> &settings, |
| 4550 | std::regex const ®ex_fsm) { |
| 4551 | auto begin_ptr = config_text.data(); |
| 4552 | auto end_ptr = begin_ptr + config_text.size(); |
| 4553 | |
| 4554 | // Use `std::cregex_iterator` to find all non-overlapping matches |
| 4555 | // across multiple lines. We rely on "multiline" mode to treat |
| 4556 | // ^ and $ as line boundaries. |
| 4557 | std::cregex_iterator it(begin_ptr, end_ptr, regex_fsm); |
| 4558 | std::cregex_iterator end_it; |
| 4559 | |
| 4560 | // For each match, capture the "key" and "value" groups. |
| 4561 | // Group 0 is the full match, 1 and 2 are our key and value. |
| 4562 | for (; it != end_it; ++it) { |
| 4563 | std::cmatch const &match = *it; |
| 4564 | std::string key = match.str(1); |
| 4565 | std::string value = match.str(2); |
| 4566 | settings.emplace_back(std::move(key), std::move(value)); |
| 4567 | } |
| 4568 | } |
| 4569 | |
| 4570 | void parse_regex(bm::State &state, std::string_view config_text) { |
| 4571 | std::size_t pairs = 0, bytes = 0; |