| 707 | */ |
| 708 | |
| 709 | std::size_t String::Find(char character, std::intmax_t start, UInt32 flags) const |
| 710 | { |
| 711 | if (character == '\0' || m_sharedString->size == 0) |
| 712 | return npos; |
| 713 | |
| 714 | if (start < 0) |
| 715 | start = std::max<std::size_t>(m_sharedString->size + start, 0); |
| 716 | |
| 717 | std::size_t pos = static_cast<std::size_t>(start); |
| 718 | if (pos >= m_sharedString->size) |
| 719 | return npos; |
| 720 | |
| 721 | if (flags & CaseInsensitive) |
| 722 | { |
| 723 | char ch = Detail::ToLower(character); |
| 724 | const char* str = m_sharedString->string.get(); |
| 725 | do |
| 726 | { |
| 727 | if (Detail::ToLower(*str) == ch) |
| 728 | return str - m_sharedString->string.get(); |
| 729 | } |
| 730 | while (*++str); |
| 731 | |
| 732 | return npos; |
| 733 | } |
| 734 | else |
| 735 | { |
| 736 | char* ch = std::strchr(&m_sharedString->string[pos], character); |
| 737 | if (ch) |
| 738 | return ch - m_sharedString->string.get(); |
| 739 | else |
| 740 | return npos; |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | /*! |
| 745 | * \brief Finds the first index of the "C string" in the string |
no test coverage detected