summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.cxx29
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.cxx10
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.cxx77
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.cxx5
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx51
-rw-r--r--Source/CPack/WiX/cmWIXAccessControlList.cxx8
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx12
-rw-r--r--Source/CPack/WiX/cmWIXPatch.cxx23
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.cxx4
-rw-r--r--Source/CPack/WiX/cmWIXShortcut.cxx16
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.cxx4
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx60
-rw-r--r--Source/CPack/cmCPackComponentGroup.cxx6
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx76
-rw-r--r--Source/CPack/cmCPackGenerator.cxx95
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx135
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.cxx6
-rw-r--r--Source/CPack/cpack.cxx18
18 files changed, 246 insertions, 389 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
index 97e792a..8153d12 100644
--- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx
+++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx
@@ -49,19 +49,15 @@ int cmCPackIFWGenerator::PackageFiles()
ifwCmd += " -p " + this->toplevel + "/packages";
if (!this->PkgsDirsVector.empty()) {
- for (std::vector<std::string>::iterator it =
- this->PkgsDirsVector.begin();
- it != this->PkgsDirsVector.end(); ++it) {
- ifwCmd += " -p " + *it;
+ for (std::string const& it : this->PkgsDirsVector) {
+ ifwCmd += " -p " + it;
}
}
if (!this->RepoDirsVector.empty()) {
if (!this->IsVersionLess("3.1")) {
- for (std::vector<std::string>::iterator it =
- this->RepoDirsVector.begin();
- it != this->RepoDirsVector.end(); ++it) {
- ifwCmd += " --repository " + *it;
+ for (std::string const& rd : this->RepoDirsVector) {
+ ifwCmd += " --repository " + rd;
}
} else {
cmCPackIFWLogger(WARNING, "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" "
@@ -137,19 +133,15 @@ int cmCPackIFWGenerator::PackageFiles()
ifwCmd += " -p " + this->toplevel + "/packages";
if (!this->PkgsDirsVector.empty()) {
- for (std::vector<std::string>::iterator it =
- this->PkgsDirsVector.begin();
- it != this->PkgsDirsVector.end(); ++it) {
- ifwCmd += " -p " + *it;
+ for (std::string const& it : this->PkgsDirsVector) {
+ ifwCmd += " -p " + it;
}
}
if (!this->RepoDirsVector.empty()) {
if (!this->IsVersionLess("3.1")) {
- for (std::vector<std::string>::iterator it =
- this->RepoDirsVector.begin();
- it != this->RepoDirsVector.end(); ++it) {
- ifwCmd += " --repository " + *it;
+ for (std::string const& rd : this->RepoDirsVector) {
+ ifwCmd += " --repository " + rd;
}
} else {
cmCPackIFWLogger(WARNING, "The \"CPACK_IFW_REPOSITORIES_DIRECTORIES\" "
@@ -321,9 +313,8 @@ int cmCPackIFWGenerator::InitializeInternal()
if (const char* RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) {
std::vector<std::string> RepoAllVector;
cmSystemTools::ExpandListArgument(RepoAllStr, RepoAllVector);
- for (std::vector<std::string>::iterator rit = RepoAllVector.begin();
- rit != RepoAllVector.end(); ++rit) {
- this->GetRepository(*rit);
+ for (std::string const& r : RepoAllVector) {
+ this->GetRepository(r);
}
}
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index 288e924..e3576bd 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -406,9 +406,8 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
// Remote repositories
if (!this->RemoteRepositories.empty()) {
xout.StartElement("RemoteRepositories");
- for (RepositoriesVector::iterator rit = this->RemoteRepositories.begin();
- rit != this->RemoteRepositories.end(); ++rit) {
- (*rit)->WriteRepositoryConfig(xout);
+ for (cmCPackIFWRepository* r : this->RemoteRepositories) {
+ r->WriteRepositoryConfig(xout);
}
xout.EndElement();
}
@@ -492,9 +491,8 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
}
// Generate packages meta information
- for (PackagesMap::iterator pit = this->Packages.begin();
- pit != this->Packages.end(); ++pit) {
- cmCPackIFWPackage* package = pit->second;
+ for (auto& p : this->Packages) {
+ cmCPackIFWPackage* package = p.second;
package->GeneratePackageFile();
}
}
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx
index 8461309..da1553a 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.cxx
+++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx
@@ -203,10 +203,8 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
// CMake dependencies
if (!component->Dependencies.empty()) {
- std::vector<cmCPackComponent*>::iterator dit;
- for (dit = component->Dependencies.begin();
- dit != component->Dependencies.end(); ++dit) {
- this->Dependencies.insert(this->Generator->ComponentPackages[*dit]);
+ for (cmCPackComponent* dep : component->Dependencies) {
+ this->Dependencies.insert(this->Generator->ComponentPackages[dep]);
}
}
@@ -413,9 +411,8 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
if (const char* value = this->GetOption(option)) {
cmSystemTools::ExpandListArgument(value, deps);
}
- for (std::vector<std::string>::iterator dit = deps.begin();
- dit != deps.end(); ++dit) {
- DependenceStruct dep(*dit);
+ for (std::string const& d : deps) {
+ DependenceStruct dep(d);
if (this->Generator->Packages.count(dep.Name)) {
cmCPackIFWPackage& depPkg = this->Generator->Packages[dep.Name];
dep.Name = depPkg.Name;
@@ -435,9 +432,8 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix)
} else if (const char* value = this->GetOption(option)) {
std::vector<std::string> depsOn;
cmSystemTools::ExpandListArgument(value, depsOn);
- for (std::vector<std::string>::iterator dit = depsOn.begin();
- dit != depsOn.end(); ++dit) {
- DependenceStruct dep(*dit);
+ for (std::string const& d : depsOn) {
+ DependenceStruct dep(d);
if (this->Generator->Packages.count(dep.Name)) {
cmCPackIFWPackage& depPkg = this->Generator->Packages[dep.Name];
dep.Name = depPkg.Name;
@@ -521,26 +517,22 @@ void cmCPackIFWPackage::GeneratePackageFile()
xout.StartElement("Package");
// DisplayName (with translations)
- for (std::map<std::string, std::string>::iterator it =
- this->DisplayName.begin();
- it != this->DisplayName.end(); ++it) {
+ for (auto const& dn : this->DisplayName) {
xout.StartElement("DisplayName");
- if (!it->first.empty()) {
- xout.Attribute("xml:lang", it->first);
+ if (!dn.first.empty()) {
+ xout.Attribute("xml:lang", dn.first);
}
- xout.Content(it->second);
+ xout.Content(dn.second);
xout.EndElement();
}
// Description (with translations)
- for (std::map<std::string, std::string>::iterator it =
- this->Description.begin();
- it != this->Description.end(); ++it) {
+ for (auto const& d : this->Description) {
xout.StartElement("Description");
- if (!it->first.empty()) {
- xout.Attribute("xml:lang", it->first);
+ if (!d.first.empty()) {
+ xout.Attribute("xml:lang", d.first);
}
- xout.Content(it->second);
+ xout.Content(d.second);
xout.EndElement();
}
@@ -568,46 +560,43 @@ void cmCPackIFWPackage::GeneratePackageFile()
// User Interfaces (copy to meta dir)
std::vector<std::string> userInterfaces = UserInterfaces;
- for (size_t i = 0; i < userInterfaces.size(); i++) {
- std::string name = cmSystemTools::GetFilenameName(userInterfaces[i]);
+ for (std::string& userInterface : userInterfaces) {
+ std::string name = cmSystemTools::GetFilenameName(userInterface);
std::string path = this->Directory + "/meta/" + name;
- cmsys::SystemTools::CopyFileIfDifferent(userInterfaces[i], path);
- userInterfaces[i] = name;
+ cmsys::SystemTools::CopyFileIfDifferent(userInterface, path);
+ userInterface = name;
}
if (!userInterfaces.empty()) {
xout.StartElement("UserInterfaces");
- for (size_t i = 0; i < userInterfaces.size(); i++) {
- xout.Element("UserInterface", userInterfaces[i]);
+ for (std::string const& userInterface : userInterfaces) {
+ xout.Element("UserInterface", userInterface);
}
xout.EndElement();
}
// Translations (copy to meta dir)
std::vector<std::string> translations = Translations;
- for (size_t i = 0; i < translations.size(); i++) {
- std::string name = cmSystemTools::GetFilenameName(translations[i]);
+ for (std::string& translation : translations) {
+ std::string name = cmSystemTools::GetFilenameName(translation);
std::string path = this->Directory + "/meta/" + name;
- cmsys::SystemTools::CopyFileIfDifferent(translations[i], path);
- translations[i] = name;
+ cmsys::SystemTools::CopyFileIfDifferent(translation, path);
+ translation = name;
}
if (!translations.empty()) {
xout.StartElement("Translations");
- for (size_t i = 0; i < translations.size(); i++) {
- xout.Element("Translation", translations[i]);
+ for (std::string const& translation : translations) {
+ xout.Element("Translation", translation);
}
xout.EndElement();
}
// Dependencies
std::set<DependenceStruct> compDepSet;
- for (std::set<DependenceStruct*>::iterator ait =
- this->AlienDependencies.begin();
- ait != this->AlienDependencies.end(); ++ait) {
- compDepSet.insert(*(*ait));
+ for (DependenceStruct* ad : this->AlienDependencies) {
+ compDepSet.insert(*ad);
}
- for (std::set<cmCPackIFWPackage*>::iterator it = this->Dependencies.begin();
- it != this->Dependencies.end(); ++it) {
- compDepSet.insert(DependenceStruct((*it)->Name));
+ for (cmCPackIFWPackage* d : this->Dependencies) {
+ compDepSet.insert(DependenceStruct(d->Name));
}
// Write dependencies
if (!compDepSet.empty()) {
@@ -624,10 +613,8 @@ void cmCPackIFWPackage::GeneratePackageFile()
// Automatic dependency on
std::set<DependenceStruct> compAutoDepSet;
- for (std::set<DependenceStruct*>::iterator ait =
- this->AlienAutoDependOn.begin();
- ait != this->AlienAutoDependOn.end(); ++ait) {
- compAutoDepSet.insert(*(*ait));
+ for (DependenceStruct* aad : this->AlienAutoDependOn) {
+ compAutoDepSet.insert(*aad);
}
// Write automatic dependency on
if (!compAutoDepSet.empty()) {
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx
index b115db0..8325f73 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.cxx
+++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx
@@ -279,9 +279,8 @@ void cmCPackIFWRepository::WriteRepositoryUpdates(cmXMLWriter& xout)
{
if (!this->RepositoryUpdate.empty()) {
xout.StartElement("RepositoryUpdate");
- for (RepositoriesVector::iterator rit = this->RepositoryUpdate.begin();
- rit != this->RepositoryUpdate.end(); ++rit) {
- (*rit)->WriteRepositoryUpdate(xout);
+ for (cmCPackIFWRepository* r : this->RepositoryUpdate) {
+ r->WriteRepositoryUpdate(xout);
}
xout.EndElement();
}
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 274dfd0..ba07d08 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -89,9 +89,8 @@ bool cmCPackWIXGenerator::RunCandleCommand(std::string const& sourceFile,
command << " -arch " << GetArchitecture();
command << " -out " << QuotePath(objectFile);
- for (extension_set_t::const_iterator i = CandleExtensions.begin();
- i != CandleExtensions.end(); ++i) {
- command << " -ext " << QuotePath(*i);
+ for (std::string const& ext : CandleExtensions) {
+ command << " -ext " << QuotePath(ext);
}
AddCustomFlags("CPACK_WIX_CANDLE_EXTRA_FLAGS", command);
@@ -113,9 +112,8 @@ bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
command << " -nologo";
command << " -out " << QuotePath(packageFileNames.at(0));
- for (extension_set_t::const_iterator i = this->LightExtensions.begin();
- i != this->LightExtensions.end(); ++i) {
- command << " -ext " << QuotePath(*i);
+ for (std::string const& ext : this->LightExtensions) {
+ command << " -ext " << QuotePath(ext);
}
const char* const cultures = GetOption("CPACK_WIX_CULTURES");
@@ -219,8 +217,8 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
std::vector<std::string> patchFilePaths;
cmSystemTools::ExpandListArgument(patchFilePath, patchFilePaths);
- for (size_t i = 0; i < patchFilePaths.size(); ++i) {
- if (!this->Patch->LoadFragments(patchFilePaths[i])) {
+ for (std::string const& p : patchFilePaths) {
+ if (!this->Patch->LoadFragments(p)) {
return false;
}
}
@@ -254,9 +252,7 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
std::set<std::string> usedBaseNames;
std::ostringstream objectFiles;
- for (size_t i = 0; i < this->WixSources.size(); ++i) {
- std::string const& sourceFilename = this->WixSources[i];
-
+ for (std::string const& sourceFilename : this->WixSources) {
std::string baseName =
cmSystemTools::GetFilenameWithoutLastExtension(sourceFilename);
@@ -306,8 +302,8 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
cmSystemTools::ExpandListArgument(cpackWixExtraObjects,
expandedExtraObjects);
- for (size_t i = 0; i < expandedExtraObjects.size(); ++i) {
- stream << " " << QuotePath(expandedExtraObjects[i]);
+ for (std::string const& obj : expandedExtraObjects) {
+ stream << " " << QuotePath(obj);
}
}
@@ -345,9 +341,7 @@ void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
std::string prefix = "CPACK_WIX_PROPERTY_";
std::vector<std::string> options = GetOptions();
- for (size_t i = 0; i < options.size(); ++i) {
- std::string const& name = options[i];
-
+ for (std::string const& name : options) {
if (name.length() > prefix.length() &&
name.substr(0, prefix.length()) == prefix) {
std::string id = name.substr(prefix.length());
@@ -503,16 +497,14 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
globalShortcuts.AddShortcutTypes(emittedShortcutTypes);
} else {
- for (std::map<std::string, cmCPackComponent>::const_iterator i =
- this->Components.begin();
- i != this->Components.end(); ++i) {
- cmCPackComponent const& component = i->second;
+ for (auto const& i : this->Components) {
+ cmCPackComponent const& component = i.second;
std::string componentPath = toplevel;
componentPath += "/";
componentPath += component.Name;
- std::string componentFeatureId = "CM_C_" + component.Name;
+ std::string const componentFeatureId = "CM_C_" + component.Name;
cmWIXShortcuts featureShortcuts;
AddComponentsToFeature(componentPath, componentFeatureId,
@@ -623,19 +615,15 @@ bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
bool cmCPackWIXGenerator::CreateFeatureHierarchy(
cmWIXFeaturesSourceWriter& featureDefinitions)
{
- for (std::map<std::string, cmCPackComponentGroup>::const_iterator i =
- ComponentGroups.begin();
- i != ComponentGroups.end(); ++i) {
- cmCPackComponentGroup const& group = i->second;
+ for (auto const& i : ComponentGroups) {
+ cmCPackComponentGroup const& group = i.second;
if (group.ParentGroup == 0) {
featureDefinitions.EmitFeatureForComponentGroup(group, *this->Patch);
}
}
- for (std::map<std::string, cmCPackComponent>::const_iterator i =
- this->Components.begin();
- i != this->Components.end(); ++i) {
- cmCPackComponent const& component = i->second;
+ for (auto const& i : this->Components) {
+ cmCPackComponent const& component = i.second;
if (!component.Group) {
featureDefinitions.EmitFeatureForComponent(component, *this->Patch);
@@ -1135,9 +1123,8 @@ void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName,
std::vector<std::string> list;
cmSystemTools::ExpandListArgument(variableContent, list);
- for (std::vector<std::string>::const_iterator i = list.begin();
- i != list.end(); ++i) {
- stream << " " << QuotePath(*i);
+ for (std::string const& i : list) {
+ stream << " " << QuotePath(i);
}
}
diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx
index 744a932..1603bf8 100644
--- a/Source/CPack/WiX/cmWIXAccessControlList.cxx
+++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx
@@ -20,8 +20,8 @@ bool cmWIXAccessControlList::Apply()
std::vector<std::string> entries;
this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries);
- for (size_t i = 0; i < entries.size(); ++i) {
- this->CreatePermissionElement(entries[i]);
+ for (std::string const& entry : entries) {
+ this->CreatePermissionElement(entry);
}
return true;
@@ -56,9 +56,9 @@ void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry)
if (!domain.empty()) {
this->SourceWriter.AddAttribute("Domain", domain);
}
- for (size_t i = 0; i < permissions.size(); ++i) {
+ for (std::string const& permission : permissions) {
this->EmitBooleanAttribute(entry,
- cmSystemTools::TrimWhitespace(permissions[i]));
+ cmSystemTools::TrimWhitespace(permission));
}
this->SourceWriter.EndElement("Permission");
}
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
index 0be4377..a7a0648 100644
--- a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -46,16 +46,12 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
patch.ApplyFragment("CM_G_" + group.Name, *this);
- for (std::vector<cmCPackComponentGroup*>::const_iterator i =
- group.Subgroups.begin();
- i != group.Subgroups.end(); ++i) {
- EmitFeatureForComponentGroup(**i, patch);
+ for (cmCPackComponentGroup* subgroup : group.Subgroups) {
+ EmitFeatureForComponentGroup(*subgroup, patch);
}
- for (std::vector<cmCPackComponent*>::const_iterator i =
- group.Components.begin();
- i != group.Components.end(); ++i) {
- EmitFeatureForComponent(**i, patch);
+ for (cmCPackComponent* component : group.Components) {
+ EmitFeatureForComponent(*component, patch);
}
EndElement("Feature");
diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx
index 287a644..dec95fb 100644
--- a/Source/CPack/WiX/cmWIXPatch.cxx
+++ b/Source/CPack/WiX/cmWIXPatch.cxx
@@ -29,10 +29,8 @@ void cmWIXPatch::ApplyFragment(std::string const& id,
return;
const cmWIXPatchElement& fragment = i->second;
- for (cmWIXPatchElement::attributes_t::const_iterator attr_i =
- fragment.attributes.begin();
- attr_i != fragment.attributes.end(); ++attr_i) {
- writer.AddAttribute(attr_i->first, attr_i->second);
+ for (auto const& attr : fragment.attributes) {
+ writer.AddAttribute(attr.first, attr.second);
}
this->ApplyElementChildren(fragment, writer);
@@ -42,11 +40,7 @@ void cmWIXPatch::ApplyFragment(std::string const& id,
void cmWIXPatch::ApplyElementChildren(const cmWIXPatchElement& element,
cmWIXSourceWriter& writer)
{
- for (cmWIXPatchElement::child_list_t::const_iterator j =
- element.children.begin();
- j != element.children.end(); ++j) {
- cmWIXPatchNode* node = *j;
-
+ for (cmWIXPatchNode* node : element.children) {
switch (node->type()) {
case cmWIXPatchNode::ELEMENT:
ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer);
@@ -63,10 +57,8 @@ void cmWIXPatch::ApplyElement(const cmWIXPatchElement& element,
{
writer.BeginElement(element.name);
- for (cmWIXPatchElement::attributes_t::const_iterator i =
- element.attributes.begin();
- i != element.attributes.end(); ++i) {
- writer.AddAttribute(i->first, i->second);
+ for (auto const& attr : element.attributes) {
+ writer.AddAttribute(attr.first, attr.second);
}
this->ApplyElementChildren(element, writer);
@@ -77,14 +69,13 @@ void cmWIXPatch::ApplyElement(const cmWIXPatchElement& element,
bool cmWIXPatch::CheckForUnappliedFragments()
{
std::string fragmentList;
- for (cmWIXPatchParser::fragment_map_t::const_iterator i = Fragments.begin();
- i != Fragments.end(); ++i) {
+ for (auto const& fragment : Fragments) {
if (!fragmentList.empty()) {
fragmentList += ", ";
}
fragmentList += "'";
- fragmentList += i->first;
+ fragmentList += fragment.first;
fragmentList += "'";
}
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx
index b050b85..e6aeed3 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.cxx
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -22,8 +22,8 @@ cmWIXPatchNode::~cmWIXPatchNode()
cmWIXPatchElement::~cmWIXPatchElement()
{
- for (child_list_t::iterator i = children.begin(); i != children.end(); ++i) {
- delete *i;
+ for (cmWIXPatchNode* child : children) {
+ delete child;
}
}
diff --git a/Source/CPack/WiX/cmWIXShortcut.cxx b/Source/CPack/WiX/cmWIXShortcut.cxx
index e5dea94..cd1988a 100644
--- a/Source/CPack/WiX/cmWIXShortcut.cxx
+++ b/Source/CPack/WiX/cmWIXShortcut.cxx
@@ -47,10 +47,9 @@ bool cmWIXShortcuts::EmitShortcuts(
return false;
}
- for (shortcut_id_map_t::const_iterator j = id_map.begin(); j != id_map.end();
- ++j) {
- std::string const& id = j->first;
- shortcut_list_t const& shortcutList = j->second;
+ for (auto const& j : id_map) {
+ std::string const& id = j.first;
+ shortcut_list_t const& shortcutList = j.second;
for (size_t shortcutListIndex = 0; shortcutListIndex < shortcutList.size();
++shortcutListIndex) {
@@ -68,9 +67,8 @@ bool cmWIXShortcuts::EmitShortcuts(
void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types)
{
- for (shortcut_type_map_t::const_iterator i = this->Shortcuts.begin();
- i != this->Shortcuts.end(); ++i) {
- types.insert(i->first);
+ for (auto const& shortcut : this->Shortcuts) {
+ types.insert(shortcut.first);
}
}
@@ -96,9 +94,9 @@ void cmWIXShortcuts::CreateFromProperty(std::string const& propertyName,
std::vector<std::string> list;
installedFile.GetPropertyAsList(propertyName, list);
- for (size_t i = 0; i < list.size(); ++i) {
+ for (std::string const& label : list) {
cmWIXShortcut shortcut;
- shortcut.label = list[i];
+ shortcut.label = label;
shortcut.workingDirectoryId = directoryId;
insert(type, id, shortcut);
}
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index a86e28d..dc730e0 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -158,9 +158,7 @@ std::string cmWIXSourceWriter::EscapeAttributeValue(std::string const& value)
std::string result;
result.reserve(value.size());
- char c = 0;
- for (size_t i = 0; i < value.size(); ++i) {
- c = value[i];
+ for (char c : value) {
switch (c) {
case '<':
result += "&lt;";
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 1e45b48..641be38 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -9,7 +9,6 @@
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
-#include <map>
#include <ostream>
#include <utility>
#include <vector>
@@ -74,10 +73,8 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
filePrefix += installPrefix + 1;
filePrefix += "/";
}
- std::vector<std::string>::const_iterator fileIt;
- for (fileIt = component->Files.begin(); fileIt != component->Files.end();
- ++fileIt) {
- std::string rp = filePrefix + *fileIt;
+ for (std::string const& file : component->Files) {
+ std::string rp = filePrefix + file;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file: " << rp << std::endl);
archive.Add(rp, 0, nullptr, false);
if (!archive) {
@@ -117,53 +114,47 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) {
- std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
- for (compGIt = this->ComponentGroups.begin();
- compGIt != this->ComponentGroups.end(); ++compGIt) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first << std::endl);
+ for (auto const& compG : this->ComponentGroups) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Packaging component group: " << compG.first << std::endl);
// Begin the archive for this group
std::string packageFileName = std::string(toplevel) + "/" +
- this->GetArchiveComponentFileName(compGIt->first, true);
+ this->GetArchiveComponentFileName(compG.first, true);
// open a block in order to automatically close archive
// at the end of the block
{
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// now iterate over the component of this group
- std::vector<cmCPackComponent*>::iterator compIt;
- for (compIt = (compGIt->second).Components.begin();
- compIt != (compGIt->second).Components.end(); ++compIt) {
+ for (cmCPackComponent* comp : (compG.second).Components) {
// Add the files of this component to the archive
- addOneComponentToArchive(archive, *compIt);
+ addOneComponentToArchive(archive, comp);
}
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
}
// Handle Orphan components (components not belonging to any groups)
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
+ for (auto& comp : this->Components) {
// Does the component belong to a group?
- if (compIt->second.Group == nullptr) {
+ if (comp.second.Group == nullptr) {
cmCPackLogger(
cmCPackLog::LOG_VERBOSE, "Component <"
- << compIt->second.Name
+ << comp.second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
std::string localToplevel(
this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
std::string packageFileName = std::string(toplevel);
- localToplevel += "/" + compIt->first;
+ localToplevel += "/" + comp.first;
packageFileName +=
- "/" + this->GetArchiveComponentFileName(compIt->first, false);
+ "/" + this->GetArchiveComponentFileName(comp.first, false);
{
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// Add the files of this component to the archive
- addOneComponentToArchive(archive, &(compIt->second));
+ addOneComponentToArchive(archive, &(comp.second));
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
@@ -173,20 +164,18 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
else {
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
+ for (auto& comp : this->Components) {
std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
std::string packageFileName = std::string(toplevel);
- localToplevel += "/" + compIt->first;
+ localToplevel += "/" + comp.first;
packageFileName +=
- "/" + this->GetArchiveComponentFileName(compIt->first, false);
+ "/" + this->GetArchiveComponentFileName(comp.first, false);
{
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// Add the files of this component to the archive
- addOneComponentToArchive(archive, &(compIt->second));
+ addOneComponentToArchive(archive, &(comp.second));
}
// add the generated package to package file names list
packageFileNames.push_back(packageFileName);
@@ -217,11 +206,9 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
// The ALL COMPONENTS in ONE package case
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
+ for (auto& comp : this->Components) {
// Add the files of this component to the archive
- addOneComponentToArchive(archive, &(compIt->second));
+ addOneComponentToArchive(archive, &(comp.second));
}
// archive goes out of scope so it will finalized and closed.
@@ -249,16 +236,15 @@ int cmCPackArchiveGenerator::PackageFiles()
// CASE 3 : NON COMPONENT package.
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
- std::vector<std::string>::const_iterator fileIt;
cmWorkingDirectory workdir(toplevel);
- for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
+ for (std::string const& file : files) {
// Get the relative path to the file
std::string rp =
- cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str());
+ cmSystemTools::RelativePath(toplevel.c_str(), file.c_str());
archive.Add(rp, 0, nullptr, false);
if (!archive) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< "
- << *fileIt << "> to archive <" << packageFileNames[0]
+ << file << "> to archive <" << packageFileNames[0]
<< "> .ERROR =" << archive.GetError() << std::endl);
return 0;
}
diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx
index e39398a..f888a5f 100644
--- a/Source/CPack/cmCPackComponentGroup.cxx
+++ b/Source/CPack/cmCPackComponentGroup.cxx
@@ -5,7 +5,6 @@
#include "cmSystemTools.h"
#include <string>
-#include <vector>
unsigned long cmCPackComponent::GetInstalledSize(
const std::string& installDir) const
@@ -14,11 +13,10 @@ unsigned long cmCPackComponent::GetInstalledSize(
return this->TotalSize;
}
- std::vector<std::string>::const_iterator fileIt;
- for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) {
+ for (std::string const& file : this->Files) {
std::string path = installDir;
path += '/';
- path += *fileIt;
+ path += file;
this->TotalSize += cmSystemTools::FileLength(path);
}
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 18d559e..855aea9 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -12,7 +12,6 @@
#include "cm_sys_stat.h"
#include "cmsys/Glob.hxx"
-#include <map>
#include <ostream>
#include <set>
#include <string.h>
@@ -105,37 +104,31 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) {
- std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
- for (compGIt = this->ComponentGroups.begin();
- compGIt != this->ComponentGroups.end(); ++compGIt) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
- << compGIt->first << std::endl);
+ for (auto const& compG : this->ComponentGroups) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ "Packaging component group: " << compG.first << std::endl);
// Begin the archive for this group
- retval &= PackageOnePack(initialTopLevel, compGIt->first);
+ retval &= PackageOnePack(initialTopLevel, compG.first);
}
// Handle Orphan components (components not belonging to any groups)
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
+ for (auto const& comp : this->Components) {
// Does the component belong to a group?
- if (compIt->second.Group == nullptr) {
+ if (comp.second.Group == nullptr) {
cmCPackLogger(
cmCPackLog::LOG_VERBOSE, "Component <"
- << compIt->second.Name
+ << comp.second.Name
<< "> does not belong to any group, package it separately."
<< std::endl);
// Begin the archive for this orphan component
- retval &= PackageOnePack(initialTopLevel, compIt->first);
+ retval &= PackageOnePack(initialTopLevel, comp.first);
}
}
}
// CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component
else {
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
- retval &= PackageOnePack(initialTopLevel, compIt->first);
+ for (auto const& comp : this->Components) {
+ retval &= PackageOnePack(initialTopLevel, comp.first);
}
}
return retval;
@@ -336,10 +329,8 @@ int cmCPackDebGenerator::createDeb()
{
std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
dirName += '/';
- for (std::vector<std::string>::const_iterator fileIt =
- packageFiles.begin();
- fileIt != packageFiles.end(); ++fileIt) {
- totalSize += cmSystemTools::FileLength(*fileIt);
+ for (std::string const& file : packageFiles) {
+ totalSize += cmSystemTools::FileLength(file);
}
}
out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n";
@@ -446,10 +437,7 @@ int cmCPackDebGenerator::createDeb()
// we have to reconstruct the parent folders as well
- for (std::vector<std::string>::const_iterator fileIt =
- packageFiles.begin();
- fileIt != packageFiles.end(); ++fileIt) {
- std::string currentPath = *fileIt;
+ for (std::string currentPath : packageFiles) {
while (currentPath != strGenWDIR) {
// the last one IS strGenWDIR, but we do not want this one:
// XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application
@@ -459,18 +447,17 @@ int cmCPackDebGenerator::createDeb()
}
}
- for (std::set<std::string>::const_iterator fileIt = orderedFiles.begin();
- fileIt != orderedFiles.end(); ++fileIt) {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << *fileIt << "\""
+ for (std::string const& file : orderedFiles) {
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << file << "\""
<< std::endl);
- std::string::size_type slashPos = fileIt->find('/', topLevelLength + 1);
+ std::string::size_type slashPos = file.find('/', topLevelLength + 1);
std::string relativeDir =
- fileIt->substr(topLevelLength, slashPos - topLevelLength);
+ file.substr(topLevelLength, slashPos - topLevelLength);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \""
<< relativeDir << "\"" << std::endl);
#ifdef WIN32
- std::string mode_t_adt_filename = *fileIt + ":cmake_mode_t";
+ std::string mode_t_adt_filename = file + ":cmake_mode_t";
cmsys::ifstream permissionStream(mode_t_adt_filename.c_str());
mode_t permissions = 0;
@@ -481,7 +468,7 @@ int cmCPackDebGenerator::createDeb()
if (permissions != 0) {
data_tar.SetPermissions(permissions);
- } else if (cmSystemTools::FileIsDirectory(*fileIt)) {
+ } else if (cmSystemTools::FileIsDirectory(file)) {
data_tar.SetPermissions(0755);
} else {
data_tar.ClearPermissions();
@@ -489,11 +476,11 @@ int cmCPackDebGenerator::createDeb()
#endif
// do not recurse because the loop will do it
- if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) {
+ if (!data_tar.Add(file, topLevelLength, ".", false)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:"
<< std::endl
<< "#top level directory: " << strGenWDIR << std::endl
- << "#file: " << *fileIt << std::endl
+ << "#file: " << file << std::endl
<< "#error:" << data_tar.GetError() << std::endl);
return 0;
}
@@ -508,23 +495,21 @@ int cmCPackDebGenerator::createDeb()
std::string topLevelWithTrailingSlash =
this->GetOption("CPACK_TEMPORARY_DIRECTORY");
topLevelWithTrailingSlash += '/';
- for (std::vector<std::string>::const_iterator fileIt =
- packageFiles.begin();
- fileIt != packageFiles.end(); ++fileIt) {
+ for (std::string const& file : packageFiles) {
// hash only regular files
- if (cmSystemTools::FileIsDirectory(*fileIt) ||
- cmSystemTools::FileIsSymlink(*fileIt)) {
+ if (cmSystemTools::FileIsDirectory(file) ||
+ cmSystemTools::FileIsSymlink(file)) {
continue;
}
std::string output =
- cmSystemTools::ComputeFileHash(*fileIt, cmCryptoHash::AlgoMD5);
+ cmSystemTools::ComputeFileHash(file, cmCryptoHash::AlgoMD5);
if (output.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of "
- << *fileIt << std::endl);
+ << file << std::endl);
}
- output += " " + *fileIt + "\n";
+ output += " " + file + "\n";
// debian md5sums entries are like this:
// 014f3604694729f3bf19263bac599765 usr/bin/ccmake
// thus strip the full path (with the trailing slash)
@@ -641,9 +626,8 @@ int cmCPackDebGenerator::createDeb()
std::vector<std::string> controlExtraList;
cmSystemTools::ExpandListArgument(controlExtra, controlExtraList);
- for (std::vector<std::string>::iterator i = controlExtraList.begin();
- i != controlExtraList.end(); ++i) {
- std::string filenamename = cmsys::SystemTools::GetFilenameName(*i);
+ for (std::string const& i : controlExtraList) {
+ std::string filenamename = cmsys::SystemTools::GetFilenameName(i);
std::string localcopy = strGenWDIR + "/" + filenamename;
if (permissionStrictPolicy) {
@@ -653,7 +637,7 @@ int cmCPackDebGenerator::createDeb()
}
// if we can copy the file, it means it does exist, let's add it:
- if (cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy)) {
+ if (cmsys::SystemTools::CopyFileIfDifferent(i, localcopy)) {
control_tar.Add(localcopy, strGenWDIR.length(), ".");
}
}
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 44c7915..e72fcc1 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -248,25 +248,23 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
cmSystemTools::PutEnv(tempInstallDirectoryEnv);
std::vector<std::string> installCommandsVector;
cmSystemTools::ExpandListArgument(installCommands, installCommandsVector);
- std::vector<std::string>::iterator it;
- for (it = installCommandsVector.begin(); it != installCommandsVector.end();
- ++it) {
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it << std::endl);
+ for (std::string const& ic : installCommandsVector) {
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ic << std::endl);
std::string output;
int retVal = 1;
bool resB =
- cmSystemTools::RunSingleCommand(it->c_str(), &output, &output, &retVal,
+ cmSystemTools::RunSingleCommand(ic.c_str(), &output, &output, &retVal,
nullptr, this->GeneratorVerbose, 0);
if (!resB || retVal) {
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/InstallOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << *it << std::endl
+ ofs << "# Run command: " << ic << std::endl
<< "# Output:" << std::endl
<< output << std::endl;
cmCPackLogger(
cmCPackLog::LOG_ERROR, "Problem running install command: "
- << *it << std::endl
+ << ic << std::endl
<< "Please check " << tmpFile << " for errors" << std::endl);
return 0;
}
@@ -286,12 +284,10 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
std::vector<std::string> ignoreFilesRegexString;
cmSystemTools::ExpandListArgument(cpackIgnoreFiles,
ignoreFilesRegexString);
- std::vector<std::string>::iterator it;
- for (it = ignoreFilesRegexString.begin();
- it != ignoreFilesRegexString.end(); ++it) {
+ for (std::string const& ifr : ignoreFilesRegexString) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Create ignore files regex for: " << *it << std::endl);
- ignoreFilesRegex.push_back(it->c_str());
+ "Create ignore files regex for: " << ifr << std::endl);
+ ignoreFilesRegex.push_back(ifr.c_str());
}
}
const char* installDirectories =
@@ -334,15 +330,14 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
files = gl.GetFiles();
std::vector<std::string>::iterator gfit;
std::vector<cmsys::RegularExpression>::iterator regIt;
- for (gfit = files.begin(); gfit != files.end(); ++gfit) {
+ for (std::string const& gf : files) {
bool skip = false;
- std::string inFile = *gfit;
- if (cmSystemTools::FileIsDirectory(*gfit)) {
+ std::string inFile = gf;
+ if (cmSystemTools::FileIsDirectory(gf)) {
inFile += '/';
}
- for (regIt = ignoreFilesRegex.begin(); regIt != ignoreFilesRegex.end();
- ++regIt) {
- if (regIt->find(inFile.c_str())) {
+ for (cmsys::RegularExpression& reg : ignoreFilesRegex) {
+ if (reg.find(inFile.c_str())) {
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Ignore file: " << inFile << std::endl);
skip = true;
@@ -353,7 +348,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
}
std::string filePath = tempDir;
filePath += "/" + subdir + "/" +
- cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
+ cmSystemTools::RelativePath(top.c_str(), gf.c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
<< inFile << " -> " << filePath << std::endl);
/* If the file is a symlink we will have to re-create it */
@@ -377,32 +372,30 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
}
/* rebuild symlinks in the installed tree */
if (!symlinkedFiles.empty()) {
- std::vector<std::pair<std::string, std::string>>::iterator symlinkedIt;
std::string curDir = cmSystemTools::GetCurrentWorkingDirectory();
std::string goToDir = tempDir;
goToDir += "/" + subdir;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir
<< std::endl);
cmWorkingDirectory workdir(goToDir);
- for (symlinkedIt = symlinkedFiles.begin();
- symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) {
+ for (auto const& symlinked : symlinkedFiles) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
- << symlinkedIt->second << "--> "
- << symlinkedIt->first << std::endl);
+ << symlinked.second << "--> " << symlinked.first
+ << std::endl);
// make sure directory exists for symlink
std::string destDir =
- cmSystemTools::GetFilenamePath(symlinkedIt->second);
+ cmSystemTools::GetFilenamePath(symlinked.second);
if (!destDir.empty() && !cmSystemTools::MakeDirectory(destDir)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create dir: "
<< destDir << "\nTrying to create symlink: "
- << symlinkedIt->second << "--> "
- << symlinkedIt->first << std::endl);
+ << symlinked.second << "--> " << symlinked.first
+ << std::endl);
}
- if (!cmSystemTools::CreateSymlink(symlinkedIt->first,
- symlinkedIt->second)) {
+ if (!cmSystemTools::CreateSymlink(symlinked.first,
+ symlinked.second)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: "
- << symlinkedIt->second << "--> "
- << symlinkedIt->first << std::endl);
+ << symlinked.second << "--> " << symlinked.first
+ << std::endl);
return 0;
}
}
@@ -423,10 +416,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
<< std::endl);
std::vector<std::string> cmakeScriptsVector;
cmSystemTools::ExpandListArgument(cmakeScripts, cmakeScriptsVector);
- std::vector<std::string>::iterator it;
- for (it = cmakeScriptsVector.begin(); it != cmakeScriptsVector.end();
- ++it) {
- std::string installScript = *it;
+ for (std::string const& installScript : cmakeScriptsVector) {
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Install script: " << installScript << std::endl);
@@ -532,10 +522,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
if (installTypes && *installTypes) {
std::vector<std::string> installTypesVector;
cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
- std::vector<std::string>::iterator installTypeIt;
- for (installTypeIt = installTypesVector.begin();
- installTypeIt != installTypesVector.end(); ++installTypeIt) {
- this->GetInstallationType(installProjectName, *installTypeIt);
+ for (std::string const& installType : installTypesVector) {
+ this->GetInstallationType(installProjectName, installType);
}
}
@@ -545,10 +533,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
const char* components = this->GetOption(componentsVar);
if (components && *components) {
cmSystemTools::ExpandListArgument(components, componentsVector);
- std::vector<std::string>::iterator compIt;
- for (compIt = componentsVector.begin();
- compIt != componentsVector.end(); ++compIt) {
- GetComponent(installProjectName, *compIt);
+ for (std::string const& comp : componentsVector) {
+ GetComponent(installProjectName, comp);
}
componentInstall = true;
}
@@ -609,11 +595,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
"- Install project: " << installProjectName << std::endl);
// Run the installation for each component
- std::vector<std::string>::iterator componentIt;
- for (componentIt = componentsVector.begin();
- componentIt != componentsVector.end(); ++componentIt) {
+ for (std::string const& component : componentsVector) {
std::string tempInstallDirectory = baseTempInstallDirectory;
- installComponent = *componentIt;
+ installComponent = component;
if (componentInstall) {
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install component: "
<< installComponent << std::endl);
@@ -990,12 +974,11 @@ int cmCPackGenerator::DoPackage()
*/
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) ["
<< packageFileNames.size() << "]:" << std::endl);
- std::vector<std::string>::iterator it;
/* now copy package one by one */
- for (it = packageFileNames.begin(); it != packageFileNames.end(); ++it) {
+ for (std::string const& pkgFileName : packageFileNames) {
std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX"));
- std::string filename(cmSystemTools::GetFilenameName(*it));
- tempPackageFileName = it->c_str();
+ std::string filename(cmSystemTools::GetFilenameName(pkgFileName));
+ tempPackageFileName = pkgFileName.c_str();
tmpPF += "/" + filename;
const char* packageFileName = tmpPF.c_str();
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): "
@@ -1419,10 +1402,9 @@ cmCPackComponent* cmCPackGenerator::GetComponent(
std::vector<std::string> installTypesVector;
cmSystemTools::ExpandListArgument(installTypes, installTypesVector);
std::vector<std::string>::iterator installTypesIt;
- for (installTypesIt = installTypesVector.begin();
- installTypesIt != installTypesVector.end(); ++installTypesIt) {
+ for (std::string const& installType : installTypesVector) {
component->InstallationTypes.push_back(
- this->GetInstallationType(projectName, *installTypesIt));
+ this->GetInstallationType(projectName, installType));
}
}
@@ -1432,9 +1414,8 @@ cmCPackComponent* cmCPackGenerator::GetComponent(
std::vector<std::string> dependsVector;
cmSystemTools::ExpandListArgument(depends, dependsVector);
std::vector<std::string>::iterator dependIt;
- for (dependIt = dependsVector.begin(); dependIt != dependsVector.end();
- ++dependIt) {
- cmCPackComponent* child = GetComponent(projectName, *dependIt);
+ for (std::string const& depend : dependsVector) {
+ cmCPackComponent* child = GetComponent(projectName, depend);
component->Dependencies.push_back(child);
child->ReverseDependencies.push_back(component);
}
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index d04ea13..ddf104c 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -59,11 +59,10 @@ int cmCPackNSISGenerator::PackageFiles()
std::string nsisInstallOptions = nsisFileName + "/NSIS.InstallOptions.ini";
nsisFileName += "/project.nsi";
std::ostringstream str;
- std::vector<std::string>::const_iterator it;
- for (it = files.begin(); it != files.end(); ++it) {
+ for (std::string const& file : files) {
std::string outputDir = "$INSTDIR";
std::string fileN =
- cmSystemTools::RelativePath(toplevel.c_str(), it->c_str());
+ cmSystemTools::RelativePath(toplevel.c_str(), file.c_str());
if (!this->Components.empty()) {
const std::string::size_type pos = fileN.find('/');
@@ -87,12 +86,11 @@ int cmCPackNSISGenerator::PackageFiles()
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str());
std::vector<std::string> dirs;
this->GetListOfSubdirectories(toplevel.c_str(), dirs);
- std::vector<std::string>::const_iterator sit;
std::ostringstream dstr;
- for (sit = dirs.begin(); sit != dirs.end(); ++sit) {
+ for (std::string const& dir : dirs) {
std::string componentName;
std::string fileN =
- cmSystemTools::RelativePath(toplevel.c_str(), sit->c_str());
+ cmSystemTools::RelativePath(toplevel.c_str(), dir.c_str());
if (fileN.empty()) {
continue;
}
@@ -205,65 +203,57 @@ int cmCPackNSISGenerator::PackageFiles()
// in a vector based on the indices, and print them in that order.
std::vector<cmCPackInstallationType*> installTypes(
this->InstallationTypes.size());
- std::map<std::string, cmCPackInstallationType>::iterator installTypeIt;
- for (installTypeIt = this->InstallationTypes.begin();
- installTypeIt != this->InstallationTypes.end(); ++installTypeIt) {
- installTypes[installTypeIt->second.Index - 1] = &installTypeIt->second;
- }
- std::vector<cmCPackInstallationType*>::iterator installTypeIt2;
- for (installTypeIt2 = installTypes.begin();
- installTypeIt2 != installTypes.end(); ++installTypeIt2) {
+ for (auto& installType : this->InstallationTypes) {
+ installTypes[installType.second.Index - 1] = &installType.second;
+ }
+ for (cmCPackInstallationType* installType : installTypes) {
installTypesCode += "InstType \"";
- installTypesCode += (*installTypeIt2)->DisplayName;
+ installTypesCode += installType->DisplayName;
installTypesCode += "\"\n";
}
// Create installation groups first
- std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
- for (groupIt = this->ComponentGroups.begin();
- groupIt != this->ComponentGroups.end(); ++groupIt) {
- if (groupIt->second.ParentGroup == nullptr) {
+ for (auto& group : this->ComponentGroups) {
+ if (group.second.ParentGroup == nullptr) {
componentCode +=
- this->CreateComponentGroupDescription(&groupIt->second, macrosOut);
+ this->CreateComponentGroupDescription(&group.second, macrosOut);
}
// Add the group description, if any.
- if (!groupIt->second.Description.empty()) {
+ if (!group.second.Description.empty()) {
groupDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" +
- groupIt->first + "} \"" +
- this->TranslateNewlines(groupIt->second.Description) + "\"\n";
+ group.first + "} \"" +
+ this->TranslateNewlines(group.second.Description) + "\"\n";
}
}
// Create the remaining components, which aren't associated with groups.
- std::map<std::string, cmCPackComponent>::iterator compIt;
- for (compIt = this->Components.begin(); compIt != this->Components.end();
- ++compIt) {
- if (compIt->second.Files.empty()) {
+ for (auto& comp : this->Components) {
+ if (comp.second.Files.empty()) {
// NSIS cannot cope with components that have no files.
continue;
}
anyDownloadedComponents =
- anyDownloadedComponents || compIt->second.IsDownloaded;
+ anyDownloadedComponents || comp.second.IsDownloaded;
- if (!compIt->second.Group) {
+ if (!comp.second.Group) {
componentCode +=
- this->CreateComponentDescription(&compIt->second, macrosOut);
+ this->CreateComponentDescription(&comp.second, macrosOut);
}
// Add this component to the various section lists.
sectionList += " !insertmacro \"${MacroName}\" \"";
- sectionList += compIt->first;
+ sectionList += comp.first;
sectionList += "\"\n";
- selectedVarsList += "Var " + compIt->first + "_selected\n";
- selectedVarsList += "Var " + compIt->first + "_was_installed\n";
+ selectedVarsList += "Var " + comp.first + "_selected\n";
+ selectedVarsList += "Var " + comp.first + "_was_installed\n";
// Add the component description, if any.
- if (!compIt->second.Description.empty()) {
+ if (!comp.second.Description.empty()) {
componentDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" +
- compIt->first + "} \"" +
- this->TranslateNewlines(compIt->second.Description) + "\"\n";
+ comp.first + "} \"" +
+ this->TranslateNewlines(comp.second.Description) + "\"\n";
}
}
@@ -463,11 +453,9 @@ int cmCPackNSISGenerator::InitializeInternal()
cmSystemTools::ExpandListArgument(cpackPackageDeskTopLinks,
cpackPackageDesktopLinksVector);
- for (std::vector<std::string>::iterator i =
- cpackPackageDesktopLinksVector.begin();
- i != cpackPackageDesktopLinksVector.end(); ++i) {
+ for (std::string const& cpdl : cpackPackageDesktopLinksVector) {
cmCPackLogger(cmCPackLog::LOG_DEBUG,
- "CPACK_CREATE_DESKTOP_LINKS: " << *i << std::endl);
+ "CPACK_CREATE_DESKTOP_LINKS: " << cpdl << std::endl);
}
} else {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
@@ -647,11 +635,9 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
componentCode += " SectionIn RO\n";
} else if (!component->InstallationTypes.empty()) {
std::ostringstream out;
- std::vector<cmCPackInstallationType*>::iterator installTypeIter;
- for (installTypeIter = component->InstallationTypes.begin();
- installTypeIter != component->InstallationTypes.end();
- ++installTypeIter) {
- out << " " << (*installTypeIter)->Index;
+ for (cmCPackInstallationType const* installType :
+ component->InstallationTypes) {
+ out << " " << installType->Index;
}
componentCode += " SectionIn" + out.str() + "\n";
}
@@ -730,19 +716,17 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
unsigned long totalSize = 0;
{ // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(zipListFileName.c_str());
- std::vector<std::string>::iterator fileIt;
- for (fileIt = component->Files.begin(); fileIt != component->Files.end();
- ++fileIt) {
+ for (std::string const& file : component->Files) {
if (needQuotesInFile) {
out << "\"";
}
- out << *fileIt;
+ out << file;
if (needQuotesInFile) {
out << "\"";
}
out << std::endl;
- totalSize += cmSystemTools::FileLength(dirName + *fileIt);
+ totalSize += cmSystemTools::FileLength(dirName + file);
}
}
@@ -798,17 +782,14 @@ std::string cmCPackNSISGenerator::CreateComponentDescription(
macrosOut << "!macro Remove_${" << component->Name << "}\n";
macrosOut << " IntCmp $" << component->Name << "_was_installed 0 noremove_"
<< component->Name << "\n";
- std::vector<std::string>::iterator pathIt;
std::string path;
- for (pathIt = component->Files.begin(); pathIt != component->Files.end();
- ++pathIt) {
- path = *pathIt;
+ for (std::string const& pathIt : component->Files) {
+ path = pathIt;
std::replace(path.begin(), path.end(), '/', '\\');
macrosOut << " Delete \"" << componentOutputDir << "\\" << path << "\"\n";
}
- for (pathIt = component->Directories.begin();
- pathIt != component->Directories.end(); ++pathIt) {
- path = *pathIt;
+ for (std::string const& pathIt : component->Directories) {
+ path = pathIt;
std::replace(path.begin(), path.end(), '/', '\\');
macrosOut << " RMDir \"" << componentOutputDir << "\\" << path << "\"\n";
}
@@ -841,17 +822,14 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription(
visited.insert(component);
std::ostringstream out;
- std::vector<cmCPackComponent*>::iterator dependIt;
- for (dependIt = component->Dependencies.begin();
- dependIt != component->Dependencies.end(); ++dependIt) {
+ for (cmCPackComponent* depend : component->Dependencies) {
// Write NSIS code to select this dependency
- out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n";
+ out << " SectionGetFlags ${" << depend->Name << "} $0\n";
out << " IntOp $0 $0 | ${SF_SELECTED}\n";
- out << " SectionSetFlags ${" << (*dependIt)->Name << "} $0\n";
- out << " IntOp $" << (*dependIt)->Name
- << "_selected 0 + ${SF_SELECTED}\n";
+ out << " SectionSetFlags ${" << depend->Name << "} $0\n";
+ out << " IntOp $" << depend->Name << "_selected 0 + ${SF_SELECTED}\n";
// Recurse
- out << CreateSelectionDependenciesDescription(*dependIt, visited).c_str();
+ out << CreateSelectionDependenciesDescription(depend, visited).c_str();
}
return out.str();
@@ -867,19 +845,16 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription(
visited.insert(component);
std::ostringstream out;
- std::vector<cmCPackComponent*>::iterator dependIt;
- for (dependIt = component->ReverseDependencies.begin();
- dependIt != component->ReverseDependencies.end(); ++dependIt) {
+ for (cmCPackComponent* depend : component->ReverseDependencies) {
// Write NSIS code to deselect this dependency
- out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n";
+ out << " SectionGetFlags ${" << depend->Name << "} $0\n";
out << " IntOp $1 ${SF_SELECTED} ~\n";
out << " IntOp $0 $0 & $1\n";
- out << " SectionSetFlags ${" << (*dependIt)->Name << "} $0\n";
- out << " IntOp $" << (*dependIt)->Name << "_selected 0 + 0\n";
+ out << " SectionSetFlags ${" << depend->Name << "} $0\n";
+ out << " IntOp $" << depend->Name << "_selected 0 + 0\n";
// Recurse
- out
- << CreateDeselectionDependenciesDescription(*dependIt, visited).c_str();
+ out << CreateDeselectionDependenciesDescription(depend, visited).c_str();
}
return out.str();
@@ -903,20 +878,16 @@ std::string cmCPackNSISGenerator::CreateComponentGroupDescription(
code += "\"" + group->DisplayName + "\" " + group->Name + "\n";
}
- std::vector<cmCPackComponentGroup*>::iterator groupIt;
- for (groupIt = group->Subgroups.begin(); groupIt != group->Subgroups.end();
- ++groupIt) {
- code += this->CreateComponentGroupDescription(*groupIt, macrosOut);
+ for (cmCPackComponentGroup* g : group->Subgroups) {
+ code += this->CreateComponentGroupDescription(g, macrosOut);
}
- std::vector<cmCPackComponent*>::iterator comp;
- for (comp = group->Components.begin(); comp != group->Components.end();
- ++comp) {
- if ((*comp)->Files.empty()) {
+ for (cmCPackComponent* comp : group->Components) {
+ if (comp->Files.empty()) {
continue;
}
- code += this->CreateComponentDescription(*comp, macrosOut);
+ code += this->CreateComponentDescription(comp, macrosOut);
}
code += "SectionGroupEnd\n";
return code;
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index c541614..3d7fd3c 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -6,7 +6,6 @@
#include <sstream>
#include <stdio.h>
#include <string>
-#include <vector>
#include "cmCPackGenerator.h"
#include "cmCPackLog.h"
@@ -48,9 +47,8 @@ int cmCPackSTGZGenerator::PackageFiles()
* have generated several packages (component packaging)
* so we must iterate over generated packages.
*/
- for (std::vector<std::string>::iterator it = packageFileNames.begin();
- it != packageFileNames.end(); ++it) {
- retval &= cmSystemTools::SetPermissions((*it).c_str(),
+ for (std::string const& pfn : packageFileNames) {
+ retval &= cmSystemTools::SetPermissions(pfn.c_str(),
#if defined(_MSC_VER) || defined(__MINGW32__)
S_IREAD | S_IWRITE | S_IEXEC
#else
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 9970721..ca904a2 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -293,10 +293,8 @@ int main(int argc, char const* const* argv)
cpackProjectDirectory.c_str());
}
}
- cpackDefinitions::MapType::iterator cdit;
- for (cdit = definitions.Map.begin(); cdit != definitions.Map.end();
- ++cdit) {
- globalMF->AddDefinition(cdit->first, cdit->second.c_str());
+ for (auto const& cd : definitions.Map) {
+ globalMF->AddDefinition(cd.first, cd.second.c_str());
}
const char* cpackModulesPath =
@@ -311,9 +309,7 @@ int main(int argc, char const* const* argv)
} else {
std::vector<std::string> generatorsVector;
cmSystemTools::ExpandListArgument(genList, generatorsVector);
- std::vector<std::string>::iterator it;
- for (it = generatorsVector.begin(); it != generatorsVector.end(); ++it) {
- const char* gen = it->c_str();
+ for (std::string const& gen : generatorsVector) {
cmMakefile::ScopePushPop raii(globalMF.get());
cmMakefile* mf = globalMF.get();
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
@@ -413,12 +409,10 @@ int main(int argc, char const* const* argv)
doc.PrependSection("Options", cmDocumentationOptions);
std::vector<cmDocumentationEntry> v;
- cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
- for (generatorIt = generators.GetGeneratorsList().begin();
- generatorIt != generators.GetGeneratorsList().end(); ++generatorIt) {
+ for (auto const& g : generators.GetGeneratorsList()) {
cmDocumentationEntry e;
- e.Name = generatorIt->first;
- e.Brief = generatorIt->second;
+ e.Name = g.first;
+ e.Brief = g.second;
v.push_back(e);
}
doc.SetSection("Generators", v);