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/WiX | |
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/WiX')
-rw-r--r-- | Source/CPack/WiX/cmCPackWIXGenerator.cxx | 51 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXAccessControlList.cxx | 8 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx | 12 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXPatch.cxx | 23 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXPatchParser.cxx | 4 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXShortcut.cxx | 16 | ||||
-rw-r--r-- | Source/CPack/WiX/cmWIXSourceWriter.cxx | 4 |
7 files changed, 44 insertions, 74 deletions
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 += "<"; |