| 30 | virtual ~BaseConfig() {} |
| 31 | |
| 32 | virtual bool LoadFile(const std::string &file, bool is_reload) { |
| 33 | bool need_check = ConfigType::NeedCheck(); |
| 34 | comm::FileConfig config(file); |
| 35 | if (!config.Read()) { |
| 36 | QLErr("FileConfig::Read fail. file %s", file.c_str()); |
| 37 | return false; |
| 38 | } |
| 39 | |
| 40 | std::string content; |
| 41 | if (!config.GetContent(content)) { |
| 42 | QLErr("FileConfig::GetContent fail. content %s", content.c_str()); |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | typename ConfigType::ProtoType proto; |
| 47 | |
| 48 | google::protobuf::util::JsonParseOptions opt; |
| 49 | opt.ignore_unknown_fields = !need_check; |
| 50 | auto status = JsonStringToMessage(content, &proto, opt); |
| 51 | if (!status.ok()) { |
| 52 | QLErr("JsonStringToMessage fail. %s", status.ToString().c_str()); |
| 53 | assert(!need_check); |
| 54 | return false; |
| 55 | } |
| 56 | |
| 57 | ConfigType::FillConfig(std::move(proto)); |
| 58 | |
| 59 | return true; |
| 60 | } |
| 61 | |
| 62 | virtual phxqueue::comm::RetCode ReadConfig(typename ConfigType::ProtoType &proto) { |
| 63 | return phxqueue::comm::RetCode::RET_OK; |
nothing calls this directly
no test coverage detected