| 485 | opt_list.clear(); |
| 486 | } |
| 487 | string grab_opt (string s, size_t start) |
| 488 | { |
| 489 | vector<string> candidates; |
| 490 | for (auto it = opt_list.begin(); it != opt_list.end(); ++it) |
| 491 | { |
| 492 | string opt = std::get<0>(*it); |
| 493 | string slice = s.substr(start, opt.size()); |
| 494 | if (slice == opt) |
| 495 | candidates.push_back(slice); |
| 496 | } |
| 497 | if (!candidates.size()) |
| 498 | return ""; |
| 499 | // Select the longest candidate |
| 500 | std::sort(candidates.begin(), candidates.end(), StringFormatter<T>::compare_opts); |
| 501 | return candidates[0]; |
| 502 | } |
| 503 | T_callback get_callback (string s) |
| 504 | { |
| 505 | for (auto it = opt_list.begin(); it != opt_list.end(); ++it) |