MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / Next

Method Next

src/string.cpp:680–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

678 }
679
680 size_t Next(IterType what) override
681 {
682 int32_t pos;
683 switch (what) {
684 case ITER_CHARACTER:
685 pos = this->char_itr->next();
686 break;
687
688 case ITER_WORD:
689 pos = this->word_itr->following(this->char_itr->current());
690 /* The ICU word iterator considers both the start and the end of a word a valid
691 * break point, but we only want word starts. Move to the next location in
692 * case the new position points to whitespace. */
693 while (pos != icu::BreakIterator::DONE &&
694 IsWhitespace(Utf16DecodeChar((const uint16_t *)&this->utf16_str[pos]))) {
695 int32_t new_pos = this->word_itr->next();
696 /* Don't set it to DONE if it was valid before. Otherwise we'll return END
697 * even though the iterator wasn't at the end of the string before. */
698 if (new_pos == icu::BreakIterator::DONE) break;
699 pos = new_pos;
700 }
701
702 this->char_itr->isBoundary(pos);
703 break;
704
705 default:
706 NOT_REACHED();
707 }
708
709 return pos == icu::BreakIterator::DONE ? END : this->utf16_to_utf8[pos];
710 }
711
712 size_t Prev(IterType what) override
713 {

Callers

nothing calls this directly

Calls 5

IsWhitespaceFunction · 0.85
Utf16DecodeCharFunction · 0.85
NOT_REACHEDFunction · 0.85
isBoundaryMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected