OpenTTD Source 20250529-master-g10c159a79f
|
Parse strings. More...
Go to the source code of this file.
Data Structures | |
class | StringConsumer |
Parse data from a string / buffer. More... | |
Functions | |
template<class T = uint32_t> | |
static std::optional< T > | ParseInteger (std::string_view arg, int base=10, bool clamp=false) |
Change a string into its number representation. | |
Parse strings.
Definition in file string_consumer.hpp.
|
inlinestatic |
Change a string into its number representation.
Supports decimal and hexadecimal numbers. Accepts leading and trailing whitespace. Trailing junk is an error.
arg | The string to be converted. |
base | The base for parsing the number, defaults to only decimal numbers. Use 0 to also allow hexadecimal. |
clamp | If the value is a valid number, but out of range for T, return the maximum representable value. Negative values for unsigned results are still treated as invalid. |
Definition at line 917 of file string_consumer.hpp.
References StringConsumer::SkipUntilCharNotIn(), and StringConsumer::WHITESPACE_NO_NEWLINE.
Referenced by ConScrollToTile(), SelectCompanyManagerFaceWindow::OnQueryTextFinished(), IndustryViewWindow::OnQueryTextFinished(), SpriteAlignerWindow::OnQueryTextFinished(), OrdersWindow::OnQueryTextFinished(), CustomCurrencyWindow::OnQueryTextFinished(), ScenarioEditorToolbarWindow::OnQueryTextFinished(), FoundTownWindow::OnQueryTextFinished(), openttd_main(), and ParseType().