| 34 | } |
| 35 | |
| 36 | virtual bool LoadFile(const std::string &file, bool is_reload) { |
| 37 | comm::FileConfig config(file); |
| 38 | if (!config.Read()) { |
| 39 | std::cout << "FileConfig::Read fail. file " << file << std::endl; |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | std::string json; |
| 44 | if (!config.GetContent(json)) { |
| 45 | std::cout << "FileConfig::GetContent fail. file " << file << std::endl; |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | std::cout << "json: " << json << std::endl; |
| 51 | |
| 52 | google::protobuf::util::JsonParseOptions opt; |
| 53 | opt.ignore_unknown_fields = true; |
| 54 | auto status = JsonStringToMessage(json, &proto_, opt); |
| 55 | if (!status.ok()) { |
| 56 | std::cout << "JsonStringToMessage fail. status " << status.ToString() << std::endl; |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | return true; |
| 61 | } |
| 62 | |
| 63 | private: |
| 64 | proto::SimpleConfig proto_; |
nothing calls this directly
no test coverage detected