From 795b6a2e42ab6f23873211ab6d0d6abb8f845cdb Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 28 Feb 2019 08:54:36 -0500 Subject: [PATCH] More std:: style for wxString and wxArrayString... ... Replacing: Insert => insert RemoveAt => erase Remove => erase IsSameAs => operator == or operator != (but only when second argument was true or default) --- src/AudacityApp.cpp | 2 +- src/BatchCommands.cpp | 8 ++++---- src/DirManager.cpp | 3 ++- src/FFmpeg.cpp | 4 ++-- src/LabelTrack.cpp | 4 ++-- src/ModuleManager.cpp | 2 +- src/PluginManager.cpp | 14 +++++++------- src/Shuttle.cpp | 2 +- src/Tags.cpp | 2 +- src/effects/Effect.cpp | 16 ++++++++-------- src/effects/Equalization.cpp | 4 ++-- src/effects/VST/VSTEffect.cpp | 6 +++--- src/effects/lv2/LV2Effect.cpp | 2 +- src/export/ExportFFmpegDialogs.cpp | 4 +++- src/export/ExportPCM.cpp | 4 ++-- src/import/Import.cpp | 10 ++++++---- src/import/ImportLOF.cpp | 6 +++--- src/menus/PluginMenus.cpp | 6 +++--- src/prefs/MidiIOPrefs.cpp | 2 +- src/widgets/FileHistory.cpp | 10 +++++----- src/widgets/KeyView.cpp | 4 ++-- src/xml/XMLWriter.cpp | 4 ++-- 22 files changed, 62 insertions(+), 57 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 39938c077..1f03cc79a 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -852,7 +852,7 @@ void AudacityApp::OnTimer(wxTimerEvent& WXUNUSED(event)) while (ofqueue.size()) { wxString name; name.swap(ofqueue[0]); - ofqueue.RemoveAt(0); + ofqueue.erase( ofqueue.begin() ); // Get the user's attention if no file name was specified if (name.empty()) { diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index dab3a543d..c00551a83 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -905,8 +905,8 @@ void MacroCommands::AddToMacro(const wxString &command, const wxString ¶ms, before = (int)mCommandMacro.size(); } - mCommandMacro.Insert(command, before); - mParamsMacro.Insert(params, before); + mCommandMacro.insert(mCommandMacro.begin() + before, command); + mParamsMacro.insert(mParamsMacro.begin() + before, params); } void MacroCommands::DeleteFromMacro(int index) @@ -915,8 +915,8 @@ void MacroCommands::DeleteFromMacro(int index) return; } - mCommandMacro.RemoveAt(index); - mParamsMacro.RemoveAt(index); + mCommandMacro.erase( mCommandMacro.begin() + index ); + mParamsMacro.erase( mParamsMacro.begin() + index ); } void MacroCommands::ResetMacro() diff --git a/src/DirManager.cpp b/src/DirManager.cpp index e451ca37b..57c694e8c 100644 --- a/src/DirManager.cpp +++ b/src/DirManager.cpp @@ -1642,7 +1642,8 @@ bool DirManager::EnsureSafeFilename(const wxFileName &fName) } - aliasList.Remove(fullPath); + aliasList.erase( + std::find( aliasList.begin(), aliasList.end(), fullPath ) ); aliasList.push_back(renamedFullPath); } diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index c3f623f88..ecddabad4 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -782,8 +782,8 @@ bool FFmpegLibs::InitLibs(const wxString &libpath_format, bool WXUNUSED(showerr) if (!gotError) { avutil_filename = FileNames::PathFromAddr(avformat->GetSymbol(wxT("avutil_version"))); avcodec_filename = FileNames::PathFromAddr(avformat->GetSymbol(wxT("avcodec_version"))); - if (avutil_filename.GetFullPath().IsSameAs(nameFull)) { - if (avcodec_filename.GetFullPath().IsSameAs(nameFull)) { + if (avutil_filename.GetFullPath() == nameFull) { + if (avcodec_filename.GetFullPath() == nameFull) { util = avformat.get(); codec = avformat.get(); } diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp index f4a8ed967..6a2d36e6f 100644 --- a/src/LabelTrack.cpp +++ b/src/LabelTrack.cpp @@ -1877,7 +1877,7 @@ bool LabelTrack::OnKeyDown(SelectedRegion &newSel, wxKeyEvent & event) { // DELETE one letter if (mCurrentCursorPos > 0) { - title.Remove(mCurrentCursorPos-1, 1); + title.erase(mCurrentCursorPos-1, 1); mCurrentCursorPos--; } } @@ -1907,7 +1907,7 @@ bool LabelTrack::OnKeyDown(SelectedRegion &newSel, wxKeyEvent & event) { // DELETE one letter if (mCurrentCursorPos < len) { - title.Remove(mCurrentCursorPos, 1); + title.erase(mCurrentCursorPos, 1); } } } diff --git a/src/ModuleManager.cpp b/src/ModuleManager.cpp index d87887536..919ed9a22 100755 --- a/src/ModuleManager.cpp +++ b/src/ModuleManager.cpp @@ -120,7 +120,7 @@ bool Module::Load() } wxString moduleVersion = versionFn(); - if( !moduleVersion.IsSameAs(AUDACITY_VERSION_STRING)) { + if( moduleVersion != AUDACITY_VERSION_STRING) { wxString ShortName = wxFileName( mName ).GetName(); AudacityMessageBox(wxString::Format(_("The module %s is matched with Audacity version %s.\n\nIt will not be loaded."), ShortName, moduleVersion), _("Module Unsuitable")); wxLogMessage(wxString::Format(_("The module %s is matched with Audacity version %s. It will not be loaded."), mName, moduleVersion)); diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 9f60b1faf..dabff281a 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -1405,7 +1405,7 @@ bool PluginManager::IsPluginRegistered(const wxString & path) { for (PluginMap::iterator iter = mPlugins.begin(); iter != mPlugins.end(); ++iter) { - if (iter->second.GetPath().IsSameAs(path)) + if (iter->second.GetPath() == path) { return true; } @@ -2124,17 +2124,17 @@ void PluginManager::LoadGroup(wxFileConfig *pRegistry, PluginType type) if (!pRegistry->Read(KEY_EFFECTTYPE, &strVal)) continue; - if (strVal.IsSameAs(KEY_EFFECTTYPE_NONE)) + if (strVal == KEY_EFFECTTYPE_NONE) plug.SetEffectType(EffectTypeNone); - else if (strVal.IsSameAs(KEY_EFFECTTYPE_ANALYZE)) + else if (strVal == KEY_EFFECTTYPE_ANALYZE) plug.SetEffectType(EffectTypeAnalyze); - else if (strVal.IsSameAs(KEY_EFFECTTYPE_GENERATE)) + else if (strVal == KEY_EFFECTTYPE_GENERATE) plug.SetEffectType(EffectTypeGenerate); - else if (strVal.IsSameAs(KEY_EFFECTTYPE_PROCESS)) + else if (strVal == KEY_EFFECTTYPE_PROCESS) plug.SetEffectType(EffectTypeProcess); - else if (strVal.IsSameAs(KEY_EFFECTTYPE_TOOL)) + else if (strVal == KEY_EFFECTTYPE_TOOL) plug.SetEffectType(EffectTypeTool); - else if (strVal.IsSameAs(KEY_EFFECTTYPE_HIDDEN)) + else if (strVal == KEY_EFFECTTYPE_HIDDEN) plug.SetEffectType(EffectTypeHidden); else continue; diff --git a/src/Shuttle.cpp b/src/Shuttle.cpp index ff2ccc547..47a170e70 100644 --- a/src/Shuttle.cpp +++ b/src/Shuttle.cpp @@ -194,7 +194,7 @@ bool Shuttle::TransferEnum( const wxString & Name, int & iValue, for( int i = 0; i < nChoices; i++ ) { - if( str.IsSameAs( pFirstStr[i] )) + if( str == pFirstStr[i] ) { iValue = i; break; diff --git a/src/Tags.cpp b/src/Tags.cpp index bc0c701d9..4d636c42c 100644 --- a/src/Tags.cpp +++ b/src/Tags.cpp @@ -484,7 +484,7 @@ void Tags::SetTag(const wxString & name, const wxString & value) mXref[key] = name; mMap[name] = value; } - else if (!iter->second.IsSameAs(name)) { + else if (iter->second != name) { // Watch out for case differences! mMap[name] = value; mMap.erase(iter->second); diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 3ebf89426..2d65cd1e8 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -3994,7 +3994,7 @@ void EffectPresetsDialog::SetPrefix(const wxString & type, const wxString & pref { mType->SetStringSelection(type); - if (type.IsSameAs(_("User Presets"))) + if (type == _("User Presets")) { mPresets->Clear(); mPresets->Append(mUserPresets); @@ -4006,7 +4006,7 @@ void EffectPresetsDialog::SetPrefix(const wxString & type, const wxString & pref } mSelection = Effect::kUserPresetIdent + mPresets->GetStringSelection(); } - else if (type.IsSameAs(_("Factory Presets"))) + else if (type == _("Factory Presets")) { mPresets->Clear(); for (size_t i = 0, cnt = mFactoryPresets.size(); i < cnt; i++) @@ -4026,13 +4026,13 @@ void EffectPresetsDialog::SetPrefix(const wxString & type, const wxString & pref } mSelection = Effect::kFactoryPresetIdent + mPresets->GetStringSelection(); } - else if (type.IsSameAs(_("Current Settings"))) + else if (type == _("Current Settings")) { mPresets->Clear(); mPresets->Enable(false); mSelection = Effect::kCurrentSettingsIdent; } - else if (type.IsSameAs(_("Factory Defaults"))) + else if (type == _("Factory Defaults")) { mPresets->Clear(); mPresets->Enable(false); @@ -4050,7 +4050,7 @@ void EffectPresetsDialog::UpdateUI() } wxString type = mType->GetString(selected); - if (type.IsSameAs(_("User Presets"))) + if (type == _("User Presets")) { selected = mPresets->GetSelection(); if (selected == wxNOT_FOUND) @@ -4064,7 +4064,7 @@ void EffectPresetsDialog::UpdateUI() mPresets->SetSelection(selected); mSelection = Effect::kUserPresetIdent + mPresets->GetString(selected); } - else if (type.IsSameAs(_("Factory Presets"))) + else if (type == _("Factory Presets")) { selected = mPresets->GetSelection(); if (selected == wxNOT_FOUND) @@ -4086,13 +4086,13 @@ void EffectPresetsDialog::UpdateUI() mPresets->SetSelection(selected); mSelection = Effect::kFactoryPresetIdent + mPresets->GetString(selected); } - else if (type.IsSameAs(_("Current Settings"))) + else if (type == _("Current Settings")) { mPresets->Clear(); mPresets->Enable(false); mSelection = Effect::kCurrentSettingsIdent; } - else if (type.IsSameAs(_("Factory Defaults"))) + else if (type == _("Factory Defaults")) { mPresets->Clear(); mPresets->Enable(false); diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 8874190aa..47921a847 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -367,7 +367,7 @@ bool EffectEqualization::ValidateUI() // If editing a macro, we don't want to be using the unnamed curve so // we offer to save it. - if (mDisallowCustom && mCurveName.IsSameAs(wxT("unnamed"))) + if (mDisallowCustom && mCurveName == wxT("unnamed")) { // PRL: This is unreachable. mDisallowCustom is always false. @@ -3338,7 +3338,7 @@ void EditCurvesDialog::OnRename(wxCommandEvent & WXUNUSED(event)) for( curve = 0; curve < numCurves; curve++ ) { wxString temp = mEditCurves[ curve ].Name; - if( name.IsSameAs( mEditCurves[ curve ].Name )) // case sensitive + if( name == mEditCurves[ curve ].Name ) // case sensitive { bad = true; if( curve == item ) // trying to rename a curve with the same name diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 84f007840..10d3dfdde 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -417,7 +417,7 @@ wxArrayString VSTEffectsModule::FindPluginPaths(PluginManagerInterface & pm) files[i] = wxPathOnly(wxPathOnly(files[i])); if (!files[i].EndsWith(wxT(".vst"))) { - files.RemoveAt(i--); + files.erase( files.begin() + i-- ); } } @@ -619,12 +619,12 @@ unsigned VSTEffectsModule::DiscoverPluginsAtPath( break; case kKeyInteractive: - proc.mInteractive = val.IsSameAs(wxT("1")); + proc.mInteractive = val == wxT("1"); keycount++; break; case kKeyAutomatable: - proc.mAutomatable = val.IsSameAs(wxT("1")); + proc.mAutomatable = val == wxT("1"); keycount++; break; diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index 013f7c9b3..30926e7f8 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -2103,7 +2103,7 @@ void LV2Effect::SetPortValue(const char *port_symbol, for (size_t p = 0, cnt = mControls.size(); p < cnt; p++) { - if (mControls[p].mSymbol.IsSameAs(symbol)) + if (mControls[p].mSymbol == symbol) { if (type == Bool && size == sizeof(bool)) { diff --git a/src/export/ExportFFmpegDialogs.cpp b/src/export/ExportFFmpegDialogs.cpp index 15e8b1b67..aea0dec2f 100644 --- a/src/export/ExportFFmpegDialogs.cpp +++ b/src/export/ExportFFmpegDialogs.cpp @@ -1818,7 +1818,9 @@ void ExportFFmpegOptions::OnDeletePreset(wxCommandEvent& WXUNUSED(event)) long index = preset->FindString(presetname); preset->SetValue(wxEmptyString); preset->Delete(index); - mPresetNames.Remove(presetname); + mPresetNames.erase( + std::find( mPresetNames.begin(), mPresetNames.end(), presetname ) + ); } /// diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index b6257a113..6d13c75e9 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -389,8 +389,8 @@ ExportPCM::ExportPCM() #if defined(wxMSW) // On Windows make sure WAV is at the beginning of the list of all possible // extensions for this format - allext.Remove(wavext); - allext.Insert(wavext, 0); + allext.erase( std::find( allext.begin(), allext.end(), wavext ) ); + allext.insert(allext.begin(), wavext); #endif SetExtensions(allext, format); SetMaxChannels(255, format); diff --git a/src/import/Import.cpp b/src/import/Import.cpp index f87061480..631a7bce8 100644 --- a/src/import/Import.cpp +++ b/src/import/Import.cpp @@ -236,7 +236,9 @@ void Importer::ReadImportItems() int index = new_item->divider; if (new_item->divider < 0) index = new_item->filters.size(); - new_item->filters.Insert(importPlugin->GetPluginStringID(),index); + new_item->filters.insert( + new_item->filters.begin() + index, + importPlugin->GetPluginStringID()); new_item->filter_objects.insert( new_item->filter_objects.begin() + index, importPlugin.get()); if (new_item->divider >= 0) @@ -454,7 +456,7 @@ bool Importer::Import(const wxString &fName, // in case subsequent code revisions to the constructor should break this assumption that // libsndfile is first. ImportPlugin *libsndfilePlugin = mImportPluginList.begin()->get(); - wxASSERT(libsndfilePlugin->GetPluginStringID().IsSameAs(wxT("libsndfile"))); + wxASSERT(libsndfilePlugin->GetPluginStringID() == wxT("libsndfile")); for (const auto &plugin : mImportPluginList) { @@ -472,7 +474,7 @@ bool Importer::Import(const wxString &fName, // but then get processed as desired by libmad. // But a wav file which bears an incorrect .mp3 extension will be successfully // processed by libsndfile and thus avoid being submitted to libmad. - if (plugin->GetPluginStringID().IsSameAs(wxT("libmad"))) + if (plugin->GetPluginStringID() == wxT("libmad")) { // Make sure libsndfile is not already in the list if (importPlugins.end() == @@ -494,7 +496,7 @@ bool Importer::Import(const wxString &fName, // formats unsuitable for it, and produce distorted results. for (const auto &plugin : mImportPluginList) { - if (!(plugin->GetPluginStringID().IsSameAs(wxT("libmad")))) + if (!(plugin->GetPluginStringID() == wxT("libmad"))) { // Make sure its not already in the list if (importPlugins.end() == diff --git a/src/import/ImportLOF.cpp b/src/import/ImportLOF.cpp index 81ddbc9d3..35a896916 100644 --- a/src/import/ImportLOF.cpp +++ b/src/import/ImportLOF.cpp @@ -344,7 +344,7 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln) } } // End if statement - if (tokenholder.IsSameAs(wxT("#"))) + if (tokenholder == wxT("#")) { // # indicates comments; ignore line tok = wxStringTokenizer(wxT(""), wxT(" ")); @@ -399,7 +399,7 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln) { tokenholder = tok.GetNextToken(); - if (tokenholder.IsSameAs(wxT("#"))) + if (tokenholder == wxT("#")) { // # indicates comments; ignore line tok = wxStringTokenizer(wxT(""), wxT(" ")); @@ -453,7 +453,7 @@ void LOFImportFileHandle::lofOpenFiles(wxString* ln) } // End if statement (more tokens after file name) } // End if statement "file" lines - else if (tokenholder.IsSameAs(wxT("#"))) + else if (tokenholder == wxT("#")) { // # indicates comments; ignore line tok = wxStringTokenizer(wxT(""), wxT(" ")); diff --git a/src/menus/PluginMenus.cpp b/src/menus/PluginMenus.cpp index 7a0bae2be..a28201f7f 100644 --- a/src/menus/PluginMenus.cpp +++ b/src/menus/PluginMenus.cpp @@ -723,7 +723,7 @@ void AddEffectMenuItemGroup( int groupCnt = namesCnt; for (int i = 0; i < namesCnt; i++) { - while (i + 1 < namesCnt && names[i].IsSameAs(names[i + 1])) + while (i + 1 < namesCnt && names[i] == names[i + 1]) { i++; groupCnt--; @@ -757,12 +757,12 @@ void AddEffectMenuItemGroup( pTable = &temp1; } - if (i + 1 < namesCnt && names[i].IsSameAs(names[i + 1])) + if (i + 1 < namesCnt && names[i] == names[i + 1]) { // collect a sub-menu for like-named items const wxString name = names[i]; BaseItemPtrs temp2; - while (i < namesCnt && names[i].IsSameAs(name)) + while (i < namesCnt && names[i] == name) { const PluginDescriptor *plug = PluginManager::Get().GetPlugin(plugs[i]); diff --git a/src/prefs/MidiIOPrefs.cpp b/src/prefs/MidiIOPrefs.cpp index d5f771df7..5e67fbad5 100644 --- a/src/prefs/MidiIOPrefs.cpp +++ b/src/prefs/MidiIOPrefs.cpp @@ -202,7 +202,7 @@ void MidiIOPrefs::OnHost(wxCommandEvent & WXUNUSED(e)) for (int i = 0; i < nDevices; i++) { const PmDeviceInfo *info = Pm_GetDeviceInfo(i); wxString interf = wxSafeConvertMB2WX(info->interf); - if (itemAtIndex.IsSameAs(interf)) { + if (itemAtIndex == interf) { wxString name = wxSafeConvertMB2WX(info->name); wxString device = wxString::Format(wxT("%s: %s"), interf, diff --git a/src/widgets/FileHistory.cpp b/src/widgets/FileHistory.cpp index 8f40cb40e..ad07c0938 100644 --- a/src/widgets/FileHistory.cpp +++ b/src/widgets/FileHistory.cpp @@ -48,14 +48,14 @@ void FileHistory::AddFileToHistory(const wxString & file, bool update) #endif if (i != wxNOT_FOUND) { - mHistory.RemoveAt(i); + mHistory.erase( mHistory.begin() + i ); } - if (mMaxFiles == mHistory.size()) { - mHistory.RemoveAt(mHistory.size() - 1); + if (mMaxFiles > 0 && mMaxFiles == mHistory.size()) { + mHistory.erase( mHistory.end() - 1 ); } - mHistory.Insert(file, 0); + mHistory.insert(mHistory.begin(), file); if (update) { AddFilesToMenu(); @@ -67,7 +67,7 @@ void FileHistory::RemoveFileFromHistory(size_t i, bool update) wxASSERT(i < mHistory.size()); if (i < mHistory.size()) { - mHistory.RemoveAt(i); + mHistory.erase( mHistory.begin() + i ); if (update) { AddFilesToMenu(); diff --git a/src/widgets/KeyView.cpp b/src/widgets/KeyView.cpp index 331995699..520263d77 100644 --- a/src/widgets/KeyView.cpp +++ b/src/widgets/KeyView.cpp @@ -778,9 +778,9 @@ KeyView::RefreshLines(bool bSort) // For the Key View, if the filter is a single character, // then it has to be the last character in the searchit string, // and be preceded by nothing or +. - if ((mViewType == ViewByKey) && + if ((mViewType == ViewByKey) && (mFilter.length() == 1) && - (!mFilter.IsSameAs(searchit.Last()) || + (mFilter != searchit.Last() || ((searchit.length() > 1) && ((wxString)(searchit.GetChar(searchit.length() - 2)) != wxT("+"))))) { diff --git a/src/xml/XMLWriter.cpp b/src/xml/XMLWriter.cpp index 35434404b..1b6d4e8b5 100644 --- a/src/xml/XMLWriter.cpp +++ b/src/xml/XMLWriter.cpp @@ -91,7 +91,7 @@ void XMLWriter::StartTag(const wxString &name) Write(wxString::Format(wxT("<%s"), name)); - mTagstack.Insert(name, 0); + mTagstack.insert(mTagstack.begin(), name); mHasKids[0] = true; mHasKids.insert(mHasKids.begin(), false); mDepth++; @@ -119,7 +119,7 @@ void XMLWriter::EndTag(const wxString &name) else { Write(wxT(">\n")); } - mTagstack.RemoveAt(0); + mTagstack.erase( mTagstack.begin() ); mHasKids.erase(mHasKids.begin()); } }