1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-24 07:05:43 +01:00

Use standard library style members of wxArrayString (and wxString) ...

... which will make it easier to change the types of those containers to
std::vectors of other string-like classes

for wxString,

IsEmpty => empty
Clear => clear
Alloc => reserve

for wxArrayString,

Count => size
GetCount => size
IsEmpty => empty
Add => push_back
Clear => clear
Empty => clear
Sort => std::sort (only with default comparator)
SetCount => resize
Last => back
Item => operator []
Alloc => reserve
This commit is contained in:
Paul Licameli
2019-02-11 19:10:48 -05:00
parent 5daa67dfe6
commit 2db49dc1f0
115 changed files with 728 additions and 728 deletions

View File

@@ -149,7 +149,7 @@ ExportFFmpegAC3Options::ExportFFmpegAC3Options(wxWindow *parent, int WXUNUSED(fo
{
for (unsigned int i=0; i < (sizeof(iAC3BitRates)/sizeof(int)); i++)
{
mBitRateNames.Add(wxString::Format(_("%i kbps"),iAC3BitRates[i]/1000));
mBitRateNames.push_back(wxString::Format(_("%i kbps"),iAC3BitRates[i]/1000));
mBitRateLabels.push_back(iAC3BitRates[i]);
}
@@ -275,7 +275,7 @@ ExportFFmpegAMRNBOptions::ExportFFmpegAMRNBOptions(wxWindow *parent, int WXUNUSE
{
for (unsigned int i=0; i < (sizeof(iAMRNBBitRate)/sizeof(int)); i++)
{
mBitRateNames.Add(wxString::Format(_("%.2f kbps"),(float)iAMRNBBitRate[i]/1000));
mBitRateNames.push_back(wxString::Format(_("%.2f kbps"),(float)iAMRNBBitRate[i]/1000));
mBitRateLabels.push_back(iAMRNBBitRate[i]);
}
@@ -346,7 +346,7 @@ ExportFFmpegWMAOptions::ExportFFmpegWMAOptions(wxWindow *parent, int WXUNUSED(fo
for (unsigned int i=0; i < (sizeof(iWMABitRate)/sizeof(int)); i++)
{
/* i18n-hint: abbreviates thousands of bits per second */
mBitRateNames.Add(wxString::Format(_("%i kbps"),iWMABitRate[i]/1000));
mBitRateNames.push_back(wxString::Format(_("%i kbps"),iWMABitRate[i]/1000));
mBitRateLabels.push_back(iWMABitRate[i]);
}
@@ -476,7 +476,7 @@ void ExportFFmpegCustomOptions::OnOpen(wxCommandEvent & WXUNUSED(evt))
FFmpegPreset::FFmpegPreset()
{
mControlState.SetCount(FELastID - FEFirstID);
mControlState.resize(FELastID - FEFirstID);
}
FFmpegPreset::~FFmpegPreset()
@@ -532,14 +532,14 @@ void FFmpegPresets::ExportPresets(wxString &filename)
void FFmpegPresets::GetPresetList(wxArrayString &list)
{
list.Clear();
list.clear();
FFmpegPresetMap::iterator iter;
for (iter = mPresets.begin(); iter != mPresets.end(); ++iter)
{
list.Add(iter->second.mPresetName);
list.push_back(iter->second.mPresetName);
}
list.Sort();
std::sort( list.begin(), list.end() );
}
void FFmpegPresets::DeletePreset(wxString &name)
@@ -613,10 +613,10 @@ void FFmpegPresets::SavePreset(ExportFFmpegOptions *parent, wxString &name)
switch(id)
{
case FEFormatID:
preset->mControlState.Item(id - FEFirstID) = format;
preset->mControlState[id - FEFirstID] = format;
break;
case FECodecID:
preset->mControlState.Item(id - FEFirstID) = codec;
preset->mControlState[id - FEFirstID] = codec;
break;
// Spin control
case FEBitrateID:
@@ -634,26 +634,26 @@ void FFmpegPresets::SavePreset(ExportFFmpegOptions *parent, wxString &name)
case FEMuxRateID:
case FEPacketSizeID:
sc = dynamic_cast<wxSpinCtrl*>(wnd);
preset->mControlState.Item(id - FEFirstID) = wxString::Format(wxT("%d"),sc->GetValue());
preset->mControlState[id - FEFirstID] = wxString::Format(wxT("%d"),sc->GetValue());
break;
// Text control
case FELanguageID:
case FETagID:
tc = dynamic_cast<wxTextCtrl*>(wnd);
preset->mControlState.Item(id - FEFirstID) = tc->GetValue();
preset->mControlState[id - FEFirstID] = tc->GetValue();
break;
// Choice
case FEProfileID:
case FEPredOrderID:
ch = dynamic_cast<wxChoice*>(wnd);
preset->mControlState.Item(id - FEFirstID) = wxString::Format(wxT("%d"),ch->GetSelection());
preset->mControlState[id - FEFirstID] = wxString::Format(wxT("%d"),ch->GetSelection());
break;
// Check box
case FEUseLPCID:
case FEBitReservoirID:
case FEVariableBlockLenID:
cb = dynamic_cast<wxCheckBox*>(wnd);
preset->mControlState.Item(id - FEFirstID) = wxString::Format(wxT("%d"),cb->GetValue());
preset->mControlState[id - FEFirstID] = wxString::Format(wxT("%d"),cb->GetValue());
break;
}
}
@@ -689,7 +689,7 @@ void FFmpegPresets::LoadPreset(ExportFFmpegOptions *parent, wxString &name)
case FEFormatID:
case FECodecID:
lb = dynamic_cast<wxListBox*>(wnd);
readstr = preset->mControlState.Item(id - FEFirstID);
readstr = preset->mControlState[id - FEFirstID];
readlong = lb->FindString(readstr);
if (readlong > -1) lb->Select(readlong);
break;
@@ -709,20 +709,20 @@ void FFmpegPresets::LoadPreset(ExportFFmpegOptions *parent, wxString &name)
case FEMuxRateID:
case FEPacketSizeID:
sc = dynamic_cast<wxSpinCtrl*>(wnd);
preset->mControlState.Item(id - FEFirstID).ToLong(&readlong);
preset->mControlState[id - FEFirstID].ToLong(&readlong);
sc->SetValue(readlong);
break;
// Text control
case FELanguageID:
case FETagID:
tc = dynamic_cast<wxTextCtrl*>(wnd);
tc->SetValue(preset->mControlState.Item(id - FEFirstID));
tc->SetValue(preset->mControlState[id - FEFirstID]);
break;
// Choice
case FEProfileID:
case FEPredOrderID:
ch = dynamic_cast<wxChoice*>(wnd);
preset->mControlState.Item(id - FEFirstID).ToLong(&readlong);
preset->mControlState[id - FEFirstID].ToLong(&readlong);
if (readlong > -1) ch->Select(readlong);
break;
// Check box
@@ -730,7 +730,7 @@ void FFmpegPresets::LoadPreset(ExportFFmpegOptions *parent, wxString &name)
case FEBitReservoirID:
case FEVariableBlockLenID:
cb = dynamic_cast<wxCheckBox*>(wnd);
preset->mControlState.Item(id - FEFirstID).ToLong(&readlong);
preset->mControlState[id - FEFirstID].ToLong(&readlong);
if (readlong) readbool = true; else readbool = false;
cb->SetValue(readbool);
break;
@@ -810,7 +810,7 @@ bool FFmpegPresets::HandleXMLTag(const wxChar *tag, const wxChar **attrs)
else if (!wxStrcmp(attr,wxT("state")))
{
if (id > FEFirstID && id < FELastID)
mPreset->mControlState.Item(id - FEFirstID) = wxString(value);
mPreset->mControlState[id - FEFirstID] = wxString(value);
}
}
return true;
@@ -872,7 +872,7 @@ void FFmpegPresets::WriteXML(XMLWriter &xmlFile) const
{
xmlFile.StartTag(wxT("setctrlstate"));
xmlFile.WriteAttr(wxT("id"),wxString(FFmpegExportCtrlIDNames[i - FEFirstID]));
xmlFile.WriteAttr(wxT("state"),preset->mControlState.Item(i - FEFirstID));
xmlFile.WriteAttr(wxT("state"),preset->mControlState[i - FEFirstID]);
xmlFile.EndTag(wxT("setctrlstate"));
}
xmlFile.EndTag(wxT("preset"));
@@ -1385,12 +1385,12 @@ ExportFFmpegOptions::ExportFFmpegOptions(wxWindow *parent)
for (unsigned int i = 0; i < 6; i++)
{
mPredictionOrderMethodLabels.push_back(i);
mPredictionOrderMethodNames.Add(wxString::Format(wxT("%s"),PredictionOrderMethodNames(i)));
mPredictionOrderMethodNames.push_back(wxString::Format(wxT("%s"),PredictionOrderMethodNames(i)));
}
for (unsigned int i=0; i < (sizeof(iAACProfileValues)/sizeof(int)); i++)
{
mProfileNames.Add(wxString::Format(wxT("%s"),iAACProfileNames(i)));
mProfileNames.push_back(wxString::Format(wxT("%s"),iAACProfileNames(i)));
mProfileLabels.push_back(iAACProfileValues[i]);
}
@@ -1420,8 +1420,8 @@ void ExportFFmpegOptions::FetchFormatList()
// If it doesn't, then it doesn't supports any audio codecs
if (ofmt->audio_codec != AV_CODEC_ID_NONE)
{
mFormatNames.Add(wxString::FromUTF8(ofmt->name));
mFormatLongNames.Add(wxString::Format(wxT("%s - %s"),mFormatNames.Last(),wxString::FromUTF8(ofmt->long_name)));
mFormatNames.push_back(wxString::FromUTF8(ofmt->name));
mFormatLongNames.push_back(wxString::Format(wxT("%s - %s"),mFormatNames.back(),wxString::FromUTF8(ofmt->long_name)));
}
}
// Show all formats
@@ -1440,8 +1440,8 @@ void ExportFFmpegOptions::FetchCodecList()
// We're only interested in audio and only in encoders
if (codec->type == AVMEDIA_TYPE_AUDIO && av_codec_is_encoder(codec))
{
mCodecNames.Add(wxString::FromUTF8(codec->name));
mCodecLongNames.Add(wxString::Format(wxT("%s - %s"),mCodecNames.Last(),wxString::FromUTF8(codec->long_name)));
mCodecNames.push_back(wxString::FromUTF8(codec->name));
mCodecLongNames.push_back(wxString::Format(wxT("%s - %s"),mCodecNames.back(),wxString::FromUTF8(codec->long_name)));
}
}
// Show all codecs
@@ -1660,8 +1660,8 @@ int ExportFFmpegOptions::FetchCompatibleCodecList(const wxChar *fmt, AVCodecID i
// By default assume that id is not in the list
int index = -1;
// By default no codecs are compatible (yet)
mShownCodecNames.Clear();
mShownCodecLongNames.Clear();
mShownCodecNames.clear();
mShownCodecLongNames.clear();
// Clear the listbox
mCodecList->Clear();
// Zero - format is not found at all
@@ -1685,9 +1685,9 @@ int ExportFFmpegOptions::FetchCompatibleCodecList(const wxChar *fmt, AVCodecID i
if (codec != NULL && (codec->type == AVMEDIA_TYPE_AUDIO) && av_codec_is_encoder(codec))
{
// If it was selected - remember it's NEW index
if ((id >= 0) && codec->id == id) index = mShownCodecNames.GetCount();
mShownCodecNames.Add(wxString::FromUTF8(codec->name));
mShownCodecLongNames.Add(wxString::Format(wxT("%s - %s"),mShownCodecNames.Last(),wxString::FromUTF8(codec->long_name)));
if ((id >= 0) && codec->id == id) index = mShownCodecNames.size();
mShownCodecNames.push_back(wxString::FromUTF8(codec->name));
mShownCodecLongNames.push_back(wxString::Format(wxT("%s - %s"),mShownCodecNames.back(),wxString::FromUTF8(codec->long_name)));
}
}
}
@@ -1701,9 +1701,9 @@ int ExportFFmpegOptions::FetchCompatibleCodecList(const wxChar *fmt, AVCodecID i
{
if (mShownCodecNames.Index(wxString::FromUTF8(codec->name)) < 0)
{
if ((id >= 0) && codec->id == id) index = mShownCodecNames.GetCount();
mShownCodecNames.Add(wxString::FromUTF8(codec->name));
mShownCodecLongNames.Add(wxString::Format(wxT("%s - %s"),mShownCodecNames.Last(),wxString::FromUTF8(codec->long_name)));
if ((id >= 0) && codec->id == id) index = mShownCodecNames.size();
mShownCodecNames.push_back(wxString::FromUTF8(codec->name));
mShownCodecLongNames.push_back(wxString::Format(wxT("%s - %s"),mShownCodecNames.back(),wxString::FromUTF8(codec->long_name)));
}
}
}
@@ -1719,9 +1719,9 @@ int ExportFFmpegOptions::FetchCompatibleCodecList(const wxChar *fmt, AVCodecID i
AVCodec *codec = avcodec_find_encoder(format->audio_codec);
if (codec != NULL && (codec->type == AVMEDIA_TYPE_AUDIO) && av_codec_is_encoder(codec))
{
if ((id >= 0) && codec->id == id) index = mShownCodecNames.GetCount();
mShownCodecNames.Add(wxString::FromUTF8(codec->name));
mShownCodecLongNames.Add(wxString::Format(wxT("%s - %s"),mShownCodecNames.Last(),wxString::FromUTF8(codec->long_name)));
if ((id >= 0) && codec->id == id) index = mShownCodecNames.size();
mShownCodecNames.push_back(wxString::FromUTF8(codec->name));
mShownCodecLongNames.push_back(wxString::Format(wxT("%s - %s"),mShownCodecNames.back(),wxString::FromUTF8(codec->long_name)));
}
}
}
@@ -1736,8 +1736,8 @@ int ExportFFmpegOptions::FetchCompatibleCodecList(const wxChar *fmt, AVCodecID i
int ExportFFmpegOptions::FetchCompatibleFormatList(AVCodecID id, wxString *selfmt)
{
int index = -1;
mShownFormatNames.Clear();
mShownFormatLongNames.Clear();
mShownFormatNames.clear();
mShownFormatLongNames.clear();
mFormatList->Clear();
AVOutputFormat *ofmt = NULL;
ofmt = NULL;
@@ -1747,11 +1747,11 @@ int ExportFFmpegOptions::FetchCompatibleFormatList(AVCodecID id, wxString *selfm
{
if (CompatibilityList[i].codec == id || CompatibilityList[i].codec == AV_CODEC_ID_NONE)
{
if ((selfmt != NULL) && (selfmt->Cmp(CompatibilityList[i].fmt) == 0)) index = mShownFormatNames.GetCount();
FromList.Add(CompatibilityList[i].fmt);
mShownFormatNames.Add(CompatibilityList[i].fmt);
if ((selfmt != NULL) && (selfmt->Cmp(CompatibilityList[i].fmt) == 0)) index = mShownFormatNames.size();
FromList.push_back(CompatibilityList[i].fmt);
mShownFormatNames.push_back(CompatibilityList[i].fmt);
AVOutputFormat *tofmt = av_guess_format(wxString(CompatibilityList[i].fmt).ToUTF8(),NULL,NULL);
if (tofmt != NULL) mShownFormatLongNames.Add(wxString::Format(wxT("%s - %s"),CompatibilityList[i].fmt,wxString::FromUTF8(tofmt->long_name)));
if (tofmt != NULL) mShownFormatLongNames.push_back(wxString::Format(wxT("%s - %s"),CompatibilityList[i].fmt,wxString::FromUTF8(tofmt->long_name)));
}
}
bool found = false;
@@ -1776,7 +1776,7 @@ int ExportFFmpegOptions::FetchCompatibleFormatList(AVCodecID id, wxString *selfm
{
wxString ofmtname = wxString::FromUTF8(ofmt->name);
found = false;
for (unsigned int i = 0; i < FromList.GetCount(); i++)
for (unsigned int i = 0; i < FromList.size(); i++)
{
if (ofmtname.Cmp(FromList[i]) == 0)
{
@@ -1786,9 +1786,9 @@ int ExportFFmpegOptions::FetchCompatibleFormatList(AVCodecID id, wxString *selfm
}
if (!found)
{
if ((selfmt != NULL) && (selfmt->Cmp(wxString::FromUTF8(ofmt->name)) == 0)) index = mShownFormatNames.GetCount();
mShownFormatNames.Add(wxString::FromUTF8(ofmt->name));
mShownFormatLongNames.Add(wxString::Format(wxT("%s - %s"),mShownFormatNames.Last(),wxString::FromUTF8(ofmt->long_name)));
if ((selfmt != NULL) && (selfmt->Cmp(wxString::FromUTF8(ofmt->name)) == 0)) index = mShownFormatNames.size();
mShownFormatNames.push_back(wxString::FromUTF8(ofmt->name));
mShownFormatLongNames.push_back(wxString::Format(wxT("%s - %s"),mShownFormatNames.back(),wxString::FromUTF8(ofmt->long_name)));
}
}
}
@@ -1803,7 +1803,7 @@ void ExportFFmpegOptions::OnDeletePreset(wxCommandEvent& WXUNUSED(event))
{
wxComboBox *preset = dynamic_cast<wxComboBox*>(FindWindowById(FEPresetID,this));
wxString presetname = preset->GetValue();
if (presetname.IsEmpty())
if (presetname.empty())
{
AudacityMessageBox(_("You can't delete a preset without name"));
return;
@@ -1826,7 +1826,7 @@ void ExportFFmpegOptions::OnSavePreset(wxCommandEvent& WXUNUSED(event))
{
wxComboBox *preset = dynamic_cast<wxComboBox*>(FindWindowById(FEPresetID,this));
wxString name = preset->GetValue();
if (name.IsEmpty())
if (name.empty())
{
AudacityMessageBox(_("You can't save a preset without name"));
return;
@@ -1835,7 +1835,7 @@ void ExportFFmpegOptions::OnSavePreset(wxCommandEvent& WXUNUSED(event))
int index = mPresetNames.Index(name,false);
if (index == -1)
{
mPresetNames.Add(name);
mPresetNames.push_back(name);
mPresetCombo->Clear();
mPresetCombo->Append(mPresetNames);
mPresetCombo->Select(mPresetNames.Index(name,false));