diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 4eb23c182..50ac971d1 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -611,18 +611,19 @@ cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage( } //---------------------------------------------------------------------------- -void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmGeneratedFileStream &xout) +void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter &xout) { - xout << "" - << std::endl; + comment << " tools at " << cmTimestamp().CurrentTime("", true); + xout.Comment(comment.str().c_str()); } diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h index 32468613d..5770451ee 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.h +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -13,12 +13,13 @@ #ifndef cmCPackIFWGenerator_h #define cmCPackIFWGenerator_h -#include #include #include "cmCPackIFWPackage.h" #include "cmCPackIFWInstaller.h" +class cmXMLWriter; + /** \class cmCPackIFWGenerator * \brief A generator for Qt Installer Framework tools * @@ -121,7 +122,7 @@ protected: // Methods cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup *group) const; cmCPackIFWPackage* GetComponentPackage(cmCPackComponent *component) const; - void WriteGeneratedByToStrim(cmGeneratedFileStream& xout); + void WriteGeneratedByToStrim(cmXMLWriter& xout); protected: // Data diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 8c77a2c24..224d606c9 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -17,7 +17,7 @@ #include #include -#include +#include #ifdef cmCPackLogger # undef cmCPackLogger @@ -334,30 +334,27 @@ void cmCPackIFWInstaller::GenerateInstallerFile() } // Output stream - cmGeneratedFileStream xout((Directory + "/config/config.xml").data()); + cmGeneratedFileStream fout((Directory + "/config/config.xml").data()); + cmXMLWriter xout(fout); - xout << "" << std::endl; + xout.StartDocument(); WriteGeneratedByToStrim(xout); - xout << "" << std::endl; + xout.StartElement("Installer"); - xout << " " << cmXMLSafe(Name).str() << "" << std::endl; - - xout << " " << Version << "" << std::endl; - - xout << " " << cmXMLSafe(Title).str() << "" - << std::endl; + xout.Element("Name", Name); + xout.Element("Version", Version); + xout.Element("Title", Title); if(!Publisher.empty()) { - xout << " " << cmXMLSafe(Publisher).str() - << "" << std::endl; + xout.Element("Publisher", Publisher); } if(!ProductUrl.empty()) { - xout << " " << ProductUrl << "" << std::endl; + xout.Element("ProductUrl", ProductUrl); } // ApplicationIcon @@ -369,8 +366,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() name = cmSystemTools::GetFilenameWithoutExtension(name); cmsys::SystemTools::CopyFileIfDifferent( InstallerApplicationIcon.data(), path.data()); - xout << " " << name - << "" << std::endl; + xout.Element("InstallerApplicationIcon", name); } // WindowIcon @@ -380,8 +376,7 @@ void cmCPackIFWInstaller::GenerateInstallerFile() std::string path = Directory + "/config/" + name; cmsys::SystemTools::CopyFileIfDifferent( InstallerWindowIcon.data(), path.data()); - xout << " " << name - << "" << std::endl; + xout.Element("InstallerWindowIcon", name); } // Logo @@ -390,104 +385,91 @@ void cmCPackIFWInstaller::GenerateInstallerFile() std::string name = cmSystemTools::GetFilenameName(Logo); std::string path = Directory + "/config/" + name; cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data()); - xout << " " << name << "" << std::endl; + xout.Element("Logo", name); } // Start menu if(!IsVersionLess("2.0")) { - xout << " " << StartMenuDir - << "" << std::endl; + xout.Element("StartMenuDir", StartMenuDir); } // Target dir if(!TargetDir.empty()) { - xout << " " << TargetDir << "" << std::endl; + xout.Element("TargetDir", TargetDir); } // Admin target dir if(!AdminTargetDir.empty()) { - xout << " " << AdminTargetDir - << "" << std::endl; + xout.Element("AdminTargetDir", AdminTargetDir); } // Remote repositories if (!Repositories.empty()) { - xout << " " << std::endl; + xout.StartElement("RemoteRepositories"); for(std::vector::iterator rit = Repositories.begin(); rit != Repositories.end(); ++rit) { - xout << " " << std::endl; + xout.StartElement("Repository"); // Url - xout << " " << rit->Url - << "" << std::endl; + xout.Element("Url", rit->Url); // Enabled if(!rit->Enabled.empty()) { - xout << " " << rit->Enabled - << "" << std::endl; + xout.Element("Enabled", rit->Enabled); } // Username if(!rit->Username.empty()) { - xout << " " << rit->Username - << "" << std::endl; + xout.Element("Username", rit->Username); } // Password if(!rit->Password.empty()) { - xout << " " << rit->Password - << "" << std::endl; + xout.Element("Password", rit->Password); } // DisplayName if(!rit->DisplayName.empty()) { - xout << " " << rit->DisplayName - << "" << std::endl; + xout.Element("DisplayName", rit->DisplayName); } - xout << " " << std::endl; + xout.EndElement(); } - xout << " " << std::endl; + xout.EndElement(); } // Maintenance tool if(!IsVersionLess("2.0") && !MaintenanceToolName.empty()) { - xout << " " << MaintenanceToolName - << "" << std::endl; + xout.Element("MaintenanceToolName", MaintenanceToolName); } // Maintenance tool ini file if(!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty()) { - xout << " " << MaintenanceToolIniFile - << "" << std::endl; + xout.Element("MaintenanceToolIniFile", MaintenanceToolIniFile); } // Different allows if(IsVersionLess("2.0")) { // CPack IFW default policy - xout << " " - << std::endl; - xout << " true" - << std::endl; - xout << " true" << std::endl; + xout.Comment("CPack IFW default policy for QtIFW less 2.0"); + xout.Element("AllowNonAsciiCharacters", "true"); + xout.Element("AllowSpaceInPath", "true"); } else { if(!AllowNonAsciiCharacters.empty()) { - xout << " " << AllowNonAsciiCharacters - << "" << std::endl; + xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters); } if(!AllowSpaceInPath.empty()) { - xout << " " << AllowSpaceInPath - << "" << std::endl; + xout.Element("AllowSpaceInPath", AllowSpaceInPath); } } @@ -497,10 +479,11 @@ void cmCPackIFWInstaller::GenerateInstallerFile() std::string name = cmSystemTools::GetFilenameName(ControlScript); std::string path = Directory + "/config/" + name; cmsys::SystemTools::CopyFileIfDifferent(ControlScript.data(), path.data()); - xout << " " << name << "" << std::endl; + xout.Element("ControlScript", name); } - xout << "" << std::endl; + xout.EndElement(); + xout.EndDocument(); } //---------------------------------------------------------------------------- @@ -535,7 +518,7 @@ void cmCPackIFWInstaller::GeneratePackageFiles() } } -void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmGeneratedFileStream &xout) +void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter &xout) { if(Generator) Generator->WriteGeneratedByToStrim(xout); } diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h index 4cba5b29e..04050c074 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.h +++ b/Source/CPack/IFW/cmCPackIFWInstaller.h @@ -13,11 +13,11 @@ #ifndef cmCPackIFWInstaller_h #define cmCPackIFWInstaller_h -#include #include class cmCPackIFWPackage; class cmCPackIFWGenerator; +class cmXMLWriter; /** \class cmCPackIFWInstaller * \brief A binary installer to be created CPack IFW generator @@ -115,7 +115,7 @@ public: // Internal implementation std::string Directory; protected: - void WriteGeneratedByToStrim(cmGeneratedFileStream& xout); + void WriteGeneratedByToStrim(cmXMLWriter& xout); }; #endif // cmCPackIFWInstaller_h diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index 5474ad1b0..b71c7e32e 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -18,6 +18,7 @@ #include #include +#include //----------------------------------------------------------------- Logger --- #ifdef cmCPackLogger @@ -447,35 +448,28 @@ void cmCPackIFWPackage::GeneratePackageFile() } // Output stream - cmGeneratedFileStream xout((Directory + "/meta/package.xml").data()); + cmGeneratedFileStream fout((Directory + "/meta/package.xml").data()); + cmXMLWriter xout(fout); - xout << "" << std::endl; + xout.StartDocument(); WriteGeneratedByToStrim(xout); - xout << "" << std::endl; + xout.StartElement("Package"); - xout << " " << DisplayName - << "" << std::endl; + xout.Element("DisplayName", DisplayName); + xout.Element("Description", Description); + xout.Element("Name", Name); + xout.Element("Version", Version); - xout << " " << Description - << "" << std::endl; - - xout << " " << Name << "" << std::endl; - - xout << " " << Version - << "" << std::endl; - - xout << " "; - if(ReleaseDate.empty()) + if (!ReleaseDate.empty()) { - xout << cmTimestamp().CurrentTime("%Y-%m-%d", true); + xout.Element("ReleaseDate", ReleaseDate); } else { - xout << ReleaseDate; + xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true)); } - xout << "" << std::endl; // Script (copy to meta dir) if(!Script.empty()) @@ -483,7 +477,7 @@ void cmCPackIFWPackage::GeneratePackageFile() std::string name = cmSystemTools::GetFilenameName(Script); std::string path = Directory + "/meta/" + name; cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data()); - xout << " " << std::endl; + xout.Element("Script", name); } // Dependencies @@ -501,16 +495,16 @@ void cmCPackIFWPackage::GeneratePackageFile() // Write dependencies if (!compDepSet.empty()) { - xout << " "; + std::stringstream dependencies; std::set::iterator it = compDepSet.begin(); - xout << it->NameWithCompare(); + dependencies << it->NameWithCompare(); ++it; while(it != compDepSet.end()) { - xout << "," << it->NameWithCompare(); + dependencies << "," << it->NameWithCompare(); ++it; } - xout << "" << std::endl; + xout.Element("Dependencies", dependencies.str()); } // Licenses (copy to meta dir) @@ -524,43 +518,42 @@ void cmCPackIFWPackage::GeneratePackageFile() } if(!licenses.empty()) { - xout << " " << std::endl; + xout.StartElement("Licenses"); for(size_t i = 0; i < licenses.size(); i += 2) { - xout << " " <" << std::endl; + xout.EndElement(); } if (!ForcedInstallation.empty()) { - xout << " " << ForcedInstallation - << "" << std::endl; + xout.Element("ForcedInstallation", ForcedInstallation); } if (!Virtual.empty()) { - xout << " " << Virtual << "" << std::endl; + xout.Element("Virtual", Virtual); } else if (!Default.empty()) { - xout << " " << Default << "" << std::endl; + xout.Element("Default", Default); } // Priority if(!SortingPriority.empty()) { - xout << " " << SortingPriority - << "" << std::endl; + xout.Element("SortingPriority", SortingPriority); } - xout << "" << std::endl; + xout.EndElement(); + xout.EndDocument(); } -void cmCPackIFWPackage::WriteGeneratedByToStrim(cmGeneratedFileStream &xout) +void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter &xout) { if(Generator) Generator->WriteGeneratedByToStrim(xout); } diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h index d2f792709..e647c1689 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.h +++ b/Source/CPack/IFW/cmCPackIFWPackage.h @@ -14,12 +14,12 @@ #define cmCPackIFWPackage_h #include -#include class cmCPackComponent; class cmCPackComponentGroup; class cmCPackIFWInstaller; class cmCPackIFWGenerator; +class cmXMLWriter; /** \class cmCPackIFWPackage * \brief A single component to be installed by CPack IFW generator @@ -135,7 +135,7 @@ public: // Internal implementation std::string Directory; protected: - void WriteGeneratedByToStrim(cmGeneratedFileStream& xout); + void WriteGeneratedByToStrim(cmXMLWriter& xout); }; #endif // cmCPackIFWPackage_h