MCPcopy Create free account
hub / github.com/cinience/RedisStudio / LoadConfig

Method LoadConfig

RedisStudio/ConnInfoUI.cpp:83–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81
82
83bool ConnInfoUI::LoadConfig( const std::string& path )
84{
85 m_pListUI->RemoveAll();
86 /// 设置利用回调填充数据
87 m_pListUI->SetTextCallback(this);//[1]
88 m_dicServerInfo.clear();
89
90 FILE* fp = fopen(kConfigFilePath, "r");
91 if (!fp) return false;
92
93 FileStream is(fp);
94 Document document; /// Default template parameter uses UTF8 and MemoryPoolAllocator.
95 if (document.ParseStream<0>(is).HasParseError())
96 {
97 UserMessageBox(GetHWND(), 10014, _T("Parse config file failed."), MB_ICONERROR);
98 fclose(fp);
99 return false;
100 }
101
102 const Value& serverConfig = document["Server"];
103 int idx = 0;
104 for (Value::ConstValueIterator itr = serverConfig.Begin(); itr != serverConfig.End(); ++itr)
105 {
106 const Value& subConfig = *itr;
107 CDuiString name = Base::CharacterSet::UTF8ToUnicode(subConfig["name"].GetString()).c_str();
108 m_dicServerInfo[kServerNameIndex].push_back(Base::CharacterSet::UnicodeToANSI(name.GetData()));
109 m_dicServerInfo[kServerIpIndex].push_back(subConfig["ip"].GetString());
110 std::ostringstream os;
111 os<<subConfig["port"].GetInt();
112 m_dicServerInfo[kServerPortIndex].push_back(os.str());
113 m_dicServerInfo[kServerAuthIndex].push_back(subConfig["auth"].GetString());
114
115 CListTextElementUI* pListElement = new CListTextElementUI;
116 pListElement->SetTag(idx++);
117 /// 设置工具提示
118 pListElement->SetToolTip(m_pListUI->GetToolTip());
119 m_pListUI->Add(pListElement);
120 }
121 fclose(fp);
122
123 return true;
124}
125
126
127bool ConnInfoUI::SaveConfig( const std::string& path )

Callers

nothing calls this directly

Calls 10

UserMessageBoxFunction · 0.85
SetTextCallbackMethod · 0.80
SetTagMethod · 0.80
SetToolTipMethod · 0.80
GetToolTipMethod · 0.80
RemoveAllMethod · 0.45
clearMethod · 0.45
HasParseErrorMethod · 0.45
GetDataMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected