From: <man...@us...> - 2014-09-28 08:55:22
|
Revision: 4317 http://sourceforge.net/p/modplug/code/4317 Author: manxorist Date: 2014-09-28 08:55:05 +0000 (Sun, 28 Sep 2014) Log Message: ----------- [Ref] Replace all trivial occurences of mpt::String::Format with typesafe mpt::String::Print. [Fix] Fix format type bug in the lame based mp3 stream encoder error reporting. Modified Paths: -------------- trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/StreamEncoder.cpp trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp trunk/OpenMPT/mptrack/StreamEncoderWAV.cpp trunk/OpenMPT/mptrack/TuningDialog.cpp Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -386,7 +386,7 @@ if(numRemovedPatterns) { - modDoc.AddToLog(mpt::String::Format("%u pattern%s removed.", numRemovedPatterns, numRemovedPatterns == 1 ? "" : "s")); + modDoc.AddToLog(mpt::String::Print("%1 pattern%2 removed.", numRemovedPatterns, numRemovedPatterns == 1 ? "" : "s")); return true; } return false; Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -186,7 +186,7 @@ // Pattern count if(m_SndFile.Patterns.GetNumPatterns() > originalSpecs->patternsMax) { - AddToLog(mpt::String::Format("Found too many patterns (%d allowed)", originalSpecs->patternsMax)); + AddToLog(mpt::String::Print("Found too many patterns (%1 allowed)", originalSpecs->patternsMax)); foundHacks = true; // REQUIRES (INTELLIGENT) AUTOFIX } @@ -224,7 +224,7 @@ } if(foundHere) { - AddToLog(mpt::String::Format("Found incompatible pattern lengths (must be between %d and %d rows)", originalSpecs->patternRowsMin, originalSpecs->patternRowsMax)); + AddToLog(mpt::String::Print("Found incompatible pattern lengths (must be between %1 and %2 rows)", originalSpecs->patternRowsMin, originalSpecs->patternRowsMax)); } // Check for invalid pattern commands @@ -253,7 +253,7 @@ // Check for too many channels if(m_SndFile.GetNumChannels() > originalSpecs->channelsMax || m_SndFile.GetNumChannels() < originalSpecs->channelsMin) { - AddToLog(mpt::String::Format("Found incompatible channel count (must be between %d and %d channels)", originalSpecs->channelsMin, originalSpecs->channelsMax)); + AddToLog(mpt::String::Print("Found incompatible channel count (must be between %1 and %2 channels)", originalSpecs->channelsMin, originalSpecs->channelsMax)); foundHacks = true; if(autofix) { @@ -283,7 +283,7 @@ // Check for too many samples if(m_SndFile.GetNumSamples() > originalSpecs->samplesMax) { - AddToLog(mpt::String::Format("Found too many samples (%d allowed)", originalSpecs->samplesMax)); + AddToLog(mpt::String::Print("Found too many samples (%1 allowed)", originalSpecs->samplesMax)); foundHacks = true; // REQUIRES (INTELLIGENT) AUTOFIX } @@ -311,7 +311,7 @@ // Check for too many instruments if(m_SndFile.GetNumInstruments() > originalSpecs->instrumentsMax) { - AddToLog(mpt::String::Format("Found too many instruments (%d allowed)", originalSpecs->instrumentsMax)); + AddToLog(mpt::String::Print("Found too many instruments (%1 allowed)", originalSpecs->instrumentsMax)); foundHacks = true; // REQUIRES (INTELLIGENT) AUTOFIX } @@ -361,7 +361,7 @@ // Check for too many orders if(m_SndFile.Order.GetLengthTailTrimmed() > originalSpecs->ordersMax) { - AddToLog(mpt::String::Format("Found too many orders (%d allowed)", originalSpecs->ordersMax)); + AddToLog(mpt::String::Print("Found too many orders (%1 allowed)", originalSpecs->ordersMax)); foundHacks = true; // REQUIRES (INTELLIGENT) AUTOFIX } @@ -369,7 +369,7 @@ // Check for invalid default tempo if(m_SndFile.m_nDefaultTempo > originalSpecs->tempoMax || m_SndFile.m_nDefaultTempo < originalSpecs->tempoMin) { - AddToLog(mpt::String::Format("Found incompatible default tempo (must be between %d and %d)", originalSpecs->tempoMin, originalSpecs->tempoMax)); + AddToLog(mpt::String::Print("Found incompatible default tempo (must be between %1 and %2)", originalSpecs->tempoMin, originalSpecs->tempoMax)); foundHacks = true; if(autofix) m_SndFile.m_nDefaultTempo = Clamp(m_SndFile.m_nDefaultTempo, originalSpecs->tempoMin, originalSpecs->tempoMax); @@ -378,7 +378,7 @@ // Check for invalid default speed if(m_SndFile.m_nDefaultSpeed > originalSpecs->speedMax || m_SndFile.m_nDefaultSpeed < originalSpecs->speedMin) { - AddToLog(mpt::String::Format("Found incompatible default speed (must be between %d and %d)", originalSpecs->speedMin, originalSpecs->speedMax)); + AddToLog(mpt::String::Print("Found incompatible default speed (must be between %1 and %2)", originalSpecs->speedMin, originalSpecs->speedMax)); foundHacks = true; if(autofix) m_SndFile.m_nDefaultSpeed = Clamp(m_SndFile.m_nDefaultSpeed, originalSpecs->speedMin, originalSpecs->speedMax); Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -360,7 +360,7 @@ for(std::vector<uint32>::const_iterator it = encTraits->samplerates.begin(); it != encTraits->samplerates.end(); ++it) { uint32 samplerate = *it; - int ndx = m_CbnSampleRate.AddString(mpt::String::Format("%d Hz", samplerate).c_str()); + int ndx = m_CbnSampleRate.AddString(mpt::String::Print("%1 Hz", samplerate).c_str()); m_CbnSampleRate.SetItemData(ndx, samplerate); if(samplerate == encSettings.Samplerate) { Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -472,7 +472,7 @@ { if(m_CurrentDeviceCaps.CanSampleFormat || ((SampleFormat)bits == m_Settings.sampleFormat)) { - UINT ndx = m_CbnSampleFormat.AddString(mpt::String::Format("%d Bit", bits).c_str()); + UINT ndx = m_CbnSampleFormat.AddString(mpt::String::Print("%1 Bit", bits).c_str()); m_CbnSampleFormat.SetItemData(ndx, bits); if((SampleFormat)bits == m_Settings.sampleFormat) { Modified: trunk/OpenMPT/mptrack/StreamEncoder.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoder.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/StreamEncoder.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -102,25 +102,25 @@ std::string EncoderFactoryBase::DescribeQuality(float quality) const //------------------------------------------------------------------ { - return mpt::String::Format("VBR %i%%", static_cast<int>(quality * 100.0f)); + return mpt::String::Print("VBR %1%%", static_cast<int>(quality * 100.0f)); } std::string EncoderFactoryBase::DescribeBitrateVBR(int bitrate) const //------------------------------------------------------------------- { - return mpt::String::Format("VBR %i kbit", bitrate); + return mpt::String::Print("VBR %1 kbit", bitrate); } std::string EncoderFactoryBase::DescribeBitrateABR(int bitrate) const //------------------------------------------------------------------- { - return mpt::String::Format("ABR %i kbit", bitrate); + return mpt::String::Print("ABR %1 kbit", bitrate); } std::string EncoderFactoryBase::DescribeBitrateCBR(int bitrate) const //------------------------------------------------------------------- { - return mpt::String::Format("CBR %i kbit", bitrate); + return mpt::String::Print("CBR %1 kbit", bitrate); } Modified: trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -285,7 +285,7 @@ format.Samplerate = samplerate; format.Channels = channels; format.Sampleformat = (SampleFormat)(bytes * 8); - format.Description = mpt::String::Format("%i Bit", bytes * 8); + format.Description = mpt::String::Print("%1 Bit", bytes * 8); format.Bitrate = 0; traits.formats.push_back(format); } Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -344,7 +344,7 @@ ok = false; \ if(warn) \ { \ - Reporting::Error(mpt::String::Format("Your '%s' is missing '%s'.\n\nPlease copy a newer 'libmp3lame.dll' into OpenMPT's root directory.", filename, #f ).c_str(), "OpenMPT - MP3 Export"); \ + Reporting::Error(mpt::String::PrintW(L"Your '%1' is missing '%2'.\n\nPlease copy a newer 'libmp3lame.dll' into OpenMPT's root directory.", filename.ToWide(), L ## #f ).c_str(), L"OpenMPT - MP3 Export"); \ } \ } \ } while(0) @@ -1495,7 +1495,7 @@ return "VBR -V9.999"; } else { - return mpt::String::Format("VBR -V%i", static_cast<int>((1.0f - quality) * 10.0f)); + return mpt::String::Print("VBR -V%1", static_cast<int>((1.0f - quality) * 10.0f)); } } #endif // MPT_MP3ENCODER_LAME @@ -1508,7 +1508,7 @@ #ifdef MPT_MP3ENCODER_BLADE if(m_Type == MP3EncoderBlade) { - return mpt::String::Format("%i kbit", bitrate); + return mpt::String::Print("%1 kbit", bitrate); } #endif // MPT_MP3ENCODER_BLADE return EncoderFactoryBase::DescribeBitrateABR(bitrate); Modified: trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/StreamEncoderVorbis.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -445,7 +445,7 @@ std::string VorbisEncoder::DescribeQuality(float quality) const //------------------------------------------------------------- { - return mpt::String::Format("Q%3.1f", quality * 10.0f); + return mpt::String::Print("Q%1", mpt::Format().ParsePrintf("%3.1f").ToString(quality * 10.0f)); } Modified: trunk/OpenMPT/mptrack/StreamEncoderWAV.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderWAV.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/StreamEncoderWAV.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -192,7 +192,7 @@ } else { format.Sampleformat = (SampleFormat)(bytes * 8); - format.Description = mpt::String::Format("%i Bit", bytes * 8); + format.Description = mpt::String::Print("%1 Bit", bytes * 8); } format.Bitrate = 0; traits.formats.push_back(format); Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2014-09-28 08:44:59 UTC (rev 4316) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2014-09-28 08:55:05 UTC (rev 4317) @@ -671,7 +671,7 @@ void CTuningDialog::OnBnClickedButtonImport() //------------------------------------------- { - std::string sFilter = mpt::String::Format(TEXT("Tuning files (*%s, *%s, *.scl)|*%s;*%s;*.scl|"), + std::string sFilter = mpt::String::Print("Tuning files (*%1, *%2, *.scl)|*%3;*%4;*.scl|", CTuning::s_FileExtension, CTuningCollection::s_FileExtension, CTuning::s_FileExtension, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |