diff options
author | Brad King <brad.king@kitware.com> | 2016-06-16 13:46:54 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-06-16 13:46:54 (GMT) |
commit | 0e523d0612f50373486c2c2360004bb8ce859f92 (patch) | |
tree | 6194d2f6871bda094e9eb86a0a1f29ce9644f2a5 | |
parent | 993991a07de48079233b3a04902a1f34ddfb97df (diff) | |
parent | ed5fa48d50ea0605b47598ff5b1d765548e8d638 (diff) | |
download | CMake-0e523d0612f50373486c2c2360004bb8ce859f92.zip CMake-0e523d0612f50373486c2c2360004bb8ce859f92.tar.gz CMake-0e523d0612f50373486c2c2360004bb8ce859f92.tar.bz2 |
Merge topic 'cleanup-streams'
ed5fa48d cmXMLWriter: use ifstream from KWSys
24ab29b8 Prefer istringstream and ostringstream over stringstream.
ab8b77dd Remove redundant arguments from fstream constructors
eb79fa72 Access std::ios_base with std::ios
29 files changed, 71 insertions, 73 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index b47d46e..accba08 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -567,7 +567,7 @@ cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository( void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter& xout) { - std::stringstream comment; + std::ostringstream comment; comment << "Generated by CPack " << CMake_VERSION << " IFW generator " << "for QtIFW "; if (IsVersionLess("2.0")) { diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index c44e389..405d668 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -422,7 +422,7 @@ void cmCPackIFWPackage::GeneratePackageFile() } // Write dependencies if (!compDepSet.empty()) { - std::stringstream dependencies; + std::ostringstream dependencies; std::set<DependenceStruct>::iterator it = compDepSet.begin(); dependencies << it->NameWithCompare(); ++it; diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 8777296..b5b364d 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -90,7 +90,7 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile, return false; } - std::stringstream command; + std::ostringstream command; command << QuotePath(executable); command << " -nologo"; command << " -arch " << GetArchitecture(); @@ -115,7 +115,7 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles) return false; } - std::stringstream command; + std::ostringstream command; command << QuotePath(executable); command << " -nologo"; command << " -out " << QuotePath(packageFileNames.at(0)); @@ -254,7 +254,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl() std::set<std::string> usedBaseNames; - std::stringstream objectFiles; + std::ostringstream objectFiles; for (size_t i = 0; i < this->WixSources.size(); ++i) { std::string const& sourceFilename = this->WixSources[i]; @@ -265,7 +265,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl() std::string uniqueBaseName = baseName; while (usedBaseNames.find(uniqueBaseName) != usedBaseNames.end()) { - std::stringstream tmp; + std::ostringstream tmp; tmp << baseName << ++counter; uniqueBaseName = tmp.str(); } @@ -403,7 +403,7 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source, std::string const& name, std::string const& value) { - std::stringstream tmp; + std::ostringstream tmp; tmp << name << "=\"" << value << '"'; source.AddProcessingInstruction( @@ -1019,7 +1019,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path) idPrefix = "H"; } - std::stringstream result; + std::ostringstream result; result << idPrefix << "_" << identifier; size_t ambiguityCount = ++IdAmbiguityCounter[identifier]; diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 043cdff..bbbd92d 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -127,7 +127,7 @@ void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry, std::string const& name) { if (!this->IsBooleanAttribute(name)) { - std::stringstream message; + std::ostringstream message; message << "Unknown boolean attribute '" << name << "'"; this->ReportError(entry, message.str()); } diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx index 60ecae6..de64059 100644 --- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx @@ -69,7 +69,7 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory( if (i == installRoot.size() - 1) { AddAttribute("Id", "INSTALL_ROOT"); } else { - std::stringstream tmp; + std::ostringstream tmp; tmp << "INSTALL_PREFIX_" << i; AddAttribute("Id", tmp.str()); } diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index 1341fa5..9a143cc 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -31,7 +31,7 @@ void cmWIXFilesSourceWriter::EmitShortcut(std::string const& id, std::string const& shortcutPrefix, size_t shortcutIndex) { - std::stringstream shortcutId; + std::ostringstream shortcutId; shortcutId << shortcutPrefix << id; if (shortcutIndex > 0) { diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx index b750dcf..449a70b 100644 --- a/Source/CPack/WiX/cmWIXPatchParser.cxx +++ b/Source/CPack/WiX/cmWIXPatchParser.cxx @@ -88,7 +88,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes) if (key == "Id") { if (Fragments.find(value) != Fragments.end()) { - std::stringstream tmp; + std::ostringstream tmp; tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value; ReportValidationError(tmp.str()); } diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index f4379c1..640e437 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -235,7 +235,7 @@ bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target, return false; } else { // Seek to desired size - 1 byte - fout.seekp(size - 1, std::ios_base::beg); + fout.seekp(size - 1, std::ios::beg); char byte = 0; // Write one byte to ensure file grows fout.write(&byte, 1); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 96a22d9..c991a23 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1677,7 +1677,7 @@ void cmCTestTestHandler::GenerateRegressionImages(cmXMLWriter& xml, xml.Attribute(measurementfile.match(3).c_str(), measurementfile.match(4)); xml.Attribute("encoding", "base64"); - std::stringstream ostr; + std::ostringstream ostr; for (size_t cc = 0; cc < rlen; cc++) { ostr << encoded_buffer[cc]; if (cc % 60 == 0 && cc) { diff --git a/Source/cmCLocaleEnvironmentScope.cxx b/Source/cmCLocaleEnvironmentScope.cxx index ee9acde..a19dbae 100644 --- a/Source/cmCLocaleEnvironmentScope.cxx +++ b/Source/cmCLocaleEnvironmentScope.cxx @@ -45,7 +45,7 @@ void cmCLocaleEnvironmentScope::SetEnv(std::string const& key, if (value.empty()) { cmSystemTools::UnsetEnv(key.c_str()); } else { - std::stringstream tmp; + std::ostringstream tmp; tmp << key << "=" << value; cmSystemTools::PutEnv(tmp.str()); } @@ -55,7 +55,7 @@ cmCLocaleEnvironmentScope::~cmCLocaleEnvironmentScope() { for (backup_map_t::const_iterator i = this->EnvironmentBackup.begin(); i != this->EnvironmentBackup.end(); ++i) { - std::stringstream tmp; + std::ostringstream tmp; tmp << i->first << "=" << i->second; cmSystemTools::PutEnv(tmp.str()); } diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx index fbec6fd..fdbd5e7 100644 --- a/Source/cmCMakeHostSystemInformationCommand.cxx +++ b/Source/cmCMakeHostSystemInformationCommand.cxx @@ -84,7 +84,7 @@ bool cmCMakeHostSystemInformationCommand::GetValue( std::string cmCMakeHostSystemInformationCommand::ValueToString( size_t value) const { - std::stringstream tmp; + std::ostringstream tmp; tmp << value; return tmp.str(); } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index a20fb98..bbda688 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -633,8 +633,8 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary); cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary); #else - cmsys::ifstream finModFile(modFile, std::ios::in); - cmsys::ifstream finStampFile(stampFile, std::ios::in); + cmsys::ifstream finModFile(modFile); + cmsys::ifstream finStampFile(stampFile); #endif if (!finModFile || !finStampFile) { // At least one of the files does not exist. The modules differ. diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 68a8488..413dacd 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -140,7 +140,7 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) cmsys::ofstream* fout = 0; std::ostream* s = &os; if (!i->Filename.empty()) { - fout = new cmsys::ofstream(i->Filename.c_str(), std::ios::out); + fout = new cmsys::ofstream(i->Filename.c_str()); if (fout) { s = fout; } else { diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index bc217af..f964b97 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -311,7 +311,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "false"); // set project specific environment - std::stringstream environment; + std::ostringstream environment; environment << "VERBOSE=1|CMAKE_NO_VERBOSE=1|"; // verbose Makefile output // set vsvars32.bat environment available at CMake time, // but not necessarily when eclipse is open @@ -341,7 +341,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() AppendDictionary(xml, "org.eclipse.cdt.make.core.autoBuildTarget", "all"); // set error parsers - std::stringstream errorOutputParser; + std::ostringstream errorOutputParser; if (compilerId == "MSVC") { errorOutputParser << "org.eclipse.cdt.core.VCErrorParser;"; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4e72f36..6abc238 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -257,7 +257,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args) fileName.c_str(), std::ios::in | (hexOutputArg.IsEnabled() ? std::ios::binary : std::ios::in)); #else - cmsys::ifstream file(fileName.c_str(), std::ios::in); + cmsys::ifstream file(fileName.c_str()); #endif if (!file) { @@ -526,7 +526,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args) #if defined(_WIN32) || defined(__CYGWIN__) cmsys::ifstream fin(fileName.c_str(), std::ios::in | std::ios::binary); #else - cmsys::ifstream fin(fileName.c_str(), std::ios::in); + cmsys::ifstream fin(fileName.c_str()); #endif if (!fin) { std::ostringstream e; diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index dee174b..c35a1bc 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -56,7 +56,7 @@ cmGeneratedFileStream& cmGeneratedFileStream::Open(const char* name, this->Stream::open(this->TempName.c_str(), std::ios::out | std::ios::binary); } else { - this->Stream::open(this->TempName.c_str(), std::ios::out); + this->Stream::open(this->TempName.c_str()); } // Check if the file opened. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index de02395..5f4b074 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1527,7 +1527,7 @@ public: if (item.find("::") != std::string::npos) { bool noMessage = false; cmake::MessageType messageType = cmake::FATAL_ERROR; - std::stringstream e; + std::ostringstream e; switch (this->Target->GetLocalGenerator()->GetPolicyStatus( cmPolicies::CMP0028)) { case cmPolicies::WARN: { @@ -1628,7 +1628,7 @@ public: if (this->Preferred.empty()) { return ""; } else if (this->Preferred.size() > 1) { - std::stringstream e; + std::ostringstream e; e << "Target " << this->Target->GetName() << " contains multiple languages with the highest linker preference" << " (" << this->Preference << "):\n"; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index aef3f44..536c5d2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2571,7 +2571,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile, #if defined(_WIN32) || defined(__CYGWIN__) cmsys::ifstream fin(pfile.c_str(), std::ios::in | std::ios::binary); #else - cmsys::ifstream fin(pfile.c_str(), std::ios::in); + cmsys::ifstream fin(pfile.c_str()); #endif if (!fin) { return; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index f74e835..3aec630 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -513,8 +513,8 @@ void cmGlobalNinjaGenerator::Generate() this->WriteBuiltinTargets(*this->BuildFileStream); if (cmSystemTools::GetErrorOccuredFlag()) { - this->RulesFileStream->setstate(std::ios_base::failbit); - this->BuildFileStream->setstate(std::ios_base::failbit); + this->RulesFileStream->setstate(std::ios::failbit); + this->BuildFileStream->setstate(std::ios::failbit); } this->CloseCompileCommandsStream(); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index e68bac2..d56bb05 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -623,7 +623,7 @@ void cmInstallTargetGenerator::AddChrpathPatchRule( std::string darwin_major_version_s = mf->GetSafeDefinition("DARWIN_MAJOR_VERSION"); - std::stringstream ss(darwin_major_version_s); + std::istringstream ss(darwin_major_version_s); int darwin_major_version; ss >> darwin_major_version; if (!ss.fail() && darwin_major_version <= 9 && diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 75d57b5..5712070 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3459,7 +3459,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, } } else { std::string newLineCharacters; - std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc; + std::ios::openmode omode = std::ios::out | std::ios::trunc; if (newLine.IsValid()) { newLineCharacters = newLine.GetCharacters(); omode |= std::ios::binary; diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index dd19760..98851d6 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -464,7 +464,7 @@ static std::string cmQtAutoGeneratorsStripCR(std::string const& line) static std::string ReadAll(const std::string& filename) { cmsys::ifstream file(filename.c_str()); - std::stringstream stream; + std::ostringstream stream; stream << file.rdbuf(); file.close(); return stream.str(); @@ -508,7 +508,7 @@ static std::string ListQt5RccInputs(cmSourceFile* sf, bool result = cmSystemTools::RunSingleCommand( command, &rccStdOut, &rccStdErr, &retVal, 0, cmSystemTools::OUTPUT_NONE); if (!result || retVal) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath() << " failed:\n" << rccStdOut << "\n" @@ -538,7 +538,7 @@ static std::string ListQt5RccInputs(cmSourceFile* sf, std::string::size_type pos = eline.find(searchString); if (pos == std::string::npos) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: Rcc lists unparsable output " << eline << std::endl; std::cerr << err.str(); diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index dc44f3e..6a6d72f 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -432,7 +432,7 @@ void cmQtAutoGenerators::Init() static std::string ReadAll(const std::string& filename) { cmsys::ifstream file(filename.c_str()); - std::stringstream stream; + std::ostringstream stream; stream << file.rdbuf(); file.close(); return stream.str(); @@ -477,7 +477,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) skipUic ? skippedUis : includedUis; const std::string& absFilename = *it; if (this->Verbose) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: Checking " << absFilename << std::endl; this->LogInfo(err.str()); } @@ -499,7 +499,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) uicSkipped.end()) { const std::string& absFilename = *it; if (this->Verbose) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: Checking " << absFilename << std::endl; this->LogInfo(err.str()); } @@ -527,19 +527,19 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) } if (this->RunMocFailed) { - std::stringstream err; + std::ostringstream err; err << "moc failed..." << std::endl; this->LogError(err.str()); return false; } if (this->RunUicFailed) { - std::stringstream err; + std::ostringstream err; err << "uic failed..." << std::endl; this->LogError(err.str()); return false; } if (this->RunRccFailed) { - std::stringstream err; + std::ostringstream err; err << "rcc failed..." << std::endl; this->LogError(err.str()); return false; @@ -560,7 +560,7 @@ void cmQtAutoGenerators::ParseCppFile( const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; this->LogError(err.str()); @@ -620,7 +620,7 @@ void cmQtAutoGenerators::ParseCppFile( ownMocHeaderFile = headerToMoc; } } else { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename << '{' @@ -644,7 +644,7 @@ void cmQtAutoGenerators::ParseCppFile( // this is for KDE4 compatibility: fileToMoc = headerToMoc; if (!requiresMoc && basename == scannedFileBasename) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": The file " "includes the moc file \"" @@ -656,7 +656,7 @@ void cmQtAutoGenerators::ParseCppFile( << std::endl; this->LogError(err.str()); } else { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": The file " "includes the moc file \"" @@ -670,7 +670,7 @@ void cmQtAutoGenerators::ParseCppFile( this->LogError(err.str()); } } else { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " "includes the moc file \"" @@ -699,7 +699,7 @@ void cmQtAutoGenerators::ParseCppFile( if (!dotMocIncluded && requiresMoc) { if (mocUnderscoreIncluded) { // this is for KDE4 compatibility: - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": The file " << "contains a " << macroName << " macro, but does not " "include " @@ -717,7 +717,7 @@ void cmQtAutoGenerators::ParseCppFile( includedMocs.erase(ownMocHeaderFile); } else { // otherwise always error out since it will not compile: - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " << "contains a " << macroName << " macro, but does not " "include " @@ -742,7 +742,7 @@ void cmQtAutoGenerators::StrictParseCppFile( const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; this->LogError(err.str()); @@ -791,7 +791,7 @@ void cmQtAutoGenerators::StrictParseCppFile( if (!headerToMoc.empty()) { includedMocs[headerToMoc] = currentMoc; } else { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << " The file " << "includes the moc file \"" << currentMoc << "\", " << "but could not find header \"" << basename << '{' @@ -807,7 +807,7 @@ void cmQtAutoGenerators::StrictParseCppFile( } } else { if (basename != scannedFileBasename) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " "includes the moc file \"" @@ -835,7 +835,7 @@ void cmQtAutoGenerators::StrictParseCppFile( std::string macroName; if (!dotMocIncluded && requiresMocing(contentsString, macroName)) { // otherwise always error out since it will not compile: - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " << absFilename << ": The file " << "contains a " << macroName << " macro, but does not include " << "\"" << scannedFileBasename << ".moc\" !\n" @@ -854,7 +854,7 @@ void cmQtAutoGenerators::ParseForUic( } const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: warning: " << absFilename << ": file is empty\n" << std::endl; this->LogError(err.str()); @@ -942,7 +942,7 @@ void cmQtAutoGenerators::ParseHeaders( if (!this->MocExecutable.empty() && includedMocs.find(headerName) == includedMocs.end()) { if (this->Verbose) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: Checking " << headerName << std::endl; this->LogInfo(err.str()); } @@ -972,7 +972,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( std::map<std::string, std::string> mergedMocs(includedMocs); mergedMocs.insert(notIncludedMocs.begin(), notIncludedMocs.end()); if (this->NameCollisionTest(mergedMocs, collisions)) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: " "The same moc file will be generated " "from different sources." @@ -1013,7 +1013,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( // compose _automoc.cpp content std::string automocSource; { - std::stringstream outStream; + std::ostringstream outStream; outStream << "/* This file is autogenerated, do not edit*/\n"; if (notIncludedMocs.empty()) { outStream << "enum some_compilers { need_more_than_nothing };\n"; @@ -1035,7 +1035,7 @@ bool cmQtAutoGenerators::GenerateMocFiles( if (oldContents == automocSource) { // nothing changed: don't touch the _automoc.cpp file if (this->Verbose) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: " << this->OutMocCppFilenameRel << " still up to date" << std::endl; this->LogInfo(err.str()); @@ -1106,7 +1106,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile, bool result = cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); if (!result || retVal) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: process for " << mocFilePath << " failed:\n" << output << std::endl; this->LogError(err.str()); @@ -1147,7 +1147,7 @@ bool cmQtAutoGenerators::GenerateUiFiles( { std::multimap<std::string, std::string> collisions; if (this->NameCollisionTest(testMap, collisions)) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: The same ui_NAME.h file will be generated " "from different sources." << std::endl @@ -1223,7 +1223,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName, bool result = cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); if (!result || retVal) { - std::stringstream err; + std::ostringstream err; err << "AUTOUIC: error: process for " << uiOutputFile << " needed by\n \"" << realName << "\"\nfailed:\n" << output << std::endl; @@ -1275,7 +1275,7 @@ bool cmQtAutoGenerators::GenerateQrcFiles() { std::multimap<std::string, std::string> collisions; if (this->NameCollisionTest(qrcGenMap, collisions)) { - std::stringstream err; + std::ostringstream err; err << "AUTOGEN: error: The same qrc_NAME.cpp file" " will be generated from different sources." << std::endl @@ -1344,7 +1344,7 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile, bool result = cmSystemTools::RunSingleCommand(command, &output, &output, &retVal); if (!result || retVal) { - std::stringstream err; + std::ostringstream err; err << "AUTORCC: error: process for " << qrcOutputFile << " failed:\n" << output << std::endl; this->LogError(err.str()); @@ -1435,7 +1435,7 @@ void cmQtAutoGenerators::NameCollisionLog( { typedef std::multimap<std::string, std::string>::const_iterator Iter; - std::stringstream err; + std::ostringstream err; // Add message err << message; // Append collision list @@ -1457,7 +1457,7 @@ void cmQtAutoGenerators::LogError(const std::string& message) void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command) { - std::stringstream sbuf; + std::ostringstream sbuf; for (std::vector<std::string>::const_iterator cmdIt = command.begin(); cmdIt != command.end(); ++cmdIt) { if (cmdIt != command.begin()) { diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index c624d0f..2a70ed0 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -152,7 +152,7 @@ std::string cmTimestamp::AddTimestampComponent(char flag, return std::string(); } - std::stringstream ss; + std::ostringstream ss; ss << static_cast<long int>(difftime(timeT, unixEpoch)); return ss.str(); } diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx index 98c2680..e2dce93d 100644 --- a/Source/cmXMLWriter.cxx +++ b/Source/cmXMLWriter.cxx @@ -14,7 +14,7 @@ #include "cmXMLSafe.h" #include <cassert> -#include <fstream> +#include <cmsys/FStream.hxx> cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level) : Output(output) @@ -107,7 +107,7 @@ void cmXMLWriter::ProcessingInstruction(const char* target, const char* data) void cmXMLWriter::FragmentFile(const char* fname) { this->CloseStartElement(); - std::ifstream fin(fname, std::ios::in | std::ios::binary); + cmsys::ifstream fin(fname, std::ios::in | std::ios::binary); this->Output << fin.rdbuf(); } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index e404fa3..db0072a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2094,7 +2094,7 @@ static bool cmakeCheckStampFile(const char* stampName) #if defined(_WIN32) || defined(__CYGWIN__) cmsys::ifstream fin(stampDepends.c_str(), std::ios::in | std::ios::binary); #else - cmsys::ifstream fin(stampDepends.c_str(), std::ios::in); + cmsys::ifstream fin(stampDepends.c_str()); #endif if (!fin) { // The stamp dependencies file cannot be read. Just assume the diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx index 8b0cede..44f71f1 100644 --- a/Source/cmcldeps.cxx +++ b/Source/cmcldeps.cxx @@ -213,7 +213,7 @@ static int process(const std::string& srcfilename, const std::string& dfile, dir.c_str(), cmSystemTools::OUTPUT_NONE); // process the include directives and output everything else - std::stringstream ss(output); + std::istringstream ss(output); std::string line; std::vector<std::string> includes; bool isFirstLine = true; // cl prints always first the source filename diff --git a/Tests/AliasTarget/commandgenerator.cpp b/Tests/AliasTarget/commandgenerator.cpp index aaab014..c4d80a1 100644 --- a/Tests/AliasTarget/commandgenerator.cpp +++ b/Tests/AliasTarget/commandgenerator.cpp @@ -5,8 +5,7 @@ int main(int argc, char** argv) { - std::fstream fout; - fout.open("commandoutput.h", std::ios::out); + std::ofstream fout("commandoutput.h"); if (!fout) return 1; fout << "#define COMMANDOUTPUT_DEFINE\n"; diff --git a/Tests/AliasTarget/targetgenerator.cpp b/Tests/AliasTarget/targetgenerator.cpp index b3e6ee2..4de4792 100644 --- a/Tests/AliasTarget/targetgenerator.cpp +++ b/Tests/AliasTarget/targetgenerator.cpp @@ -3,8 +3,7 @@ int main(int argc, char** argv) { - std::fstream fout; - fout.open("targetoutput.h", std::ios::out); + std::ofstream fout("targetoutput.h"); if (!fout) return 1; fout << "#define TARGETOUTPUT_DEFINE\n"; |