| 3571 | } |
| 3572 | |
| 3573 | int String::findmk(const Vector<String>& p_keys, int p_from, int* r_key) const |
| 3574 | { |
| 3575 | if (p_from < 0) |
| 3576 | { |
| 3577 | return -1; |
| 3578 | } |
| 3579 | if (p_keys.size() == 0) |
| 3580 | { |
| 3581 | return -1; |
| 3582 | } |
| 3583 | |
| 3584 | // int src_len=p_str.length(); |
| 3585 | const String* keys = &p_keys[0]; |
| 3586 | int key_count = p_keys.size(); |
| 3587 | int len = length(); |
| 3588 | |
| 3589 | if (len == 0) |
| 3590 | { |
| 3591 | return -1; // won't find anything! |
| 3592 | } |
| 3593 | |
| 3594 | const char32_t* src = get_data(); |
| 3595 | |
| 3596 | for (int i = p_from; i < len; i++) |
| 3597 | { |
| 3598 | bool found = true; |
| 3599 | for (int k = 0; k < key_count; k++) |
| 3600 | { |
| 3601 | found = true; |
| 3602 | if (r_key) |
| 3603 | { |
| 3604 | *r_key = k; |
| 3605 | } |
| 3606 | const char32_t* cmp = keys[k].get_data(); |
| 3607 | int l = keys[k].length(); |
| 3608 | |
| 3609 | for (int j = 0; j < l; j++) |
| 3610 | { |
| 3611 | int read_pos = i + j; |
| 3612 | |
| 3613 | if (read_pos >= len) |
| 3614 | { |
| 3615 | found = false; |
| 3616 | break; |
| 3617 | } |
| 3618 | |
| 3619 | if (src[read_pos] != cmp[j]) |
| 3620 | { |
| 3621 | found = false; |
| 3622 | break; |
| 3623 | } |
| 3624 | } |
| 3625 | if (found) |
| 3626 | { |
| 3627 | break; |
| 3628 | } |
| 3629 | } |
| 3630 | |