MCPcopy Create free account
hub / github.com/OriginQ/QPanda-2 / init_withconfig

Method init_withconfig

Extensions/PilotOSMachine/QPilotMachine.cpp:2690–2721  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2688}
2689
2690bool QPilotMachine::init_withconfig(const std::string& config_path)
2691{
2692 try
2693 {
2694 JsonParser json_conf;
2695 std::string s_pilot_conf;
2696 std::string s_pilot_conf_buffer;
2697 std::fstream f_pilot_conf(config_path);
2698 if (f_pilot_conf.is_open())
2699 {
2700 while (!f_pilot_conf.eof())
2701 {
2702 f_pilot_conf >> s_pilot_conf_buffer;
2703 s_pilot_conf += s_pilot_conf_buffer;
2704 }
2705 f_pilot_conf.close();
2706 if (!s_pilot_conf.empty())
2707 {
2708 json_conf.load_json(s_pilot_conf);
2709 bool log_cout = json_conf.get_bool("log_cout");
2710 std::string pilot_url = json_conf.get_string("pilot_url");
2711 return init(pilot_url, log_cout);
2712 }
2713 }
2714 PTraceError("Error: pilotmachine configure error:\n{\"log_out\":false,\"pilot_url\":\"https://ip:port\"}");
2715 }
2716 catch (const std::exception& e)
2717 {
2718 PTraceError("Error: on exception: " << e.what());
2719 throw;
2720 }
2721}
2722
2723ErrorCode QPilotMachine::get_token(std::string& rep_json)
2724{

Callers

nothing calls this directly

Calls 6

load_jsonMethod · 0.80
get_boolMethod · 0.80
get_stringMethod · 0.80
initFunction · 0.50
emptyMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected