comparison 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
comparison
equal deleted inserted replaced
640:e2ad41b02ebf 641:7e2d0739f37c
34 { 34 {
35 ctl.recv([&ctl, req, handler, this] (auto code, auto message) { 35 ctl.recv([&ctl, req, handler, this] (auto code, auto message) {
36 if (code) 36 if (code)
37 throw boost::system::system_error(code); 37 throw boost::system::system_error(code);
38 38
39 auto c = json_util::to_string(message["command"]); 39 const auto c = json_util::get_string(message, "/command"_json_pointer);
40 40
41 if (c != req["command"].get<std::string>()) { 41 if (!c) {
42 recv_response(ctl, std::move(req), std::move(handler)); 42 recv_response(ctl, std::move(req), std::move(handler));
43 return; 43 return;
44 } 44 }
45 45
46 if (handler) 46 if (handler)