From: <man...@us...> - 2014-10-06 15:18:54
|
Revision: 4394 http://sourceforge.net/p/modplug/code/4394 Author: manxorist Date: 2014-10-06 15:18:40 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Ref] Remove explicit iostream formatting in StreamEncoderFLAC and StreamEncoderMP3. Modified Paths: -------------- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp Modified: trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2014-10-06 13:20:50 UTC (rev 4393) +++ trunk/OpenMPT/mptrack/StreamEncoderFLAC.cpp 2014-10-06 15:18:40 UTC (rev 4394) @@ -16,9 +16,6 @@ #include "Mptrack.h" #include "TrackerSettings.h" -#include <locale> -#include <sstream> - #define FLAC__NO_DLL #include <flac/include/FLAC/metadata.h> #include <flac/include/FLAC/format.h> @@ -263,13 +260,11 @@ traits.fileDescription = "FLAC"; traits.encoderSettingsName = "FLAC"; traits.encoderName = "libFLAC"; - std::ostringstream description; - description.imbue(std::locale::classic()); - description << "Free Lossless Audio Codec" << std::endl; - description << "Vendor: " << FLAC__VENDOR_STRING << std::endl; - description << "Version: " << FLAC__VERSION_STRING << std::endl; - description << "API: " << FLAC_API_VERSION_CURRENT << "." << FLAC_API_VERSION_REVISION << "." << FLAC_API_VERSION_AGE << std::endl; - traits.description = description.str(); + traits.description = ""; + traits.description += mpt::String::Print<std::string>("Free Lossless Audio Codec\n"); + traits.description += mpt::String::Print<std::string>("Vendor: %1\n", FLAC__VENDOR_STRING); + traits.description += mpt::String::Print<std::string>("Version: %1\n", FLAC__VERSION_STRING); + traits.description += mpt::String::Print<std::string>("API: %1.%2.%3\n", FLAC_API_VERSION_CURRENT, FLAC_API_VERSION_REVISION, FLAC_API_VERSION_AGE); traits.canTags = true; traits.maxChannels = 4; traits.samplerates = TrackerSettings::Instance().GetSampleRates(); Modified: trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp =================================================================== --- trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-10-06 13:20:50 UTC (rev 4393) +++ trunk/OpenMPT/mptrack/StreamEncoderMP3.cpp 2014-10-06 15:18:40 UTC (rev 4394) @@ -22,9 +22,6 @@ #include "../common/StringFixer.h" #include <deque> -#include <iomanip> -#include <locale> -#include <sstream> // For ACM debugging purposes #define ACMLOG(x, ...) @@ -697,18 +694,18 @@ traits.fileDescription = "MPEG-1 Layer 3"; traits.encoderSettingsName = "MP3Blade"; traits.encoderName = lame ? "Lame_enc.dll" : "BladeEnc.dll"; - std::ostringstream description; - description.imbue(std::locale::classic()); BE_VERSION ver; MemsetZero(ver); beVersion(&ver); - description << "DLL version: " << (int)ver.byDLLMajorVersion << "." << (int)ver.byDLLMinorVersion << std::endl; - description << "Engine version: " << (int)ver.byMajorVersion << "." << (int)ver.byMinorVersion << " "; - description << std::setfill('0') << std::setw(4) << (int)ver.wYear << "-" << std::setfill('0') << std::setw(2) << (int)ver.byMonth << "-" << std::setfill('0') << std::setw(2) << (int)ver.byDay << std::endl; + traits.description = ""; + traits.description += mpt::String::Print<std::string>("DLL version: %1.%2\n", (int)ver.byDLLMajorVersion, (int)ver.byDLLMinorVersion); + traits.description += mpt::String::Print<std::string>("Engine version: %1.%2 %3-%4-%5\n" + , (int)ver.byMajorVersion, (int)ver.byMinorVersion + , mpt::fmt::dec0<4>((int)ver.wYear), mpt::fmt::dec0<2>((int)ver.byMonth), mpt::fmt::dec0<2>((int)ver.byDay) + ); std::string url; mpt::String::Copy(url, ver.zHomepage); - description << "URL: " << url << std::endl; - traits.description = description.str(); + traits.description += mpt::String::Print<std::string>("URL: \n", url); traits.canTags = true; traits.maxChannels = 2; traits.samplerates = std::vector<uint32>(mpeg1layer3_samplerates, mpeg1layer3_samplerates + CountOf(mpeg1layer3_samplerates));; @@ -897,13 +894,13 @@ return reinterpret_cast<AcmDynBind*>(inst)->AcmFormatEnumCB(driver, pafd, fdwSupport); } template<size_t size> - static void AppendField(std::ostream &s, const std::string &field, const CHAR(&val)[size]) + static void AppendField(std::string &s, const std::string &field, const CHAR(&val)[size]) { std::string tmp; mpt::String::Copy(tmp, val); if(!tmp.empty()) { - s << field << ": " << tmp << std::endl; + s += field + std::string(": ") + tmp + std::string("\n"); } } BOOL AcmFormatEnumCB(HACMDRIVERID driver, LPACMFORMATDETAILS pafd, DWORD fdwSupport) @@ -973,8 +970,7 @@ std::string driverNameLong; std::string driverNameShort; std::string driverNameCombined; - std::ostringstream driverDescription; - driverDescription.imbue(std::locale::classic()); + std::string driverDescription; if(add.szLongName[0]) { @@ -1047,9 +1043,9 @@ formats_waveformats.push_back(wfex); } - if(!driverDescription.str().empty()) + if(!driverDescription.empty()) { - drivers.insert(driverDescription.str()); + drivers.insert(driverDescription); } found_codec = true; @@ -1125,18 +1121,15 @@ traits.fileExtension = "mp3"; traits.fileShortDescription = "MP3 (ACM)"; traits.fileDescription = "MPEG Layer 3"; - std::ostringstream name; - name.imbue(std::locale::classic()); DWORD ver = acmGetVersion(); if(ver & 0xffff) { - name << "Microsoft Windows ACM " << ((ver>>24)&0xff) << "." << ((ver>>16)&0xff) << "." << ((ver>>0)&0xffff); + traits.encoderName = mpt::String::Print<std::string>("%1 %2.%3.%4", "Microsoft Windows ACM", mpt::fmt::hex0<2>((ver>>24)&0xff), mpt::fmt::hex0<2>((ver>>16)&0xff), mpt::fmt::hex0<4>((ver>>0)&0xffff)); } else { - name << "Microsoft Windows ACM " << ((ver>>24)&0xff) << "." << ((ver>>16)&0xff); + traits.encoderName = mpt::String::Print<std::string>("%1 %2.%3", "Microsoft Windows ACM", mpt::fmt::hex0<2>((ver>>24)&0xff), mpt::fmt::hex0<2>((ver>>16)&0xff)); } traits.encoderSettingsName = "MP3ACM"; - traits.encoderName = name.str(); for(std::set<std::string>::const_iterator i = drivers.begin(); i != drivers.end(); ++i) { traits.description += (*i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |