Skip to content

Commit 981dfcd

Browse files
committed
optimize status demo
1 parent 51a7827 commit 981dfcd

File tree

12 files changed

+785
-87
lines changed

12 files changed

+785
-87
lines changed

‎app/wizard_demo/dns-gate/tools/status/json/struct.gson.cpp‎

Lines changed: 372 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,63 @@
33
#include "struct.gson.h"
44
namespace acl
55
{
6+
acl::json_node& gson(acl::json &$json, const filter_mac_t &$obj)
7+
{
8+
acl::json_node &$node = $json.create_node();
9+
10+
if (check_nullptr($obj.mac))
11+
$node.add_null("mac");
12+
else
13+
$node.add_text("mac", acl::get_value($obj.mac));
14+
15+
16+
return $node;
17+
}
18+
19+
acl::json_node& gson(acl::json &$json, const filter_mac_t *$obj)
20+
{
21+
return gson ($json, *$obj);
22+
}
23+
24+
25+
acl::string gson(const filter_mac_t &$obj)
26+
{
27+
acl::json $json;
28+
acl::json_node &$node = acl::gson ($json, $obj);
29+
return $node.to_string ();
30+
}
31+
32+
33+
std::pair<bool,std::string> gson(acl::json_node &$node, filter_mac_t &$obj)
34+
{
35+
acl::json_node *mac = $node["mac"];
36+
std::pair<bool, std::string> $result;
37+
38+
if(!mac ||!($result = gson(*mac, &$obj.mac), $result.first))
39+
return std::make_pair(false, "required [filter_mac_t.mac] failed:{"+$result.second+"}");
40+
41+
return std::make_pair(true,"");
42+
}
43+
44+
45+
std::pair<bool,std::string> gson(acl::json_node &$node, filter_mac_t *$obj)
46+
{
47+
return gson($node, *$obj);
48+
}
49+
50+
51+
std::pair<bool,std::string> gson(const acl::string &$str, filter_mac_t &$obj)
52+
{
53+
acl::json _json;
54+
_json.update($str.c_str());
55+
if (!_json.finish())
56+
{
57+
return std::make_pair(false, "json not finish error");
58+
}
59+
return gson(_json.get_root(), $obj);
60+
}
61+
62+
663
acl::json_node& gson(acl::json &$json, const host_info_t &$obj)
764
{
865
acl::json_node &$node = $json.create_node();
@@ -150,6 +207,321 @@ namespace acl
150207
}
151208

152209

210+
acl::json_node& gson(acl::json &$json, const limit_speed_host_management_t &$obj)
211+
{
212+
acl::json_node &$node = $json.create_node();
213+
214+
if (check_nullptr($obj.table))
215+
$node.add_null("table");
216+
else
217+
$node.add_text("table", acl::get_value($obj.table));
218+
219+
if (check_nullptr($obj.filter))
220+
$node.add_null("filter");
221+
else
222+
$node.add_child("filter", acl::gson($json, $obj.filter));
223+
224+
if (check_nullptr($obj.para))
225+
$node.add_null("para");
226+
else
227+
$node.add_child("para", acl::gson($json, $obj.para));
228+
229+
230+
return $node;
231+
}
232+
233+
acl::json_node& gson(acl::json &$json, const limit_speed_host_management_t *$obj)
234+
{
235+
return gson ($json, *$obj);
236+
}
237+
238+
239+
acl::string gson(const limit_speed_host_management_t &$obj)
240+
{
241+
acl::json $json;
242+
acl::json_node &$node = acl::gson ($json, $obj);
243+
return $node.to_string ();
244+
}
245+
246+
247+
std::pair<bool,std::string> gson(acl::json_node &$node, limit_speed_host_management_t &$obj)
248+
{
249+
acl::json_node *table = $node["table"];
250+
acl::json_node *filter = $node["filter"];
251+
acl::json_node *para = $node["para"];
252+
std::pair<bool, std::string> $result;
253+
254+
if(!table ||!($result = gson(*table, &$obj.table), $result.first))
255+
return std::make_pair(false, "required [limit_speed_host_management_t.table] failed:{"+$result.second+"}");
256+
257+
if(!filter ||!filter->get_obj()||!($result = gson(*filter->get_obj(), &$obj.filter), $result.first))
258+
return std::make_pair(false, "required [limit_speed_host_management_t.filter] failed:{"+$result.second+"}");
259+
260+
if(!para ||!para->get_obj()||!($result = gson(*para->get_obj(), &$obj.para), $result.first))
261+
return std::make_pair(false, "required [limit_speed_host_management_t.para] failed:{"+$result.second+"}");
262+
263+
return std::make_pair(true,"");
264+
}
265+
266+
267+
std::pair<bool,std::string> gson(acl::json_node &$node, limit_speed_host_management_t *$obj)
268+
{
269+
return gson($node, *$obj);
270+
}
271+
272+
273+
std::pair<bool,std::string> gson(const acl::string &$str, limit_speed_host_management_t &$obj)
274+
{
275+
acl::json _json;
276+
_json.update($str.c_str());
277+
if (!_json.finish())
278+
{
279+
return std::make_pair(false, "json not finish error");
280+
}
281+
return gson(_json.get_root(), $obj);
282+
}
283+
284+
285+
acl::json_node& gson(acl::json &$json, const limit_speed_para_t &$obj)
286+
{
287+
acl::json_node &$node = $json.create_node();
288+
289+
if (check_nullptr($obj.host_save))
290+
$node.add_null("host_save");
291+
else
292+
$node.add_text("host_save", acl::get_value($obj.host_save));
293+
294+
if (check_nullptr($obj.type))
295+
$node.add_null("type");
296+
else
297+
$node.add_text("type", acl::get_value($obj.type));
298+
299+
if (check_nullptr($obj.origin_hostname))
300+
$node.add_null("origin_hostname");
301+
else
302+
$node.add_text("origin_hostname", acl::get_value($obj.origin_hostname));
303+
304+
if (check_nullptr($obj.hostname))
305+
$node.add_null("hostname");
306+
else
307+
$node.add_text("hostname", acl::get_value($obj.hostname));
308+
309+
if (check_nullptr($obj.ssid))
310+
$node.add_null("ssid");
311+
else
312+
$node.add_text("ssid", acl::get_value($obj.ssid));
313+
314+
if (check_nullptr($obj.ip))
315+
$node.add_null("ip");
316+
else
317+
$node.add_text("ip", acl::get_value($obj.ip));
318+
319+
if (check_nullptr($obj.mac))
320+
$node.add_null("mac");
321+
else
322+
$node.add_text("mac", acl::get_value($obj.mac));
323+
324+
if (check_nullptr($obj.limit))
325+
$node.add_null("limit");
326+
else
327+
$node.add_text("limit", acl::get_value($obj.limit));
328+
329+
if (check_nullptr($obj.up_limit))
330+
$node.add_null("up_limit");
331+
else
332+
$node.add_text("up_limit", acl::get_value($obj.up_limit));
333+
334+
if (check_nullptr($obj.down_limit))
335+
$node.add_null("down_limit");
336+
else
337+
$node.add_text("down_limit", acl::get_value($obj.down_limit));
338+
339+
if (check_nullptr($obj.time_obj))
340+
$node.add_null("time_obj");
341+
else
342+
$node.add_text("time_obj", acl::get_value($obj.time_obj));
343+
344+
if (check_nullptr($obj.name))
345+
$node.add_null("name");
346+
else
347+
$node.add_text("name", acl::get_value($obj.name));
348+
349+
if (check_nullptr($obj.time_mode))
350+
$node.add_null("time_mode");
351+
else
352+
$node.add_text("time_mode", acl::get_value($obj.time_mode));
353+
354+
if (check_nullptr($obj.is_cur_host))
355+
$node.add_null("is_cur_host");
356+
else
357+
$node.add_text("is_cur_host", acl::get_value($obj.is_cur_host));
358+
359+
360+
return $node;
361+
}
362+
363+
acl::json_node& gson(acl::json &$json, const limit_speed_para_t *$obj)
364+
{
365+
return gson ($json, *$obj);
366+
}
367+
368+
369+
acl::string gson(const limit_speed_para_t &$obj)
370+
{
371+
acl::json $json;
372+
acl::json_node &$node = acl::gson ($json, $obj);
373+
return $node.to_string ();
374+
}
375+
376+
377+
std::pair<bool,std::string> gson(acl::json_node &$node, limit_speed_para_t &$obj)
378+
{
379+
acl::json_node *host_save = $node["host_save"];
380+
acl::json_node *type = $node["type"];
381+
acl::json_node *origin_hostname = $node["origin_hostname"];
382+
acl::json_node *hostname = $node["hostname"];
383+
acl::json_node *ssid = $node["ssid"];
384+
acl::json_node *ip = $node["ip"];
385+
acl::json_node *mac = $node["mac"];
386+
acl::json_node *limit = $node["limit"];
387+
acl::json_node *up_limit = $node["up_limit"];
388+
acl::json_node *down_limit = $node["down_limit"];
389+
acl::json_node *time_obj = $node["time_obj"];
390+
acl::json_node *name = $node["name"];
391+
acl::json_node *time_mode = $node["time_mode"];
392+
acl::json_node *is_cur_host = $node["is_cur_host"];
393+
std::pair<bool, std::string> $result;
394+
395+
if(!host_save ||!($result = gson(*host_save, &$obj.host_save), $result.first))
396+
return std::make_pair(false, "required [limit_speed_para_t.host_save] failed:{"+$result.second+"}");
397+
398+
if(!type ||!($result = gson(*type, &$obj.type), $result.first))
399+
return std::make_pair(false, "required [limit_speed_para_t.type] failed:{"+$result.second+"}");
400+
401+
if(!origin_hostname ||!($result = gson(*origin_hostname, &$obj.origin_hostname), $result.first))
402+
return std::make_pair(false, "required [limit_speed_para_t.origin_hostname] failed:{"+$result.second+"}");
403+
404+
if(!hostname ||!($result = gson(*hostname, &$obj.hostname), $result.first))
405+
return std::make_pair(false, "required [limit_speed_para_t.hostname] failed:{"+$result.second+"}");
406+
407+
if(!ssid ||!($result = gson(*ssid, &$obj.ssid), $result.first))
408+
return std::make_pair(false, "required [limit_speed_para_t.ssid] failed:{"+$result.second+"}");
409+
410+
if(!ip ||!($result = gson(*ip, &$obj.ip), $result.first))
411+
return std::make_pair(false, "required [limit_speed_para_t.ip] failed:{"+$result.second+"}");
412+
413+
if(!mac ||!($result = gson(*mac, &$obj.mac), $result.first))
414+
return std::make_pair(false, "required [limit_speed_para_t.mac] failed:{"+$result.second+"}");
415+
416+
if(!limit ||!($result = gson(*limit, &$obj.limit), $result.first))
417+
return std::make_pair(false, "required [limit_speed_para_t.limit] failed:{"+$result.second+"}");
418+
419+
if(!up_limit ||!($result = gson(*up_limit, &$obj.up_limit), $result.first))
420+
return std::make_pair(false, "required [limit_speed_para_t.up_limit] failed:{"+$result.second+"}");
421+
422+
if(!down_limit ||!($result = gson(*down_limit, &$obj.down_limit), $result.first))
423+
return std::make_pair(false, "required [limit_speed_para_t.down_limit] failed:{"+$result.second+"}");
424+
425+
if(!time_obj ||!($result = gson(*time_obj, &$obj.time_obj), $result.first))
426+
return std::make_pair(false, "required [limit_speed_para_t.time_obj] failed:{"+$result.second+"}");
427+
428+
if(!name ||!($result = gson(*name, &$obj.name), $result.first))
429+
return std::make_pair(false, "required [limit_speed_para_t.name] failed:{"+$result.second+"}");
430+
431+
if(!time_mode ||!($result = gson(*time_mode, &$obj.time_mode), $result.first))
432+
return std::make_pair(false, "required [limit_speed_para_t.time_mode] failed:{"+$result.second+"}");
433+
434+
if(!is_cur_host ||!($result = gson(*is_cur_host, &$obj.is_cur_host), $result.first))
435+
return std::make_pair(false, "required [limit_speed_para_t.is_cur_host] failed:{"+$result.second+"}");
436+
437+
return std::make_pair(true,"");
438+
}
439+
440+
441+
std::pair<bool,std::string> gson(acl::json_node &$node, limit_speed_para_t *$obj)
442+
{
443+
return gson($node, *$obj);
444+
}
445+
446+
447+
std::pair<bool,std::string> gson(const acl::string &$str, limit_speed_para_t &$obj)
448+
{
449+
acl::json _json;
450+
_json.update($str.c_str());
451+
if (!_json.finish())
452+
{
453+
return std::make_pair(false, "json not finish error");
454+
}
455+
return gson(_json.get_root(), $obj);
456+
}
457+
458+
459+
acl::json_node& gson(acl::json &$json, const limit_speed_req_t &$obj)
460+
{
461+
acl::json_node &$node = $json.create_node();
462+
463+
if (check_nullptr($obj.method))
464+
$node.add_null("method");
465+
else
466+
$node.add_text("method", acl::get_value($obj.method));
467+
468+
if (check_nullptr($obj.host_management))
469+
$node.add_null("host_management");
470+
else
471+
$node.add_child("host_management", acl::gson($json, $obj.host_management));
472+
473+
474+
return $node;
475+
}
476+
477+
acl::json_node& gson(acl::json &$json, const limit_speed_req_t *$obj)
478+
{
479+
return gson ($json, *$obj);
480+
}
481+
482+
483+
acl::string gson(const limit_speed_req_t &$obj)
484+
{
485+
acl::json $json;
486+
acl::json_node &$node = acl::gson ($json, $obj);
487+
return $node.to_string ();
488+
}
489+
490+
491+
std::pair<bool,std::string> gson(acl::json_node &$node, limit_speed_req_t &$obj)
492+
{
493+
acl::json_node *method = $node["method"];
494+
acl::json_node *host_management = $node["host_management"];
495+
std::pair<bool, std::string> $result;
496+
497+
if(!method ||!($result = gson(*method, &$obj.method), $result.first))
498+
return std::make_pair(false, "required [limit_speed_req_t.method] failed:{"+$result.second+"}");
499+
500+
if(!host_management ||!host_management->get_obj()||!($result = gson(*host_management->get_obj(), &$obj.host_management), $result.first))
501+
return std::make_pair(false, "required [limit_speed_req_t.host_management] failed:{"+$result.second+"}");
502+
503+
return std::make_pair(true,"");
504+
}
505+
506+
507+
std::pair<bool,std::string> gson(acl::json_node &$node, limit_speed_req_t *$obj)
508+
{
509+
return gson($node, *$obj);
510+
}
511+
512+
513+
std::pair<bool,std::string> gson(const acl::string &$str, limit_speed_req_t &$obj)
514+
{
515+
acl::json _json;
516+
_json.update($str.c_str());
517+
if (!_json.finish())
518+
{
519+
return std::make_pair(false, "json not finish error");
520+
}
521+
return gson(_json.get_root(), $obj);
522+
}
523+
524+
153525
acl::json_node& gson(acl::json &$json, const login_req_t &$obj)
154526
{
155527
acl::json_node &$node = $json.create_node();

0 commit comments

Comments
 (0)