diff options
author | Pavel Solodovnikov <hellyeahdominate@gmail.com> | 2017-09-15 22:04:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-09-19 12:06:08 (GMT) |
commit | f43baf69814176f52b2b229667c4d3e88154bdea (patch) | |
tree | 58d8ff3131b492e71be8feb701a013e28f00dd9c /Source/CPack/IFW | |
parent | c0c5f924fe46fcf83603117689b372cb8520c4bb (diff) | |
download | CMake-f43baf69814176f52b2b229667c4d3e88154bdea.zip CMake-f43baf69814176f52b2b229667c4d3e88154bdea.tar.gz CMake-f43baf69814176f52b2b229667c4d3e88154bdea.tar.bz2 |
Meta: modernize old-fashioned loops to range-based `for` (CPack).
Changes done via `clang-tidy` with some manual fine-tuning
for the variable naming and `auto` type deduction
where appropriate.
Diffstat (limited to 'Source/CPack/IFW')
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.cxx | 29 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.cxx | 10 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.cxx | 77 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWRepository.cxx | 5 |
4 files changed, 48 insertions, 73 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(); } |