summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx83
1 files changed, 41 insertions, 42 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 3677a28..174760f 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -34,8 +34,8 @@
static bool requiresMocing(const std::string& text, std::string& macroName)
{
// this simple check is much much faster than the regexp
- if (strstr(text.c_str(), "Q_OBJECT") == NULL &&
- strstr(text.c_str(), "Q_GADGET") == NULL) {
+ if (strstr(text.c_str(), "Q_OBJECT") == CM_NULLPTR &&
+ strstr(text.c_str(), "Q_GADGET") == CM_NULLPTR) {
return false;
}
@@ -88,7 +88,7 @@ static std::string extractSubDir(const std::string& absPath,
}
cmQtAutoGenerators::cmQtAutoGenerators()
- : Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0)
+ : Verbose(cmsys::SystemTools::HasEnv("VERBOSE"))
, ColorOutput(true)
, RunMocFailed(false)
, RunUicFailed(false)
@@ -155,7 +155,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
snapshot.GetDirectory().SetCurrentBinary(targetDirectory);
snapshot.GetDirectory().SetCurrentSource(targetDirectory);
- cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, snapshot));
+ CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, snapshot));
gg.SetCurrentMakefile(mf.get());
this->ReadAutogenInfoFile(mf.get(), targetDirectory, config);
@@ -431,7 +431,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();
@@ -476,7 +476,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());
}
@@ -498,7 +498,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());
}
@@ -526,19 +526,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;
@@ -559,7 +559,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());
@@ -587,7 +587,7 @@ void cmQtAutoGenerators::ParseCppFile(
// first a simple string check for "moc" is *much* faster than the regexp,
// and if the string search already fails, we don't have to try the
// expensive regexp
- if ((strstr(contentsString.c_str(), "moc") != NULL) &&
+ if ((strstr(contentsString.c_str(), "moc") != CM_NULLPTR) &&
(mocIncludeRegExp.find(contentsString))) {
// for every moc include in the file
do {
@@ -619,7 +619,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 << '{'
@@ -635,15 +635,15 @@ void cmQtAutoGenerators::ParseCppFile(
}
} else {
std::string fileToMoc = absFilename;
- if ((basename != scannedFileBasename) || (requiresMoc == false)) {
+ if (!requiresMoc || basename != scannedFileBasename) {
std::string mocSubDir = extractSubDir(absPath, currentMoc);
std::string headerToMoc =
findMatchingHeader(absPath, mocSubDir, basename, headerExtensions);
if (!headerToMoc.empty()) {
// this is for KDE4 compatibility:
fileToMoc = headerToMoc;
- if ((requiresMoc == false) && (basename == scannedFileBasename)) {
- std::stringstream err;
+ if (!requiresMoc && basename == scannedFileBasename) {
+ std::ostringstream err;
err << "AUTOGEN: warning: " << absFilename
<< ": The file "
"includes the moc file \""
@@ -655,7 +655,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 \""
@@ -669,7 +669,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 \""
@@ -695,10 +695,10 @@ void cmQtAutoGenerators::ParseCppFile(
// If this is the case, the moc_foo.cpp should probably be generated from
// foo.cpp instead of foo.h, because otherwise it won't build.
// But warn, since this is not how it is supposed to be used.
- if ((dotMocIncluded == false) && (requiresMoc == true)) {
- if (mocUnderscoreIncluded == true) {
+ 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 "
@@ -716,7 +716,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 "
@@ -741,7 +741,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());
@@ -764,7 +764,7 @@ void cmQtAutoGenerators::StrictParseCppFile(
// first a simple string check for "moc" is *much* faster than the regexp,
// and if the string search already fails, we don't have to try the
// expensive regexp
- if ((strstr(contentsString.c_str(), "moc") != NULL) &&
+ if ((strstr(contentsString.c_str(), "moc") != CM_NULLPTR) &&
(mocIncludeRegExp.find(contentsString))) {
// for every moc include in the file
do {
@@ -790,7 +790,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 << '{'
@@ -806,7 +806,7 @@ void cmQtAutoGenerators::StrictParseCppFile(
}
} else {
if (basename != scannedFileBasename) {
- std::stringstream err;
+ std::ostringstream err;
err << "AUTOGEN: error: " << absFilename
<< ": The file "
"includes the moc file \""
@@ -832,10 +832,9 @@ void cmQtAutoGenerators::StrictParseCppFile(
// foo.cpp instead of foo.h, because otherwise it won't build.
// But warn, since this is not how it is supposed to be used.
std::string macroName;
- if ((dotMocIncluded == false) &&
- (requiresMocing(contentsString, 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 +853,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());
@@ -879,7 +878,7 @@ void cmQtAutoGenerators::ParseForUic(
const std::string realName = cmsys::SystemTools::GetRealPath(absFilename);
matchOffset = 0;
- if ((strstr(contentsString.c_str(), "ui_") != NULL) &&
+ if ((strstr(contentsString.c_str(), "ui_") != CM_NULLPTR) &&
(uiIncludeRegExp.find(contentsString))) {
do {
const std::string currentUi = uiIncludeRegExp.match(1);
@@ -942,7 +941,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());
}
@@ -971,7 +970,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."
@@ -1012,7 +1011,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";
@@ -1034,7 +1033,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());
@@ -1105,7 +1104,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());
@@ -1146,7 +1145,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
@@ -1222,7 +1221,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;
@@ -1272,7 +1271,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
@@ -1339,7 +1338,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());
@@ -1387,7 +1386,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
@@ -1409,7 +1408,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()) {