Skip to content

Commit 40bf0c1

Browse files
authored
[cleanup] clConfig (#3839)
1 parent f67ef71 commit 40bf0c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+133
-133
lines changed

AutoSave/AutoSaveSettings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ AutoSaveSettings AutoSaveSettings::Load()
2525
{
2626
AutoSaveSettings settings;
2727
clConfig config("auto-save.conf");
28-
config.ReadItem(&settings);
28+
config.ReadItem(settings);
2929
return settings;
3030
}
3131

3232
void AutoSaveSettings::Save(const AutoSaveSettings& settings)
3333
{
3434
clConfig config("auto-save.conf");
35-
config.WriteItem(&settings);
35+
config.WriteItem(settings);
3636
}

CodeLite/cl_config.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ void clConfig::DoDeleteProperty(const wxString& property)
153153
}
154154
}
155155

156-
bool clConfig::ReadItem(clConfigItem* item, const wxString& differentName)
156+
bool clConfig::ReadItem(clConfigItem& item)
157157
{
158-
wxString nameToUse = differentName.IsEmpty() ? item->GetName() : differentName;
159-
if (m_root->toElement().hasNamedObject(nameToUse)) {
160-
item->FromJSON(m_root->toElement().namedObject(nameToUse));
158+
const wxString& name = item.GetName();
159+
if (m_root->toElement().hasNamedObject(name)) {
160+
item.FromJSON(m_root->toElement().namedObject(name));
161161
return true;
162162
}
163163
return false;
@@ -197,11 +197,11 @@ void clConfig::Read(const wxString& name,
197197
}
198198
}
199199

200-
void clConfig::WriteItem(const clConfigItem* item, const wxString& differentName)
200+
void clConfig::WriteItem(const clConfigItem& item)
201201
{
202-
wxString nameToUse = differentName.IsEmpty() ? item->GetName() : differentName;
203-
DoDeleteProperty(nameToUse);
204-
m_root->toElement().append(item->ToJSON());
202+
const wxString& name = item.GetName();
203+
DoDeleteProperty(name);
204+
m_root->toElement().addProperty(name, item.ToJSON());
205205
m_root->save(m_filename);
206206
}
207207

CodeLite/cl_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ class WXDLLIMPEXP_CL clConfig
149149

150150
// General objects
151151
// -----------------------------
152-
bool ReadItem(clConfigItem* item, const wxString& differentName = wxEmptyString);
153-
void WriteItem(const clConfigItem* item, const wxString& differentName = wxEmptyString);
152+
bool ReadItem(clConfigItem& item);
153+
void WriteItem(const clConfigItem& item);
154154
// bool
155155
bool Read(const wxString& name, bool defaultValue);
156156
void Write(const wxString& name, bool value);

DatabaseExplorer/DbSettingDialog.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void DbSettingDialog::DoSaveSqliteHistory()
238238
// Save the recent opened files
239239
clConfig config(DBE_CONFIG_FILE);
240240
DbExplorerSettings settings;
241-
config.ReadItem(&settings);
241+
config.ReadItem(settings);
242242

243243
wxArrayString files = settings.GetRecentFiles();
244244

@@ -248,38 +248,38 @@ void DbSettingDialog::DoSaveSqliteHistory()
248248

249249
files.Insert(filename, 0);
250250
settings.SetRecentFiles(files);
251-
config.WriteItem(&settings);
251+
config.WriteItem(settings);
252252
}
253253

254254
wxArrayString DbSettingDialog::DoLoadSqliteHistory()
255255
{
256256
clConfig config(DBE_CONFIG_FILE);
257257
DbExplorerSettings settings;
258-
config.ReadItem(&settings);
258+
config.ReadItem(settings);
259259
return settings.GetRecentFiles();
260260
}
261261

262262
DbConnectionInfoVec DbSettingDialog::DoLoadMySQLHistory()
263263
{
264264
clConfig config(DBE_CONFIG_FILE);
265265
DbExplorerSettings settings;
266-
config.ReadItem(&settings);
266+
config.ReadItem(settings);
267267
return settings.GetMySQLConnections();
268268
}
269269

270270
DbConnectionInfoVec DbSettingDialog::DoLoadPgSQLHistory()
271271
{
272272
clConfig config(DBE_CONFIG_FILE);
273273
DbExplorerSettings settings;
274-
config.ReadItem(&settings);
274+
config.ReadItem(settings);
275275
return settings.GetPgSQLConnections();
276276
}
277277

