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

Function ParseInteger

src/core/string_consumer.hpp:917–925  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

915 */
916template <class T = uint32_t>
917static inline std::optional<T> ParseInteger(std::string_view arg, int base = 10, bool clamp = false)
918{
919 StringConsumer consumer{arg};
920 consumer.SkipUntilCharNotIn(StringConsumer::WHITESPACE_NO_NEWLINE);
921 auto result = consumer.TryReadIntegerBase<T>(base, clamp);
922 consumer.SkipUntilCharNotIn(StringConsumer::WHITESPACE_NO_NEWLINE);
923 if (consumer.AnyBytesLeft()) return std::nullopt;
924 return result;
925}
926
927#endif /* STRING_CONSUMER_HPP */

Callers 15

openttd_mainFunction · 0.85
OnQueryTextFinishedMethod · 0.85
OnQueryTextFinishedMethod · 0.85
OnQueryTextFinishedMethod · 0.85
OnQueryTextFinishedMethod · 0.85
OnQueryTextFinishedMethod · 0.85
FillSetDetailsMethod · 0.85
ParseTypeFunction · 0.85
ConResetTileFunction · 0.85
ConScrollToTileFunction · 0.85
ConUnBanFunction · 0.85

Calls 2

SkipUntilCharNotInMethod · 0.80
AnyBytesLeftMethod · 0.80

Tested by

no test coverage detected