diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-12 21:07:52 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-12 21:28:55 +0200 |
commit | fdfda6dec20101013bb33633e657f06ef2a1ea96 (patch) | |
tree | 2157f8281cd9bc33a6984455c4831c397d2bd30c /Applications/IRCClient | |
parent | 15f4043a7a80f52c0fa05c4e69771e758464cd20 (diff) | |
download | serenity-fdfda6dec20101013bb33633e657f06ef2a1ea96.zip |
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
Diffstat (limited to 'Applications/IRCClient')
-rw-r--r-- | Applications/IRCClient/IRCClient.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Applications/IRCClient/IRCClient.cpp b/Applications/IRCClient/IRCClient.cpp index 947be679f3..6b078e281f 100644 --- a/Applications/IRCClient/IRCClient.cpp +++ b/Applications/IRCClient/IRCClient.cpp @@ -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); } |