Replace BOOST_FOREACH by C++ 11 for range loop.

This commit is contained in:
gallaert 2020-04-09 21:15:39 +01:00 committed by James Turner
parent 825d93423d
commit c9a4c0dac1
20 changed files with 230 additions and 266 deletions

View File

@ -22,12 +22,11 @@
#include <simgear_config.h>
#include <simgear/debug/BufferedLogCallback.hxx>
#include <boost/foreach.hpp>
#include <simgear/sg_inlines.h>
#include <simgear/threads/SGThread.hxx>
#include <cstdlib> // for malloc
#include <cstring>
#include <mutex>
namespace simgear
@ -52,7 +51,7 @@ BufferedLogCallback::BufferedLogCallback(sgDebugClass c, sgDebugPriority p) :
BufferedLogCallback::~BufferedLogCallback()
{
BOOST_FOREACH(unsigned char* msg, d->m_buffer) {
for (auto msg : d->m_buffer) {
free(msg);
}
}

View File

@ -24,14 +24,13 @@
#include "logstream.hxx"
#include <cstring>
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <mutex>
#include <boost/foreach.hpp>
#include <simgear/sg_inlines.h>
#include <simgear/threads/SGThread.hxx>
#include <simgear/threads/SGQueue.hxx>
@ -532,7 +531,7 @@ public:
PauseThread pause(this);
m_logPriority = p;
m_logClass = c;
BOOST_FOREACH(simgear::LogCallback* cb, m_consoleCallbacks) {
for (auto cb : m_consoleCallbacks) {
cb->setLogLevels(c, p);
}
}

View File

@ -35,7 +35,6 @@
#include <stdexcept>
#include <mutex>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <simgear/simgear_config.h>

View File

@ -5,8 +5,6 @@
#include <signal.h>
#include <iostream>
#include <boost/foreach.hpp>
#include <simgear/io/sg_file.hxx>
#include <simgear/io/HTTPClient.hxx>
@ -123,7 +121,7 @@ int main(int argc, char* argv[])
}
ARequest* req = new ARequest(url);
BOOST_FOREACH(string h, headers) {
for (const auto& h : headers) {
req->addHeader(h);
}

View File

@ -41,7 +41,6 @@
#include <simgear/misc/strutils.hxx>
#include <simgear/debug/logstream.hxx>
#include <boost/foreach.hpp>
#include <cstring>
#include <cstdlib>
@ -359,7 +358,7 @@ bool Dir::removeChildren() const
bool ok;
PathList cs = children(NO_DOT_OR_DOTDOT | INCLUDE_HIDDEN | TYPE_FILE | TYPE_DIR);
BOOST_FOREACH(SGPath path, cs) {
for (auto path : cs) {
if (path.isDir()) {
Dir childDir(path);
ok = childDir.remove(true);

View File

@ -18,7 +18,6 @@
#include <simgear_config.h>
#include <simgear/package/Catalog.hxx>
#include <boost/foreach.hpp>
#include <algorithm>
#include <fstream>
#include <cstring>
@ -299,7 +298,7 @@ PackageList
Catalog::packagesMatching(const SGPropertyNode* aFilter) const
{
PackageList r;
BOOST_FOREACH(PackageRef p, m_packages) {
for (auto p : m_packages) {
if (p->matches(aFilter)) {
r.push_back(p);
}
@ -311,7 +310,7 @@ PackageList
Catalog::packagesNeedingUpdate() const
{
PackageList r;
BOOST_FOREACH(PackageRef p, m_packages) {
for (auto p : m_packages) {
if (!p->isInstalled()) {
continue;
}
@ -327,7 +326,7 @@ PackageList
Catalog::installedPackages() const
{
PackageList r;
BOOST_FOREACH(PackageRef p, m_packages) {
for (auto p : m_packages) {
if (p->isInstalled()) {
r.push_back(p);
}

View File

@ -20,7 +20,6 @@
#include <simgear/package/Package.hxx>
#include <cassert>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/case_conv.hpp>
#include <simgear/debug/logstream.hxx>
@ -369,7 +368,7 @@ PackageList Package::dependencies() const
{
PackageList result;
BOOST_FOREACH(SGPropertyNode* dep, m_props->getChildren("depends")) {
for (auto dep : m_props->getChildren("depends")) {
std::string depName = dep->getStringValue("id");
unsigned int rev = dep->getIntValue("revision", 0);
@ -410,7 +409,7 @@ std::string Package::nameForVariant(const std::string& vid) const
return name();
}
BOOST_FOREACH(SGPropertyNode* var, m_props->getChildren("variant")) {
for (auto var : m_props->getChildren("variant")) {
if (vid == var->getStringValue("id")) {
return var->getStringValue("name");
}

View File

@ -19,7 +19,6 @@
#include <simgear/package/Root.hxx>
#include <boost/foreach.hpp>
#include <cstring>
#include <map>
#include <deque>
@ -349,7 +348,7 @@ unsigned int Root::maxAgeSeconds() const
void Root::setHTTPClient(HTTP::Client* aHTTP)
{
d->http = aHTTP;
BOOST_FOREACH(HTTP::Request_ptr req, d->httpPendingRequests) {
for (auto req : d->httpPendingRequests) {
d->http->makeRequest(req);
}

View File

@ -24,7 +24,6 @@
#include <simgear/package/Root.hxx>
#include <simgear/misc/sg_dir.hxx>
#include <boost/foreach.hpp>
#include <iostream>
#include <cstring>
@ -98,7 +97,7 @@ void printPackageInfo(pkg::Package* pkg)
if (pkg->properties()->hasChild("author")) {
cout << "Authors:" << endl;
BOOST_FOREACH(SGPropertyNode* author, pkg->properties()->getChildren("author")) {
for (auto author : pkg->properties()->getChildren("author")) {
if (author->hasChild("name")) {
cout << "\t" << author->getStringValue("name") << endl;
@ -174,7 +173,7 @@ int main(int argc, char** argv)
pkg->install()->uninstall();
} else if (!strcmp(argv[1], "update-all")) {
pkg::PackageList updates = root->packagesNeedingUpdate();
BOOST_FOREACH(pkg::Package* p, updates) {
for (auto p : updates) {
root->scheduleToUpdate(p->install());
}
} else if (!strcmp(argv[1], "list-updated")) {
@ -185,7 +184,7 @@ int main(int argc, char** argv)
}
cout << updates.size() << " packages have updates" << endl;
BOOST_FOREACH(pkg::Package* p, updates) {
for (auto p : updates) {
cout << "\t" << p->id() << " " << p->getLocalisedProp("name") << endl;
}
} else if (!strcmp(argv[1], "info")) {

View File

@ -21,8 +21,6 @@
#include "PropertyBasedMgr.hxx"
#include <boost/foreach.hpp>
#include <stdexcept>
#include <string>
@ -78,7 +76,7 @@ namespace simgear
if( name.empty() )
return PropertyBasedElementPtr();
BOOST_FOREACH(PropertyBasedElementPtr el, _elements)
for (auto el : _elements)
if( el && el->getProps()->getStringValue("name") == name )
return el;

View File

@ -22,8 +22,6 @@
#include <fstream>
#include <limits>
#include <boost/foreach.hpp>
#include <cpl_conv.h> // for CPLMalloc()
#include "ogr_spatialref.h"

View File

@ -34,8 +34,6 @@
#include <iomanip>
#include <fstream>
#include <boost/foreach.hpp>
#include <cpl_conv.h> // for CPLMalloc()
#include "ogr_spatialref.h"

View File

@ -36,7 +36,6 @@
#include <mutex>
#include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <boost/functional/hash.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
@ -261,8 +260,7 @@ int Effect::getGenerator(Effect::Generator what) const
Technique* Effect::chooseTechnique(RenderInfo* info, const std::string &scheme)
{
BOOST_FOREACH(ref_ptr<Technique>& technique, techniques)
{
for (auto& technique : techniques) {
if (technique->valid(info) == Technique::VALID &&
technique->getScheme() == scheme)
return technique.get();
@ -272,16 +270,14 @@ Technique* Effect::chooseTechnique(RenderInfo* info, const std::string &scheme)
void Effect::resizeGLObjectBuffers(unsigned int maxSize)
{
BOOST_FOREACH(const ref_ptr<Technique>& technique, techniques)
{
for (const auto& technique : techniques) {
technique->resizeGLObjectBuffers(maxSize);
}
}
void Effect::releaseGLObjects(osg::State* state) const
{
BOOST_FOREACH(const ref_ptr<Technique>& technique, techniques)
{
for (const auto& technique : techniques) {
technique->releaseGLObjects(state);
}
}
@ -929,8 +925,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
// resolvedProgramMap for a program using those shaders.
ProgramKey resolvedKey;
resolvedKey.attributes = prgKey.attributes;
BOOST_FOREACH(const ShaderKey& shaderKey, prgKey.shaders)
{
for (const auto& shaderKey : prgKey.shaders) {
// FIXME orig: const string& shaderName = shaderKey.first;
string shaderName = shaderKey.first;
Shader::Type stype = (Shader::Type)shaderKey.second;
@ -957,8 +952,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
return;
}
program = new Program;
BOOST_FOREACH(const ShaderKey& skey, resolvedKey.shaders)
{
for (const auto& skey : resolvedKey.shaders) {
const string& fileName = skey.first;
Shader::Type stype = (Shader::Type)skey.second;
ShaderMap::iterator sitr = shaderMap.find(skey);
@ -973,7 +967,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass,
}
}
}
BOOST_FOREACH(const ProgramKey::AttribKey& key, prgKey.attributes) {
for (const auto& key : prgKey.attributes) {
program->addBindAttribLocation(key.first, key.second);
}
const SGPropertyNode* pGeometryVerticesOut
@ -1551,7 +1545,7 @@ bool Effect_writeLocalData(const Object& obj, osgDB::Output& fw)
const Effect& effect = static_cast<const Effect&>(obj);
fw.indent() << "techniques " << effect.techniques.size() << "\n";
BOOST_FOREACH(const ref_ptr<Technique>& technique, effect.techniques) {
for (const auto& technique : effect.techniques) {
fw.writeObject(*technique);
}
return true;

View File

@ -7,8 +7,6 @@
#include "Pass.hxx"
#include "EffectCullVisitor.hxx"
#include <boost/foreach.hpp>
#include <iterator>
#include <vector>
#include <string>
@ -177,8 +175,7 @@ Technique::processDrawables(const EffectGeode::DrawablesIterator& begin,
}
EffectCullVisitor* ecv = dynamic_cast<EffectCullVisitor*>( cv );
EffectGeode::DrawablesIterator drawablesEnd = itr;
BOOST_FOREACH(ref_ptr<Pass>& pass, passes)
{
for (auto& pass : passes) {
osg::ref_ptr<osg::StateSet> ss = pass;
if (ecv && ( ! pass->getBufferUnitList().empty() || ! pass->getPositionedUniformMap().empty() ) ) {
ss = static_cast<osg::StateSet*>(
@ -220,7 +217,7 @@ void Technique::resizeGLObjectBuffers(unsigned int maxSize)
{
if (_shadowingStateSet.valid())
_shadowingStateSet->resizeGLObjectBuffers(maxSize);
BOOST_FOREACH(ref_ptr<Pass>& pass, passes) {
for (auto& pass : passes) {
pass->resizeGLObjectBuffers(maxSize);
}
_contextMap.resize(maxSize);
@ -230,8 +227,7 @@ void Technique::releaseGLObjects(osg::State* state) const
{
if (_shadowingStateSet.valid())
_shadowingStateSet->releaseGLObjects(state);
BOOST_FOREACH(const ref_ptr<Pass>& pass, passes)
{
for (const auto& pass : passes) {
pass->releaseGLObjects(state);
}
if (state == 0) {
@ -444,7 +440,7 @@ bool Technique_writeLocalData(const Object& obj, osgDB::Output& fw)
fw.writeObject(*tniq.getShadowingStateSet());
}
fw.indent() << "num_passes " << tniq.passes.size() << "\n";
BOOST_FOREACH(const ref_ptr<Pass>& pass, tniq.passes) {
for (const auto& pass : tniq.passes) {
fw.writeObject(*pass);
}
return true;

View File

@ -33,7 +33,6 @@
#include <string>
#include <mutex>
#include <boost/foreach.hpp>
#include "mat.hxx"
#include <osg/CullFace>
@ -520,8 +519,7 @@ void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options)
makeChild(binProp, "bin-number")->setIntValue(TRANSPARENT_BIN);
makeChild(binProp, "bin-name")->setStringValue("DepthSortedBin");
}
BOOST_FOREACH(_internal_state& matState, _status)
{
for (auto& matState : _status) {
SGPropertyNode_ptr effectProp = new SGPropertyNode();
copyProperties(propRoot, effectProp);
SGPropertyNode* effectParamProp = effectProp->getChild("parameters", 0);

View File

@ -34,7 +34,6 @@
#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <boost/scoped_array.hpp>
#include <boost/foreach.hpp>
typedef std::map<std::string, osg::observer_ptr<simgear::Effect> > EffectMap;
static EffectMap lightEffectMap;
@ -68,8 +67,8 @@ public:
params->getNode("ambient")->setValue(_ambient * dim);
params->getNode("diffuse")->setValue(_diffuse * dim);
params->getNode("specular")->setValue(_specular * dim);
BOOST_FOREACH(osg::ref_ptr<simgear::Technique> & technique, effect->techniques) {
BOOST_FOREACH(osg::ref_ptr<simgear::Pass> & pass, technique->passes) {
for (auto& technique : effect->techniques) {
for (auto& pass : technique->passes) {
osg::Uniform* amb = pass->getUniform("Ambient");
if (amb)
amb->set(osg::Vec4f(_ambient.x() * dim, _ambient.y() * dim, _ambient.z() * dim, _ambient.w() * dim));

View File

@ -9,8 +9,6 @@
#include <utility>
#include <boost/foreach.hpp>
#include <osg/ref_ptr>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
@ -349,7 +347,7 @@ ref_ptr<Node> instantiateEffects(osg::Node* modelGroup,
SGPropertyNode* defaultNode = configNode->getChild("default");
if (defaultNode && defaultNode->getValue<bool>())
defaultEffectPropRoot = configNode;
BOOST_FOREACH(SGPropertyNode_ptr objNameNode, objectNames) {
for (auto objNameNode : objectNames) {
emap.insert(make_pair(objNameNode->getStringValue(), configNode));
}
configNode->removeChild("default");

View File

@ -29,7 +29,6 @@
#include <map>
#include <math.h>
#include <boost/foreach.hpp>
#include <boost/tuple/tuple_comparison.hpp>
#include <osg/Geode>

View File

@ -25,7 +25,6 @@
#endif
#include <vector>
#include <boost/foreach.hpp>
#include <osg/Geode>
#include <osg/Geometry>
@ -242,7 +241,7 @@ public:
void makeFace(const ElementVec& elements, double hpos, const osg::Matrix& xform)
{
BOOST_FOREACH(element_info* element, elements) {
for (auto element : elements) {
GlyphGeometry* gg = getGeometry(element->material->get_effect());
gg->addGlyph(element->glyph, hpos, grounddist, element->abswidth, element->height, xform);
hpos += element->abswidth;
@ -541,4 +540,3 @@ void AirportSignBuilder::addSign(const SGGeod& pos, double heading, const std::s
}
} // of namespace simgear

View File

@ -11,7 +11,6 @@
# include <simgear_config.h>
#endif
#include <boost/foreach.hpp>
#include <simgear/compiler.h>
#include "SGBinding.hxx"
@ -132,14 +131,14 @@ SGBinding::fire (double setting) const
void fireBindingList(const SGBindingList& aBindings, SGPropertyNode* params)
{
BOOST_FOREACH(SGBinding_ptr b, aBindings) {
for (auto b : aBindings) {
b->fire(params);
}
}
void fireBindingListWithOffset(const SGBindingList& aBindings, double offset, double max)
{
BOOST_FOREACH(SGBinding_ptr b, aBindings) {
for (auto b : aBindings) {
b->fire(offset, max);
}
}
@ -147,7 +146,7 @@ void fireBindingListWithOffset(const SGBindingList& aBindings, double offset, do
SGBindingList readBindingList(const simgear::PropertyList& aNodes, SGPropertyNode* aRoot)
{
SGBindingList result;
BOOST_FOREACH(SGPropertyNode* node, aNodes) {
for (auto node : aNodes) {
result.push_back(new SGBinding(node, aRoot));
}
@ -156,7 +155,7 @@ SGBindingList readBindingList(const simgear::PropertyList& aNodes, SGPropertyNod
void clearBindingList(const SGBindingList& aBindings)
{
BOOST_FOREACH(SGBinding_ptr b, aBindings) {
for (auto b : aBindings) {
b->clear();
}
}
@ -167,7 +166,7 @@ bool anyBindingEnabled(const SGBindingList& aBindings)
return false;
}
BOOST_FOREACH(SGBinding_ptr b, aBindings) {
for (auto b : aBindings) {
if (b->test()) {
return true;
}
@ -175,4 +174,3 @@ bool anyBindingEnabled(const SGBindingList& aBindings)
return false;
}