MCPcopy Create free account
hub / github.com/Tencent/phxqueue / LoadFile

Method LoadFile

phxqueue_phxrpc/test/simpleconfig.h:36–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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_;

Callers

nothing calls this directly

Calls 3

GetContentMethod · 0.80
ToStringMethod · 0.80
ReadMethod · 0.45

Tested by

no test coverage detected