summaryrefslogtreecommitdiff
path: root/Source/cmSourceGroupCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-09-13 12:34:49 +0000
committerKitware Robot <kwrobot@kitware.com>2017-09-13 08:35:05 -0400
commit67810849b95acfe036a9a605dbda6f0a3d6f7493 (patch)
treefa63356603dd00956f306eb92d4ecdbca9e450d4 /Source/cmSourceGroupCommand.cxx
parenta763cffd6b65bbe5572527e39969981bf31d5aca (diff)
parent7d5095796ab616cf9b709036387bb95ab9984141 (diff)
downloadcmake-67810849b95acfe036a9a605dbda6f0a3d6f7493.tar.gz
Merge topic 'ranged-for'
7d509579 Meta: modernize old-fashioned loops to range-based `for`. Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1249
Diffstat (limited to 'Source/cmSourceGroupCommand.cxx')
-rw-r--r--Source/cmSourceGroupCommand.cxx21
1 files changed, 10 insertions, 11 deletions
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 890109e5ff..69983a8756 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -41,8 +41,8 @@ std::set<std::string> getSourceGroupFilesPaths(
std::set<std::string> ret;
const std::string::size_type rootLength = root.length();
- for (size_t i = 0; i < files.size(); ++i) {
- ret.insert(files[i].substr(rootLength + 1)); // +1 to also omnit last '/'
+ for (std::string const& file : files) {
+ ret.insert(file.substr(rootLength + 1)); // +1 to also omnit last '/'
}
return ret;
@@ -51,9 +51,9 @@ std::set<std::string> getSourceGroupFilesPaths(
bool rootIsPrefix(const std::string& root,
const std::vector<std::string>& files, std::string& error)
{
- for (size_t i = 0; i < files.size(); ++i) {
- if (!cmSystemTools::StringStartsWith(files[i], root.c_str())) {
- error = "ROOT: " + root + " is not a prefix of file: " + files[i];
+ for (std::string const& file : files) {
+ if (!cmSystemTools::StringStartsWith(file, root.c_str())) {
+ error = "ROOT: " + root + " is not a prefix of file: " + file;
return false;
}
}
@@ -91,14 +91,13 @@ bool addFilesToItsSourceGroups(const std::string& root,
{
cmSourceGroup* sg;
- for (std::set<std::string>::const_iterator it = sgFilesPaths.begin();
- it != sgFilesPaths.end(); ++it) {
+ for (std::string const& sgFilesPath : sgFilesPaths) {
std::vector<std::string> tokenizedPath;
if (!prefix.empty()) {
- tokenizedPath = tokenizePath(prefix + '/' + *it);
+ tokenizedPath = tokenizePath(prefix + '/' + sgFilesPath);
} else {
- tokenizedPath = tokenizePath(*it);
+ tokenizedPath = tokenizePath(sgFilesPath);
}
if (tokenizedPath.size() > 1) {
@@ -107,10 +106,10 @@ bool addFilesToItsSourceGroups(const std::string& root,
sg = makefile.GetOrCreateSourceGroup(tokenizedPath);
if (!sg) {
- errorMsg = "Could not create source group for file: " + *it;
+ errorMsg = "Could not create source group for file: " + sgFilesPath;
return false;
}
- const std::string fullPath = getFullFilePath(root, *it);
+ const std::string fullPath = getFullFilePath(root, sgFilesPath);
sg->AddGroupFile(fullPath);
}
}