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

Method ReadUntil

src/core/string_consumer.hpp:711–727  ·  view source on GitHub ↗

* Read data until the first occurrence of 'str', and advance reader. * @param str Separator string. * @param sep Whether to include/exclude 'str' from the result, and/or skip it. */

Source from the content-addressed store, hash-verified

709 * @param sep Whether to include/exclude 'str' from the result, and/or skip it.
710 */
711 [[nodiscard]] std::string_view ReadUntil(std::string_view str, SeparatorUsage sep)
712 {
713 assert(!str.empty());
714 auto result = this->PeekUntil(str, sep);
715 this->Skip(result.size());
716 switch (sep) {
717 default:
718 break;
719 case SKIP_ONE_SEPARATOR:
720 this->SkipIf(str);
721 break;
722 case SKIP_ALL_SEPARATORS:
723 while (this->ReadIf(str)) {}
724 break;
725 }
726 return result;
727 }
728 /**
729 * Skip data until the first occurrence of 'str'.
730 * @param str Separator string.

Callers 4

ReadUntilCharMethod · 0.95
ParseCommandLineFunction · 0.80
HasStringInExtensionListFunction · 0.80

Calls 6

PeekUntilMethod · 0.95
SkipMethod · 0.95
SkipIfMethod · 0.95
ReadIfMethod · 0.95
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected