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

Method SaveConfig

RedisStudio/ConnInfoUI.cpp:127–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125
126
127bool ConnInfoUI::SaveConfig( const std::string& path )
128{
129 std::size_t theSize = m_dicServerInfo[kServerNameIndex].size();
130
131 FILE* fp = fopen(kConfigFilePath, "w+");
132 if (!fp)
133 {
134 UserMessageBox(GetHWND(), 20003, NULL, MB_ICONERROR);
135 return false;
136 }
137 FileStream os(fp);
138 PrettyWriter<FileStream> writer(os);
139 writer.StartObject();
140 writer.String("Server");
141 writer.StartArray();
142 for (std::size_t idx=0; idx<theSize; ++idx)
143 {
144 writer.StartObject();
145 writer.String("name");
146 CDuiString name = Base::CharacterSet::ANSIToUnicode(m_dicServerInfo[kServerNameIndex][idx]).c_str();
147
148 writer.String(Base::CharacterSet::UnicodeToUTF8(name.GetData()).c_str());
149 writer.String("ip");
150 writer.String(m_dicServerInfo[kServerIpIndex][idx].c_str(), m_dicServerInfo[kServerIpIndex][idx].length());
151 writer.String("port");
152 writer.Int(atoi(m_dicServerInfo[kServerPortIndex][idx].c_str()));
153 writer.String("auth");
154 writer.String(m_dicServerInfo[kServerAuthIndex][idx].c_str());
155 writer.EndObject();
156 }
157 writer.EndArray();
158 writer.EndObject();
159 fclose(fp);
160 return true;
161}
162
163
164LPCTSTR ConnInfoUI::GetItemText( CControlUI* pControl, int iIndex, int iSubItem )

Callers

nothing calls this directly

Calls 9

UserMessageBoxFunction · 0.85
sizeMethod · 0.45
StartObjectMethod · 0.45
StringMethod · 0.45
StartArrayMethod · 0.45
GetDataMethod · 0.45
IntMethod · 0.45
EndObjectMethod · 0.45
EndArrayMethod · 0.45

Tested by

no test coverage detected