mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-17 09:22:42 +01:00
Change: ParseInteger now checks for trailing junk chars.
This commit is contained in:
@@ -71,18 +71,6 @@ static IntervalTimer<TimerGameCalendar> _scheduled_monthly_timer = {{TimerGameCa
|
||||
IConsoleCmdExec(fmt::format("exec {}", filename));
|
||||
}};
|
||||
|
||||
|
||||
/**
|
||||
* Change a string into its number representation. Supports decimal and hexadecimal numbers.
|
||||
* @param arg The string to be converted.
|
||||
* @param base The base for parsing the number, defaults to only decimal numbers. Use 0 to also allow hexadecimal.
|
||||
* @return The number, or std::nullopt when it could not be parsed.
|
||||
*/
|
||||
static std::optional<uint32_t> ParseInteger(std::string_view arg, int base = 10)
|
||||
{
|
||||
return StringConsumer{arg}.TryReadIntegerBase<uint32_t>(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an integer using #ParseInteger and convert it to the requested type.
|
||||
* @param arg The string to be converted.
|
||||
|
||||
Reference in New Issue
Block a user