1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-18 17:10:55 +02:00

More std:: style for wxString...

... Remove all uses of the three-valued Cmp comparison member function, which
returns 0 for equality, except in one place.  Use operators == and != instead.

(C++20's spaceship operator hasn't landed here yet!)
This commit is contained in:
Paul Licameli 2019-03-10 14:12:35 -04:00
parent 795b6a2e42
commit 2a1bf3a77f
5 changed files with 15 additions and 10 deletions

View File

@ -825,6 +825,8 @@ int wxCALLBACK PluginRegistrationDialog::SortCompare(long item1, long item2, lon
int PluginRegistrationDialog::SortCompare(ItemData *item1, ItemData *item2)
{
// This function is a three-valued comparator
wxString *str1;
wxString *str2;

View File

@ -577,7 +577,7 @@ wxMenuBar * CommandManager::GetMenuBar(const wxString & sMenu) const
{
for (const auto &entry : mMenuBarList)
{
if(!entry.name.Cmp(sMenu))
if(entry.name == sMenu)
return entry.menubar;
}

View File

@ -1669,7 +1669,7 @@ int ExportFFmpegOptions::FetchCompatibleCodecList(const wxChar *fmt, AVCodecID i
wxString str(fmt);
for (int i = 0; CompatibilityList[i].fmt != NULL; i++)
{
if (str.Cmp(CompatibilityList[i].fmt) == 0)
if (str == CompatibilityList[i].fmt)
{
// Format is found in the list
found = 1;
@ -1748,7 +1748,7 @@ 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.size();
if ((selfmt != NULL) && (*selfmt == CompatibilityList[i].fmt)) 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);
@ -1760,7 +1760,7 @@ int ExportFFmpegOptions::FetchCompatibleFormatList(AVCodecID id, wxString *selfm
{
for (int i = 0; CompatibilityList[i].fmt != NULL; i++)
{
if (!selfmt->Cmp(CompatibilityList[i].fmt))
if (*selfmt == CompatibilityList[i].fmt)
{
found = true;
break;
@ -1779,7 +1779,7 @@ int ExportFFmpegOptions::FetchCompatibleFormatList(AVCodecID id, wxString *selfm
found = false;
for (unsigned int i = 0; i < FromList.size(); i++)
{
if (ofmtname.Cmp(FromList[i]) == 0)
if (ofmtname == FromList[i])
{
found = true;
break;
@ -1787,7 +1787,9 @@ int ExportFFmpegOptions::FetchCompatibleFormatList(AVCodecID id, wxString *selfm
}
if (!found)
{
if ((selfmt != NULL) && (selfmt->Cmp(wxString::FromUTF8(ofmt->name)) == 0)) index = mShownFormatNames.size();
if ((selfmt != NULL) &&
(*selfmt == wxString::FromUTF8(ofmt->name)))
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)));
}
@ -1934,8 +1936,9 @@ void ExportFFmpegOptions::EnableDisableControls(AVCodec *cdc, wxString *selfmt)
bool format = false;
if (apptable[i].codec == AV_CODEC_ID_NONE) codec = true;
else if (cdc != NULL && apptable[i].codec == cdc->id) codec = true;
if (!wxString::FromUTF8(apptable[i].format).Cmp(wxT("any"))) format = true;
else if (selfmt != NULL && selfmt->Cmp(wxString::FromUTF8(apptable[i].format)) == 0) format = true;
if (wxString::FromUTF8(apptable[i].format) == wxT("any")) format = true;
else if (selfmt != NULL &&
*selfmt == wxString::FromUTF8(apptable[i].format)) format = true;
if (codec && format)
{
handled = apptable[i].control;

View File

@ -207,7 +207,7 @@ void Importer::ReadImportItems()
bool found = false;
for (const auto &importPlugin : mImportPluginList)
{
if (importPlugin->GetPluginStringID().Cmp(new_item->filters[i]) == 0)
if (importPlugin->GetPluginStringID() == new_item->filters[i])
{
new_item->filter_objects.push_back(importPlugin.get());
found = true;

View File

@ -505,7 +505,7 @@ void ExtImportPrefs::OnRuleTableEdit (wxGridEvent& event)
wxString trimmed = vals[i];
trimmed.Trim().Trim(false);
if (trimmed.Cmp(vals[i]) != 0)
if (trimmed != vals[i])
{
if (!askedAboutSpaces)
{