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

Method Prev

src/string.cpp:800–829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

798 }
799
800 size_t Prev(IterType what) override
801 {
802 const auto begin = this->string.begin();
803 /* Already at the beginning? */
804 if (this->cur_pos == begin) return END;
805
806 switch (what) {
807 case ITER_CHARACTER:
808 --this->cur_pos;
809 return this->cur_pos.GetByteOffset();
810
811 case ITER_WORD:
812 /* Consume preceding whitespace. */
813 do {
814 --this->cur_pos;
815 } while (this->cur_pos != begin && IsWhitespace(*this->cur_pos));
816 /* Consume preceding word. */
817 while (this->cur_pos != begin && !IsWhitespace(*this->cur_pos)) {
818 --this->cur_pos;
819 }
820 /* Move caret back to the beginning of the word. */
821 if (IsWhitespace(*this->cur_pos)) ++this->cur_pos;
822 return this->cur_pos.GetByteOffset();
823
824 default:
825 NOT_REACHED();
826 }
827
828 return END;
829 }
830};
831
832#if defined(WITH_COCOA) && !defined(STRGEN) && !defined(SETTINGSGEN)

Callers

nothing calls this directly

Calls 4

IsWhitespaceFunction · 0.85
NOT_REACHEDFunction · 0.85
GetByteOffsetMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected