| 98 | } |
| 99 | |
| 100 | std::optional<common_chat_msg_parser::find_regex_result> common_chat_msg_parser::try_find_literal(const std::string & literal) { |
| 101 | auto idx = input_.find(literal, pos_); |
| 102 | if (idx != std::string::npos) { |
| 103 | find_regex_result res; |
| 104 | res.prelude = input_.substr(pos_, idx - pos_); |
| 105 | auto end = idx + literal.size(); |
| 106 | res.groups.emplace_back(common_string_range{idx, end}); |
| 107 | move_to(end); |
| 108 | return res; |
| 109 | } |
| 110 | if (is_partial_) { |
| 111 | idx = string_find_partial_stop(input_, literal); |
| 112 | if (idx != std::string::npos && idx >= pos_) { |
| 113 | find_regex_result res; |
| 114 | res.prelude = input_.substr(pos_, idx - pos_); |
| 115 | auto end = input_.size(); |
| 116 | res.groups.emplace_back(common_string_range{idx, end}); |
| 117 | move_to(end); |
| 118 | return res; |
| 119 | } |
| 120 | } |
| 121 | return std::nullopt; |
| 122 | } |
| 123 | |
| 124 | void common_chat_msg_parser::consume_literal(const std::string & literal) { |
| 125 | if (!try_consume_literal(literal)) { |
nothing calls this directly
no test coverage detected