278278
void DbSettingDialog::DoSaveMySQLHistory()
279279
{
280280
clConfig config(DBE_CONFIG_FILE);
281281
DbExplorerSettings settings;
282-
config.ReadItem(&settings);
282+
config.ReadItem(settings);
283283
DbConnectionInfoVec mysql = settings.GetMySQLConnections();
284284

285285
DbConnectionInfo conn;
@@ -303,14 +303,14 @@ void DbSettingDialog::DoSaveMySQLHistory()
303303

304304
mysql.insert(mysql.begin(), conn);
305305
settings.SetMySQLConnections(mysql);
306-
config.WriteItem(&settings);
306+
config.WriteItem(settings);
307307
}
308308

309309
void DbSettingDialog::DoSavePgSQLHistory()
310310
{
311311
clConfig config(DBE_CONFIG_FILE);
312312
DbExplorerSettings settings;
313-
config.ReadItem(&settings);
313+
config.ReadItem(settings);
314314
DbConnectionInfoVec pgconns = settings.GetPgSQLConnections();
315315

316316
long port = 0;
@@ -337,7 +337,7 @@ void DbSettingDialog::DoSavePgSQLHistory()
337337

338338
pgconns.insert(pgconns.begin(), conn);
339339
settings.SetPgSQLConnections(pgconns);
340-
config.WriteItem(&settings);
340+
config.WriteItem(settings);
341341
}
342342

343343
void DbSettingDialog::DoFindConnectionByName(const DbConnectionInfoVec& conns, const wxString& name)

DatabaseExplorer/SqlCommandPanel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ void SQLCommandPanel::OnHistoryToolClicked(wxAuiToolBarEvent& event)
400400

401401
DbExplorerSettings settings;
402402
clConfig conf(DBE_CONFIG_FILE);
403-
conf.ReadItem(&settings);
403+
conf.ReadItem(settings);
404404
settings.GetRecentFiles();
405405

406406
wxArrayString sqls = settings.GetSqlHistory();
@@ -504,7 +504,7 @@ void SQLCommandPanel::SaveSqlHistory(wxArrayString sqls)
504504

505505
DbExplorerSettings s;
506506
clConfig conf(DBE_CONFIG_FILE);
507-
conf.ReadItem(&s);
507+
conf.ReadItem(s);
508508
const wxArrayString& history = s.GetSqlHistory();
509509

510510
// Append the current history to the new sqls (exclude dups)
@@ -520,5 +520,5 @@ void SQLCommandPanel::SaveSqlHistory(wxArrayString sqls)
520520
}
521521

522522
s.SetSqlHistory(sqls);
523-
conf.WriteItem(&s);
523+
conf.WriteItem(s);
524524
}

Docker/clDockerSettings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ void clDockerSettings::Load()
5454
wxFileName fn(clStandardPaths::Get().GetUserDataDir(), "docker.conf");
5555
fn.AppendDir("config");
5656
clConfig conf(fn.GetFullPath());
57-
conf.ReadItem(this);
57+
conf.ReadItem(*this);
5858
}
5959

6060
void clDockerSettings::Save()
6161
{
6262
wxFileName fn(clStandardPaths::Get().GetUserDataDir(), "docker.conf");
6363
fn.AppendDir("config");
6464
clConfig conf(fn.GetFullPath());
65-
conf.WriteItem(this);
65+
conf.WriteItem(*this);
6666
}

Docker/clDockerWorkspaceSettings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ clDockerWorkspaceSettings& clDockerWorkspaceSettings::Load(const wxFileName& fil
3939
{
4040
m_workspaceFile = filename;
4141
clConfig conf(filename.GetFullPath());
42-
conf.ReadItem(this);
42+
conf.ReadItem(*this);
4343
return *this;
4444
}
4545

4646
clDockerWorkspaceSettings& clDockerWorkspaceSettings::Save(const wxFileName& filename)
4747
{
4848
m_workspaceFile = filename;
4949
clConfig conf(filename.GetFullPath());
50-
conf.WriteItem(this);
50+
conf.WriteItem(*this);
5151
return *this;
5252
}
5353

HelpPlugin/HelpPluginSettings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ HelpPluginSettings::HelpPluginSettings()
1919
HelpPluginSettings& HelpPluginSettings::Load()
2020
{
2121
clConfig conf("help-plugin.conf");
22-
conf.ReadItem(this);
22+
conf.ReadItem(*this);
2323
return *this;
2424
}
2525

2626
HelpPluginSettings& HelpPluginSettings::Save()
2727
{
2828
clConfig conf("help-plugin.conf");
29-
conf.WriteItem(this);
29+
conf.WriteItem(*this);
3030
return *this;
3131
}
3232
void HelpPluginSettings::FromJSON(const JSONItem& json)

LiteEditor/frame.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,13 +1432,13 @@ void clMainFrame::CreateGUIControls()
14321432
<< endl;
14331433
}
14341434
clConfig ccConfig("code-completion.conf");
1435-
ccConfig.ReadItem(&m_tagsOptionsData);
1435+
ccConfig.ReadItem(m_tagsOptionsData);
14361436

