diff options
author | Artur Ryt <artur.ryt@gmail.com> | 2019-02-07 21:39:05 (GMT) |
---|---|---|
committer | Artur Ryt <artur.ryt@gmail.com> | 2019-02-07 21:39:05 (GMT) |
commit | 01b2d6ab7465e7f22fb821876027df86b0c8f363 (patch) | |
tree | 7ae313670e3655269ef7f9db6feabdc4bb2aaf25 /Source/CPack | |
parent | 15bdbec0176e3aa620bb5bda3631819c5ca18eaf (diff) | |
download | CMake-01b2d6ab7465e7f22fb821876027df86b0c8f363.zip CMake-01b2d6ab7465e7f22fb821876027df86b0c8f363.tar.gz CMake-01b2d6ab7465e7f22fb821876027df86b0c8f363.tar.bz2 |
Modernize: Use ranged for-loops when possible
Replaced most manual `const_iterator`-based loops and some
reverse-iterator loops with range loops.
Fixes: #18858
Diffstat (limited to 'Source/CPack')
-rw-r--r-- | Source/CPack/cmCPackCygwinBinaryGenerator.cxx | 5 | ||||
-rw-r--r-- | Source/CPack/cmCPackPKGGenerator.cxx | 54 |
2 files changed, 22 insertions, 37 deletions
diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index 2119f78..49a9f15 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -44,10 +44,9 @@ int cmCPackCygwinBinaryGenerator::PackageFiles() // to create the file before the super class is called { cmGeneratedFileStream ofs(manifestFile.c_str()); - for (std::vector<std::string>::const_iterator i = files.begin(); - i != files.end(); ++i) { + for (std::string const& file : files) { // remove the temp dir and replace with /usr - ofs << (*i).substr(tempdir.size()) << "\n"; + ofs << file.substr(tempdir.size()) << "\n"; } ofs << manifest << "\n"; } diff --git a/Source/CPack/cmCPackPKGGenerator.cxx b/Source/CPack/cmCPackPKGGenerator.cxx index ae227aa..d54ab56 100644 --- a/Source/CPack/cmCPackPKGGenerator.cxx +++ b/Source/CPack/cmCPackPKGGenerator.cxx @@ -66,21 +66,17 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile) xout.StartElement("choices-outline"); // Emit the outline for the groups - std::map<std::string, cmCPackComponentGroup>::iterator groupIt; - for (groupIt = this->ComponentGroups.begin(); - groupIt != this->ComponentGroups.end(); ++groupIt) { - if (groupIt->second.ParentGroup == nullptr) { - CreateChoiceOutline(groupIt->second, xout); + for (auto const& group : this->ComponentGroups) { + if (group.second.ParentGroup == nullptr) { + CreateChoiceOutline(group.second, xout); } } // Emit the outline for the non-grouped components - std::map<std::string, cmCPackComponent>::iterator compIt; - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { - if (!compIt->second.Group) { + for (auto const& comp : this->Components) { + if (!comp.second.Group) { xout.StartElement("line"); - xout.Attribute("choice", compIt->first + "Choice"); + xout.Attribute("choice", comp.first + "Choice"); xout.Content(""); // Avoid self-closing tag. xout.EndElement(); } @@ -94,13 +90,11 @@ void cmCPackPKGGenerator::WriteDistributionFile(const char* metapackageFile) xout.EndElement(); // choices-outline> // Create the actual choices - for (groupIt = this->ComponentGroups.begin(); - groupIt != this->ComponentGroups.end(); ++groupIt) { - CreateChoice(groupIt->second, xout); + for (auto const& group : this->ComponentGroups) { + CreateChoice(group.second, xout); } - for (compIt = this->Components.begin(); compIt != this->Components.end(); - ++compIt) { - CreateChoice(compIt->second, xout); + for (auto const& comp : this->Components) { + CreateChoice(comp.second, xout); } if (!this->PostFlightComponent.Name.empty()) { @@ -119,17 +113,13 @@ void cmCPackPKGGenerator::CreateChoiceOutline( { xout.StartElement("line"); xout.Attribute("choice", group.Name + "Choice"); - std::vector<cmCPackComponentGroup*>::const_iterator groupIt; - for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end(); - ++groupIt) { - CreateChoiceOutline(**groupIt, xout); + for (cmCPackComponentGroup* subgroup : group.Subgroups) { + CreateChoiceOutline(*subgroup, xout); } - std::vector<cmCPackComponent*>::const_iterator compIt; - for (compIt = group.Components.begin(); compIt != group.Components.end(); - ++compIt) { + for (cmCPackComponent* comp : group.Components) { xout.StartElement("line"); - xout.Attribute("choice", (*compIt)->Name + "Choice"); + xout.Attribute("choice", comp->Name + "Choice"); xout.Content(""); // Avoid self-closing tag. xout.EndElement(); } @@ -238,11 +228,9 @@ void cmCPackPKGGenerator::AddDependencyAttributes( } visited.insert(&component); - std::vector<cmCPackComponent*>::const_iterator dependIt; - for (dependIt = component.Dependencies.begin(); - dependIt != component.Dependencies.end(); ++dependIt) { - out << " && choices['" << (*dependIt)->Name << "Choice'].selected"; - AddDependencyAttributes(**dependIt, visited, out); + for (cmCPackComponent* depend : component.Dependencies) { + out << " && choices['" << depend->Name << "Choice'].selected"; + AddDependencyAttributes(*depend, visited, out); } } @@ -255,11 +243,9 @@ void cmCPackPKGGenerator::AddReverseDependencyAttributes( } visited.insert(&component); - std::vector<cmCPackComponent*>::const_iterator dependIt; - for (dependIt = component.ReverseDependencies.begin(); - dependIt != component.ReverseDependencies.end(); ++dependIt) { - out << " || choices['" << (*dependIt)->Name << "Choice'].selected"; - AddReverseDependencyAttributes(**dependIt, visited, out); + for (cmCPackComponent* depend : component.ReverseDependencies) { + out << " || choices['" << depend->Name << "Choice'].selected"; + AddReverseDependencyAttributes(*depend, visited, out); } } |