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/QtDialog | |
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/QtDialog')
-rw-r--r-- | Source/QtDialog/FirstConfigure.cxx | 23 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 33 |
2 files changed, 26 insertions, 30 deletions
diff --git a/Source/QtDialog/FirstConfigure.cxx b/Source/QtDialog/FirstConfigure.cxx index f28e1a8..364a378 100644 --- a/Source/QtDialog/FirstConfigure.cxx +++ b/Source/QtDialog/FirstConfigure.cxx @@ -95,33 +95,32 @@ void StartCompilerSetup::setGenerators( QStringList generator_list; - std::vector<cmake::GeneratorInfo>::const_iterator it; - for (it = gens.begin(); it != gens.end(); ++it) { - generator_list.append(QString::fromLocal8Bit(it->name.c_str())); + for (cmake::GeneratorInfo const& gen : gens) { + generator_list.append(QString::fromLocal8Bit(gen.name.c_str())); - if (it->supportsPlatform) { + if (gen.supportsPlatform) { this->GeneratorsSupportingPlatform.append( - QString::fromLocal8Bit(it->name.c_str())); + QString::fromLocal8Bit(gen.name.c_str())); this - ->GeneratorDefaultPlatform[QString::fromLocal8Bit(it->name.c_str())] = - QString::fromLocal8Bit(it->defaultPlatform.c_str()); + ->GeneratorDefaultPlatform[QString::fromLocal8Bit(gen.name.c_str())] = + QString::fromLocal8Bit(gen.defaultPlatform.c_str()); std::vector<std::string>::const_iterator platformIt = - it->supportedPlatforms.cbegin(); - while (platformIt != it->supportedPlatforms.cend()) { + gen.supportedPlatforms.cbegin(); + while (platformIt != gen.supportedPlatforms.cend()) { this->GeneratorSupportedPlatforms.insert( - QString::fromLocal8Bit(it->name.c_str()), + QString::fromLocal8Bit(gen.name.c_str()), QString::fromLocal8Bit((*platformIt).c_str())); platformIt++; } } - if (it->supportsToolset) { + if (gen.supportsToolset) { this->GeneratorsSupportingToolset.append( - QString::fromLocal8Bit(it->name.c_str())); + QString::fromLocal8Bit(gen.name.c_str())); } } diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index a073c30..bf7726e 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -48,9 +48,8 @@ QCMake::QCMake(QObject* p) this->CMakeInstance->GetRegisteredGenerators( generators, /*includeNamesWithPlatform=*/false); - std::vector<cmake::GeneratorInfo>::const_iterator it; - for (it = generators.begin(); it != generators.end(); ++it) { - this->AvailableGenerators.push_back(*it); + for (cmake::GeneratorInfo const& gen : generators) { + this->AvailableGenerators.push_back(gen); } } @@ -234,24 +233,23 @@ void QCMake::setProperties(const QCMakePropertyList& newProps) // set the value of properties cmState* state = this->CMakeInstance->GetState(); std::vector<std::string> cacheKeys = state->GetCacheEntryKeys(); - for (std::vector<std::string>::const_iterator it = cacheKeys.begin(); - it != cacheKeys.end(); ++it) { - cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*it); + for (std::string const& key : cacheKeys) { + cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key); if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC) { continue; } QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(it->c_str()); + prop.Key = QString::fromLocal8Bit(key.c_str()); int idx = props.indexOf(prop); if (idx == -1) { - toremove.append(QString::fromLocal8Bit(it->c_str())); + toremove.append(QString::fromLocal8Bit(key.c_str())); } else { prop = props[idx]; if (prop.Value.type() == QVariant::Bool) { - state->SetCacheEntryValue(*it, prop.Value.toBool() ? "ON" : "OFF"); + state->SetCacheEntryValue(key, prop.Value.toBool() ? "ON" : "OFF"); } else { - state->SetCacheEntryValue(*it, + state->SetCacheEntryValue(key, prop.Value.toString().toLocal8Bit().data()); } props.removeAt(idx); @@ -297,22 +295,21 @@ QCMakePropertyList QCMake::properties() const cmState* state = this->CMakeInstance->GetState(); std::vector<std::string> cacheKeys = state->GetCacheEntryKeys(); - for (std::vector<std::string>::const_iterator i = cacheKeys.begin(); - i != cacheKeys.end(); ++i) { - cmStateEnums::CacheEntryType t = state->GetCacheEntryType(*i); + for (std::string const& key : cacheKeys) { + cmStateEnums::CacheEntryType t = state->GetCacheEntryType(key); if (t == cmStateEnums::INTERNAL || t == cmStateEnums::STATIC || t == cmStateEnums::UNINITIALIZED) { continue; } - const char* cachedValue = state->GetCacheEntryValue(*i); + const char* cachedValue = state->GetCacheEntryValue(key); QCMakeProperty prop; - prop.Key = QString::fromLocal8Bit(i->c_str()); + prop.Key = QString::fromLocal8Bit(key.c_str()); prop.Help = - QString::fromLocal8Bit(state->GetCacheEntryProperty(*i, "HELPSTRING")); + QString::fromLocal8Bit(state->GetCacheEntryProperty(key, "HELPSTRING")); prop.Value = QString::fromLocal8Bit(cachedValue); - prop.Advanced = state->GetCacheEntryPropertyAsBool(*i, "ADVANCED"); + prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED"); if (t == cmStateEnums::BOOL) { prop.Type = QCMakeProperty::BOOL; prop.Value = cmSystemTools::IsOn(cachedValue); @@ -323,7 +320,7 @@ QCMakePropertyList QCMake::properties() const } else if (t == cmStateEnums::STRING) { prop.Type = QCMakeProperty::STRING; const char* stringsProperty = - state->GetCacheEntryProperty(*i, "STRINGS"); + state->GetCacheEntryProperty(key, "STRINGS"); if (stringsProperty) { prop.Strings = QString::fromLocal8Bit(stringsProperty).split(";"); } |