| 222 | } |
| 223 | |
| 224 | std::optional<common_json> common_chat_msg_parser::try_consume_json() { |
| 225 | auto it = input_.cbegin() + pos_; |
| 226 | const auto end = input_.cend(); |
| 227 | common_json result; |
| 228 | if (!common_json_parse(it, end, healing_marker_, result)) { |
| 229 | return std::nullopt; |
| 230 | } |
| 231 | pos_ = std::distance(input_.cbegin(), it); |
| 232 | if (result.healing_marker.marker.empty()) { |
| 233 | // No healing marker, just return the parsed json |
| 234 | return result; |
| 235 | } |
| 236 | if (!is_partial()) { |
| 237 | throw common_chat_msg_partial_exception("JSON"); |
| 238 | } |
| 239 | return result; |
| 240 | } |
| 241 | |
| 242 | common_json common_chat_msg_parser::consume_json() { |
| 243 | if (auto result = try_consume_json()) { |
nothing calls this directly
no test coverage detected