|
OpenTTD Source 20260206-master-g4d4e37dbf1
|
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 919 of file string_consumer.hpp.
References StringConsumer::AnyBytesLeft(), StringConsumer::SkipUntilCharNotIn(), StringConsumer::TryReadIntegerBase(), and StringConsumer::WHITESPACE_NO_NEWLINE.
Referenced by TarScanner::AddFile(), ScriptInfo::AddLabels(), ConScrollToTile(), ConZoomToLevel(), GetDriverParamInt(), GetSavegameFormat(), GraphicsSetLoadConfig(), CheatWindow::OnQueryTextFinished(), CompanyWindow::OnQueryTextFinished(), CreateScenarioWindow::OnQueryTextFinished(), CustomCurrencyWindow::OnQueryTextFinished(), FoundTownWindow::OnQueryTextFinished(), GameOptionsWindow::OnQueryTextFinished(), GenerateLandscapeWindow::OnQueryTextFinished(), GSConfigWindow::OnQueryTextFinished(), IndustryViewWindow::OnQueryTextFinished(), NetworkStartServerWindow::OnQueryTextFinished(), NewGRFInspectWindow::OnQueryTextFinished(), NewGRFParametersWindow::OnQueryTextFinished(), OrdersWindow::OnQueryTextFinished(), ScenarioEditorToolbarWindow::OnQueryTextFinished(), ScriptSettingsWindow::OnQueryTextFinished(), SpriteAlignerWindow::OnQueryTextFinished(), TimetableWindow::OnQueryTextFinished(), openttd_main(), ParseCompanyManagerFaceCode(), ParseType(), and SelectGameWindow::ReadIntroGameViewportCommand().