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

Function ParseRelNum

src/strgen/strgen_base.cpp:175–186  ·  view source on GitHub ↗

The plural specifier looks like * {NUM} {PLURAL passenger passengers} then it picks either passenger/passengers depending on the count in NUM */

Source from the content-addressed store, hash-verified

173/* The plural specifier looks like
174 * {NUM} {PLURAL <ARG#> passenger passengers} then it picks either passenger/passengers depending on the count in NUM */
175static std::pair<std::optional<size_t>, std::optional<size_t>> ParseRelNum(StringConsumer &consumer)
176{
177 consumer.SkipUntilCharNotIn(StringConsumer::WHITESPACE_NO_NEWLINE);
178 std::optional<size_t> v = consumer.TryReadIntegerBase<size_t>(10);
179 std::optional<size_t> offset;
180 if (v.has_value() && consumer.ReadCharIf(':')) {
181 /* Take the Nth within */
182 offset = consumer.TryReadIntegerBase<size_t>(10);
183 if (!offset.has_value()) StrgenFatal("Expected number for substring parameter");
184 }
185 return {v, offset};
186}
187
188/* Parse out the next word, or nullptr */
189std::optional<std::string_view> ParseWord(StringConsumer &consumer)

Callers 2

EmitPluralFunction · 0.85
EmitGenderFunction · 0.85

Calls 2

SkipUntilCharNotInMethod · 0.80
ReadCharIfMethod · 0.80

Tested by

no test coverage detected