mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
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:
parent
15f4043a7a
commit
fdfda6dec2
55 changed files with 354 additions and 455 deletions
|
@ -267,11 +267,10 @@ void IRCClient::handle(const Message& msg)
|
|||
}
|
||||
#endif
|
||||
|
||||
bool is_numeric;
|
||||
int numeric = msg.command.to_uint(is_numeric);
|
||||
auto numeric = msg.command.to_uint();
|
||||
|
||||
if (is_numeric) {
|
||||
switch (numeric) {
|
||||
if (numeric.has_value()) {
|
||||
switch (numeric.value()) {
|
||||
case RPL_WELCOME:
|
||||
return handle_rpl_welcome(msg);
|
||||
case RPL_WHOISCHANNELS:
|
||||
|
@ -798,10 +797,9 @@ void IRCClient::handle_rpl_topicwhotime(const Message& msg)
|
|||
auto& channel_name = msg.arguments[1];
|
||||
auto& nick = msg.arguments[2];
|
||||
auto setat = msg.arguments[3];
|
||||
bool ok;
|
||||
time_t setat_time = setat.to_uint(ok);
|
||||
if (ok)
|
||||
setat = Core::DateTime::from_timestamp(setat_time).to_string();
|
||||
auto setat_time = setat.to_uint();
|
||||
if (setat_time.has_value())
|
||||
setat = Core::DateTime::from_timestamp(setat_time.value()).to_string();
|
||||
ensure_channel(channel_name).add_message(String::format("*** (set by %s at %s)", nick.characters(), setat.characters()), Color::Blue);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue