ENH: Renamed cmStringStream to cmOStringStream and added cmIStringStream. Removed cmInputStringStream.
This commit is contained in:
parent
65cc289047
commit
281f7519e1
@ -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());
|
||||
|
@ -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") + ")";
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
|
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user