14371437
// If the cc options value has changed, construct a new instance
14381438
// with default values and call the "Merge" method
14391439
TagsOptionsData tmp;
14401440
m_tagsOptionsData.Merge(tmp);
1441-
ccConfig.WriteItem(&m_tagsOptionsData);
1441+
ccConfig.WriteItem(m_tagsOptionsData);
14421442

14431443
// update ctags options
14441444
TagsManagerST::Get()->SetCtagsOptions(m_tagsOptionsData);
@@ -2456,7 +2456,7 @@ void clMainFrame::OnCtagsOptions(wxCommandEvent& event)
24562456
TagsManagerST::Get()->SetCtagsOptions(m_tagsOptionsData);
24572457

24582458
clConfig ccConfig("code-completion.conf");
2459-
ccConfig.WriteItem(&m_tagsOptionsData);
2459+
ccConfig.WriteItem(m_tagsOptionsData);
24602460

24612461
// do we need to colourise?
24622462
if ((newColVars != colVars) || (colourTypes != m_tagsOptionsData.GetCcColourFlags())) {
@@ -2977,7 +2977,7 @@ void clMainFrame::UpdateParserSearchPathsFromDefaultCompiler()
29772977
{
29782978
// Check that the user has some paths set in the parser
29792979
clConfig ccConfig("code-completion.conf");
2980-
ccConfig.ReadItem(&m_tagsOptionsData);
2980+
ccConfig.ReadItem(m_tagsOptionsData);
29812981

29822982
// Since the version numbers aren't the same
29832983
// we should merge the new settings with the old ones
@@ -3008,7 +3008,7 @@ void clMainFrame::UpdateParserSearchPathsFromDefaultCompiler()
30083008
wxArrayString clangSearchPaths = m_tagsOptionsData.GetClangSearchPathsArray();
30093009
mergedPaths = ccConfig.MergeArrays(paths, clangSearchPaths);
30103010
m_tagsOptionsData.SetClangSearchPathsArray(mergedPaths);
3011-
ccConfig.WriteItem(&m_tagsOptionsData);
3011+
ccConfig.WriteItem(m_tagsOptionsData);
30123012
}
30133013

30143014
void clMainFrame::OnFileCloseAll(wxCommandEvent& event)
@@ -5359,7 +5359,7 @@ void clMainFrame::OnShowDebuggerWindow(wxCommandEvent& e)
53595359
// load the debugger configuration
53605360
clConfig conf("debugger-view.conf");
53615361
DebuggerPaneConfig item;
5362-
conf.ReadItem(&item);
5362+
conf.ReadItem(item);
53635363

53645364
bool show = e.IsChecked();
53655365
if (e.GetId() == XRCID("debugger_win_locals")) {
@@ -5398,7 +5398,7 @@ void clMainFrame::OnShowDebuggerWindow(wxCommandEvent& e)
53985398
item.ShowDebuggerWindow(DebuggerPaneConfig::Disassemble, show);
53995399
}
54005400

5401-
conf.WriteItem(&item);
5401+
conf.WriteItem(item);
54025402
// Reload the perspective
54035403
ManagerST::Get()->GetPerspectiveManager().LoadPerspective();
54045404
}
@@ -5408,7 +5408,7 @@ void clMainFrame::OnShowDebuggerWindowUI(wxUpdateUIEvent& e)
54085408
// load the debugger configuration
54095409
// clConfig conf("debugger-view.conf");
54105410
DebuggerPaneConfig item;
5411-
// conf.ReadItem( &item );
5411+
// conf.ReadItem(item);
54125412

54135413
DebuggerPaneConfig::eDebuggerWindows winid = DebuggerPaneConfig::None;
54145414

LiteEditor/mainbook.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ void MainBook::CreateSession(SessionEntry& session, wxArrayInt* excludeArr)
16141614
// Set the "Find In Files" file mask for this workspace
16151615
FindReplaceData frd;
16161616
frd.SetName("FindInFilesData");
1617-
clConfig::Get().ReadItem(&frd);
1617+
clConfig::Get().ReadItem(frd);
16181618
session.SetFindInFilesMask(frd.GetSelectedMask());
16191619
}
16201620

0 commit comments

Comments
 (0)