AK: Make string-to-number conversion helpers return Optional

Get rid of the weird old signature:

- int StringType::to_int(bool& ok) const

And replace it with sensible new signature:

- Optional<int> StringType::to_int() const
This commit is contained in:
Andreas Kling 2020-06-12 21:07:52 +02:00
commit fdfda6dec2
Notes: sideshowbarker 2024-07-19 05:41:49 +09:00
55 changed files with 354 additions and 455 deletions

View file

@ -158,13 +158,8 @@ public:
ASSERT(as_uint() <= INT32_MAX);
return (int)as_uint();
}
if (is_string()) {
bool ok;
int value = as_string().to_int(ok);
if (!ok)
return 0;
return value;
}
if (is_string())
return as_string().to_int().value_or(0);
return 0;
}