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

Method PeekUntil

src/core/string_consumer.cpp:136–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136std::string_view StringConsumer::PeekUntil(std::string_view str, SeparatorUsage sep) const
137{
138 assert(!str.empty());
139 auto buf = this->src.substr(this->position);
140 auto len = buf.find(str);
141 if (len != std::string_view::npos) {
142 switch (sep) {
143 case READ_ONE_SEPARATOR:
144 if (buf.compare(len, str.size(), str) == 0) len += str.size();
145 break;
146 case READ_ALL_SEPARATORS:
147 while (buf.compare(len, str.size(), str) == 0) len += str.size();
148 break;
149 default:
150 break;
151 }
152 }
153 return buf.substr(0, len);
154}
155
156std::string_view StringConsumer::PeekUntilUtf8(char32_t c, SeparatorUsage sep) const
157{

Callers 3

ReadUntilMethod · 0.95
PeekUntilCharMethod · 0.95

Calls 5

substrMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
compareMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected