diff irccdctl/cli.cpp @ 641:7e2d0739f37c

Irccd: import json_util from code Change how parsing values from JSON is done, the json_util functions do not throw but return a boost::optional instead. Then, create some convenient local wrappers in server_util.cpp to throw on missing values. While here, add as much as possible const qualifier on variables that will not be modified.
author David Demelier <markand@malikania.fr>
date Tue, 20 Mar 2018 20:01:02 +0100
parents 27587ff92a64
children 4a13a016ea4f
line wrap: on
line diff
--- a/irccdctl/cli.cpp	Tue Mar 20 19:45:01 2018 +0100
+++ b/irccdctl/cli.cpp	Tue Mar 20 20:01:02 2018 +0100
@@ -36,9 +36,9 @@
         if (code)
             throw boost::system::system_error(code);
 
-        auto c = json_util::to_string(message["command"]);
+        const auto c = json_util::get_string(message, "/command"_json_pointer);
 
-        if (c != req["command"].get<std::string>()) {
+        if (!c) {
             recv_response(ctl, std::move(req), std::move(handler));
             return;
         }