diff options
author | Brad King <brad.king@kitware.com> | 2002-10-10 14:43:59 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2002-10-10 14:43:59 (GMT) |
commit | 281f7519e1707bd30ce8f9368b7515396f713af9 (patch) | |
tree | 560dd62bf62c26753d47b870c405677bb30eceb0 /Source | |
parent | 65cc289047fc2a4b444838c690d9bd45eca04f7e (diff) | |
download | CMake-281f7519e1707bd30ce8f9368b7515396f713af9.zip CMake-281f7519e1707bd30ce8f9368b7515396f713af9.tar.gz CMake-281f7519e1707bd30ce8f9368b7515396f713af9.tar.bz2 |
ENH: Renamed cmStringStream to cmOStringStream and added cmIStringStream. Removed cmInputStringStream.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmCMakeMinimumRequired.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalBorlandMakefileGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalNMakeMakefileGenerator.cxx | 22 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator.cxx | 128 | ||||
-rw-r--r-- | Source/cmStandardIncludes.h | 73 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 6 | ||||
-rw-r--r-- | Source/cmVTKMakeInstantiatorCommand.cxx | 2 | ||||
-rw-r--r-- | Source/cmake.cxx | 6 | ||||
-rw-r--r-- | Source/ctest.cxx | 2 |
9 files changed, 128 insertions, 117 deletions
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx index 4b7c9f5..771dd00 100644 --- a/Source/cmCMakeMinimumRequired.cxx +++ b/Source/cmCMakeMinimumRequired.cxx @@ -35,7 +35,7 @@ bool cmCMakeMinimumRequired::InitialPass(std::vector<std::string> const& args) sscanf(args[1].c_str(), "%f", &reqVersion); if(reqVersion > version) { - cmStringStream str; + cmOStringStream str; str << "WARNING: This project requires version: " << args[1].c_str() << " of cmake.\n" << "You are running version: " << version; cmSystemTools::Message(str.str().c_str()); diff --git a/Source/cmLocalBorlandMakefileGenerator.cxx b/Source/cmLocalBorlandMakefileGenerator.cxx index 16e311c..b7bb097 100644 --- a/Source/cmLocalBorlandMakefileGenerator.cxx +++ b/Source/cmLocalBorlandMakefileGenerator.cxx @@ -221,7 +221,7 @@ void cmLocalBorlandMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout command += "-e"; command += target; command += " "; - cmStringStream linklibs; + cmOStringStream linklibs; this->OutputLinkLibraries(linklibs, name, t); // then the linker options -L and libraries (any other order will fail!) command += linklibs.str(); @@ -321,7 +321,7 @@ void cmLocalBorlandMakefileGenerator::OutputExecutableRule(std::ostream& fout, { command += " -tWC "; } - cmStringStream linklibs; + cmOStringStream linklibs; this->OutputLinkLibraries(linklibs, 0, t); command += linklibs.str(); command += " $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ")"; diff --git a/Source/cmLocalNMakeMakefileGenerator.cxx b/Source/cmLocalNMakeMakefileGenerator.cxx index 4f3cee6..2bed0ad 100644 --- a/Source/cmLocalNMakeMakefileGenerator.cxx +++ b/Source/cmLocalNMakeMakefileGenerator.cxx @@ -84,7 +84,7 @@ std::string cmLocalNMakeMakefileGenerator::ShortPathCommand(const char* command) cmRegularExpression removeIntDir("(.*)(/|\\\\)\\$\\(IntDir\\)(.*)"); if(removeIntDir.find(c)) { - c = removeIntDir.match(1) + removeIntDir.match(3); + c = removeIntDir.match(1) + removeIntDir.match(3); } std::string unixPath = c; // since the command may already be a windows path, convert it @@ -407,7 +407,7 @@ void cmLocalNMakeMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout, command += " $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; - cmStringStream linklibs; + cmOStringStream linklibs; this->OutputLinkLibraries(linklibs, name, t); command += linklibs.str(); @@ -528,7 +528,7 @@ void cmLocalNMakeMakefileGenerator::OutputExecutableRule(std::ostream& fout, command += " /subsystem:windows "; } - cmStringStream linklibs; + cmOStringStream linklibs; this->OutputLinkLibraries(linklibs, 0, t); command += linklibs.str(); @@ -614,16 +614,16 @@ void cmLocalNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout, // if it ends in .lib, then it is a full path and should // be escaped, and does not need .lib added if(reg.find(lib->first)) - { - librariesLinked += ShortPath(lib->first.c_str()); - librariesLinked += " "; - } + { + librariesLinked += ShortPath(lib->first.c_str()); + librariesLinked += " "; + } else - { + { librariesLinked += m_LibraryLinkOption; - librariesLinked += lib->first; - librariesLinked += m_StaticLibraryExtension + " "; - } + librariesLinked += lib->first; + librariesLinked += m_StaticLibraryExtension + " "; + } } } linkLibs += librariesLinked; diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index 89fdae0..80bd21a 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -347,7 +347,7 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) l != tgts.end(); l++) { if (l->second.GetType() == cmTarget::UTILITY && - l->second.IsInAll()) + l->second.IsInAll()) { fout << " \\\n" << l->first.c_str(); } @@ -545,14 +545,14 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, { librariesLinked += "-l"; file = libname.match(1); - librariesLinked += file; + librariesLinked += file; librariesLinked += " "; } else if(libname_noprefix.find(file)) { librariesLinked += "-l"; file = libname_noprefix.match(1); - librariesLinked += file; + librariesLinked += file; librariesLinked += " "; } } @@ -652,7 +652,7 @@ void cmLocalUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout, libName = cmSystemTools::ConvertToOutputPath(libName.c_str()); command2 += libName + " \\\n"; command2 += "\t $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; - cmStringStream linklibs; + cmOStringStream linklibs; this->OutputLinkLibraries(linklibs, name, t); command2 += linklibs.str(); std::string customCommands = this->CreateTargetRules(t, name); @@ -694,7 +694,7 @@ void cmLocalUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout, libName = cmSystemTools::ConvertToOutputPath(libName.c_str()); command2 += libName + " \\\n"; command2 += "\t $(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; - cmStringStream linklibs; + cmOStringStream linklibs; this->OutputLinkLibraries(linklibs, std::string(name).c_str(), t); command2 += linklibs.str(); std::string customCommands = this->CreateTargetRules(t, name); @@ -771,7 +771,7 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout, "$(CMAKE_C_COMPILER) $(CMAKE_C_SHLIB_LINK_FLAGS) $(CMAKE_C_FLAGS) "; } command += "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") "; - cmStringStream linklibs; + cmOStringStream linklibs; this->OutputLinkLibraries(linklibs, 0, t); command += linklibs.str(); std::string outputFile = m_ExecutableOutputPath + name; @@ -859,7 +859,7 @@ void cmLocalUnixMakefileGenerator::OutputTargets(std::ostream& fout) // This is handled by the OutputInstallRules method case cmTarget::INSTALL_PROGRAMS: // This is handled by the OutputInstallRules method - break; + break; } } } @@ -1414,14 +1414,14 @@ void cmLocalUnixMakefileGenerator::OutputCustomRules(std::ostream& fout) // the custom command, as the command will be fired when the other target // is built. if ( cr->GetSourceName().compare(tgt->first) !=0) - { - cmSourceGroup& sourceGroup = - m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(), - sourceGroups); - cmCustomCommand cc(*cr); - cc.ExpandVariables(*m_Makefile); - sourceGroup.AddCustomCommand(cc); - } + { + cmSourceGroup& sourceGroup = + m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(), + sourceGroups); + cmCustomCommand cc(*cr); + cc.ExpandVariables(*m_Makefile); + sourceGroup.AddCustomCommand(cc); + } } } @@ -1622,53 +1622,53 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) { // first make the directories for each target fout << "\t@if [ ! -d $(DESTDIR)" << prefix << l->second.GetInstallPath() << - " ] ; then \\\n"; + " ] ; then \\\n"; fout << "\t echo \"Making directory $(DESTDIR)" << prefix - << l->second.GetInstallPath() << " \"; \\\n"; + << l->second.GetInstallPath() << " \"; \\\n"; fout << "\t mkdir -p $(DESTDIR)" << prefix << l->second.GetInstallPath() - << "; \\\n"; + << "; \\\n"; fout << "\t chmod 755 $(DESTDIR)" << prefix << l->second.GetInstallPath() - << "; \\\n"; + << "; \\\n"; fout << "\t else true; \\\n"; fout << "\t fi\n"; // now install the target switch (l->second.GetType()) - { - case cmTarget::STATIC_LIBRARY: - fout << "\t$(INSTALL_DATA) " << m_LibraryOutputPath << "lib" + { + case cmTarget::STATIC_LIBRARY: + fout << "\t$(INSTALL_DATA) " << m_LibraryOutputPath << "lib" << l->first; fout << ".a"; - fout << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; - break; - case cmTarget::SHARED_LIBRARY: - fout << "\t$(INSTALL_DATA) " << m_LibraryOutputPath << "lib" + fout << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; + break; + case cmTarget::SHARED_LIBRARY: + fout << "\t$(INSTALL_DATA) " << m_LibraryOutputPath << "lib" << l->first; fout << m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX"); - fout << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; - break; - case cmTarget::MODULE_LIBRARY: - fout << "\t$(INSTALL_DATA) " << m_LibraryOutputPath << "lib" + fout << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; + break; + case cmTarget::MODULE_LIBRARY: + fout << "\t$(INSTALL_DATA) " << m_LibraryOutputPath << "lib" << l->first; fout << m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX"); - fout << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; - break; - case cmTarget::WIN32_EXECUTABLE: - case cmTarget::EXECUTABLE: + fout << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; + break; + case cmTarget::WIN32_EXECUTABLE: + case cmTarget::EXECUTABLE: fout << "\t$(INSTALL_PROGRAM) " << m_ExecutableOutputPath << l->first << cmSystemTools::GetExecutableExtension() - << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; - break; - case cmTarget::INSTALL_FILES: - { + << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; + break; + case cmTarget::INSTALL_FILES: + { std::string sourcePath = m_Makefile->GetCurrentDirectory(); std::string binaryPath = m_Makefile->GetCurrentOutputDirectory(); sourcePath += "/"; binaryPath += "/"; - const std::vector<std::string> &sf = l->second.GetSourceLists(); - std::vector<std::string>::const_iterator i; - for (i = sf.begin(); i != sf.end(); ++i) - { + const std::vector<std::string> &sf = l->second.GetSourceLists(); + std::vector<std::string>::const_iterator i; + for (i = sf.begin(); i != sf.end(); ++i) + { std::string f = *i; if(f.substr(0, sourcePath.length()) == sourcePath) { @@ -1678,7 +1678,7 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) { f = f.substr(binaryPath.length()); } - fout << "\t@echo \"Installing " << f.c_str() << " \"\n"; + fout << "\t@echo \"Installing " << f.c_str() << " \"\n"; // avoid using install-sh to install install-sh // does not work on windows.... if(*i == "install-sh") @@ -1689,21 +1689,21 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) { fout << "\t @$(INSTALL_DATA) "; } - fout << *i - << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; - } - } - break; - case cmTarget::INSTALL_PROGRAMS: - { + fout << *i + << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; + } + } + break; + case cmTarget::INSTALL_PROGRAMS: + { std::string sourcePath = m_Makefile->GetCurrentDirectory(); std::string binaryPath = m_Makefile->GetCurrentOutputDirectory(); sourcePath += "/"; binaryPath += "/"; - const std::vector<std::string> &sf = l->second.GetSourceLists(); - std::vector<std::string>::const_iterator i; - for (i = sf.begin(); i != sf.end(); ++i) - { + const std::vector<std::string> &sf = l->second.GetSourceLists(); + std::vector<std::string>::const_iterator i; + for (i = sf.begin(); i != sf.end(); ++i) + { std::string f = *i; if(f.substr(0, sourcePath.length()) == sourcePath) { @@ -1713,7 +1713,7 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) { f = f.substr(binaryPath.length()); } - fout << "\t@echo \"Installing " << f.c_str() << " \"\n"; + fout << "\t@echo \"Installing " << f.c_str() << " \"\n"; // avoid using install-sh to install install-sh // does not work on windows.... if(*i == "install-sh") @@ -1724,15 +1724,15 @@ void cmLocalUnixMakefileGenerator::OutputInstallRules(std::ostream& fout) { fout << "\t @$(INSTALL_PROGRAM) "; } - fout << *i - << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; - } - } - break; + fout << *i + << " $(DESTDIR)" << prefix << l->second.GetInstallPath() << "\n"; + } + } + break; case cmTarget::UTILITY: default: break; - } + } } } } @@ -1941,7 +1941,7 @@ void cmLocalUnixMakefileGenerator::OutputSourceObjectBuildRules(std::ostream& fo target != targets.end(); ++target) { bool shared = ((target->second.GetType() == cmTarget::SHARED_LIBRARY) || - (target->second.GetType() == cmTarget::MODULE_LIBRARY)); + (target->second.GetType() == cmTarget::MODULE_LIBRARY)); std::string exportsDef = ""; if(shared) { @@ -2060,14 +2060,14 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout, // for nmake and borland, the echo should not be quoted if(strcmp(m_GlobalGenerator->GetName(), "Unix Makefiles") == 0) { - cmSystemTools::ReplaceString(echostring, "\\\n", " "); + cmSystemTools::ReplaceString(echostring, "\\\n", " "); cmSystemTools::ReplaceString(echostring, " \t", " "); cmSystemTools::ReplaceString(echostring, "\n\t", "\"\n\techo \""); fout << "\techo \"" << echostring.c_str() << "\"\n"; } else { - cmSystemTools::ReplaceString(echostring, "\n\t", "\n\techo "); + cmSystemTools::ReplaceString(echostring, "\n\t", "\n\techo "); fout << "\techo " << echostring.c_str() << "\n"; } } diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index 20c4b0e..d72bb9c 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -162,65 +162,76 @@ struct cmStdString : public std::string StdString(s, pos, n) {} }; -// Define cmStringStream wrapper to hide differences between -// std::stringstream and the old strstream. +// Define cmOStringStream and cmIStringStream wrappers to hide +// differences between std::stringstream and the old strstream. #if !defined(CMAKE_NO_ANSI_STRING_STREAM) -class cmStringStream: public std::ostringstream +class cmOStringStream: public std::ostringstream { public: - cmStringStream() {} + cmOStringStream() {} private: - cmStringStream(const cmStringStream&); - void operator=(const cmStringStream&); + cmOStringStream(const cmOStringStream&); + void operator=(const cmOStringStream&); }; -class cmInputStringStream: public std::istringstream +class cmIStringStream: public std::istringstream { public: typedef std::istringstream Superclass; - cmInputStringStream() {} - cmInputStringStream(const char* c) : Superclass(c) {} + cmIStringStream() {} + cmIStringStream(const std::string& s): Superclass(s) {} private: - cmInputStringStream(const cmInputStringStream&); - void operator=(const cmInputStringStream&); + cmIStringStream(const cmIStringStream&); + void operator=(const cmIStringStream&); }; #else -class cmStrStreamCleanup +class cmOStrStreamCleanup { public: - cmStrStreamCleanup(std::ostrstream& ostr): m_StrStream(ostr) {} - ~cmStrStreamCleanup() { m_StrStream.rdbuf()->freeze(0); } - static void IgnoreUnusedVariable(const cmStrStreamCleanup&) {} + cmOStrStreamCleanup(std::ostrstream& ostr): m_OStrStream(ostr) {} + ~cmOStrStreamCleanup() { m_OStrStream.rdbuf()->freeze(0); } + static void IgnoreUnusedVariable(const cmOStrStreamCleanup&) {} protected: - std::ostrstream& m_StrStream; + std::ostrstream& m_OStrStream; }; -class cmStringStream: public std::ostrstream +class cmOStringStream: public std::ostrstream { public: typedef std::ostrstream Superclass; - cmStringStream() {} + cmOStringStream() {} std::string str() { - cmStrStreamCleanup cleanup(*this); - cmStrStreamCleanup::IgnoreUnusedVariable(cleanup); - int pcount = this->pcount(); - const char* ptr = this->Superclass::str(); - return std::string(ptr?ptr:"", pcount); + cmOStrStreamCleanup cleanup(*this); + cmOStrStreamCleanup::IgnoreUnusedVariable(cleanup); + int pcount = this->pcount(); + const char* ptr = this->Superclass::str(); + return std::string(ptr?ptr:"", pcount); } private: - cmStringStream(const cmStringStream&); - void operator=(const cmStringStream&); + cmOStringStream(const cmOStringStream&); + void operator=(const cmOStringStream&); }; -class cmInputStringStream: public std::istrstream + +class cmIStringStream: private std::string, public std::istrstream { public: - typedef std::istrstream Superclass; - cmInputStringStream(const char* c) : Superclass(c) {} + typedef std::string StdString; + typedef std::istrstream IStrStream; + cmIStringStream(): StdString(), IStrStream(this->StdString::c_str()) {} + cmIStringStream(const std::string& s): + StdString(s), IStrStream(this->StdString::c_str()) {} + std::string str() const { return *this; } + void str(const std::string& s) + { + // Very dangerous. If this throws, the object is hosed. When the + // destructor is later called, the program is hosed too. + this->~cmIStringStream(); + new (this) cmIStringStream(s); + } private: - cmInputStringStream(const cmInputStringStream&); - void operator=(const cmInputStringStream&); + cmIStringStream(const cmIStringStream&); + void operator=(const cmIStringStream&); }; #endif - #endif diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9512179..1941165 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1083,7 +1083,7 @@ bool cmSystemTools::FilesDiffer(const char* source, if(statSource.st_size != static_cast<long>(finSource.gcount()) || statSource.st_size != static_cast<long>(finDestination.gcount())) { - cmStringStream msg; + cmOStringStream msg; msg << "FilesDiffer failed to read files (allocated: " << statSource.st_size << ", read source: " << finSource.gcount() << ", read dest: " << finDestination.gcount(); @@ -1190,7 +1190,7 @@ void cmSystemTools::cmCopyFile(const char* source, if (statSource.st_size != statDestination.st_size) { - cmStringStream msg; + cmOStringStream msg; msg << "CopyFile failed to copy files (sizes differ, source: " << statSource.st_size << " , dest: " << statDestination.st_size; cmSystemTools::Error(msg.str().c_str()); @@ -1426,7 +1426,7 @@ bool RunCommandViaPopen(const char* command, if (WIFSIGNALED(retVal)) { retVal = WTERMSIG(retVal); - cmStringStream error; + cmOStringStream error; error << "\nProcess terminated due to "; switch (retVal) { diff --git a/Source/cmVTKMakeInstantiatorCommand.cxx b/Source/cmVTKMakeInstantiatorCommand.cxx index c54e043..8ad3aaf 100644 --- a/Source/cmVTKMakeInstantiatorCommand.cxx +++ b/Source/cmVTKMakeInstantiatorCommand.cxx @@ -326,7 +326,7 @@ cmVTKMakeInstantiatorCommand std::string cmVTKMakeInstantiatorCommand::OldGenerateCreationFileName(unsigned int block) { - cmStringStream nameStr; + cmOStringStream nameStr; nameStr << m_ClassName.c_str() << block << ".cxx"; std::string result = nameStr.str(); return result; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index db604a7..fd976b9 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -95,7 +95,7 @@ void cmake::AddCommand(cmCommand* wg) void cmake::Usage(const char* program) { - cmStringStream errorStream; + cmOStringStream errorStream; errorStream << "cmake version " << cmMakefile::GetMajorVersion() << "." << cmMakefile::GetMinorVersion() << "\n"; @@ -332,7 +332,7 @@ int cmake::AddCMakePaths(const char *arg0) if(!cmSystemTools::FileExists(cMakeSelf.c_str())) { failures.push_back(cMakeSelf); - cmStringStream msg; + cmOStringStream msg; msg << "CMAKE can not find the command line program cmake.\n"; msg << " argv[0] = \"" << arg0 << "\"\n"; msg << " Attempted paths:\n"; @@ -444,7 +444,7 @@ int cmake::AddCMakePaths(const char *arg0) void CMakeCommandUsage(const char* program) { - cmStringStream errorStream; + cmOStringStream errorStream; errorStream << "cmake version " << cmMakefile::GetMajorVersion() diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 1b87f79..a21aef9 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -475,7 +475,7 @@ int ctest::BuildDirectory() // 1 - error // > 1 - warning std::vector<int> markedLines; - cmInputStringStream istr(coutput); + cmIStringStream istr(coutput); while(istr) { char buffer[1024]; |