From d443ddb053141510311e002c59746a2dd9ba8b16 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 11 Jan 2013 05:40:18 +0000 Subject: Use range-based for loops where possible. Mmm, shiny. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4919 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/BlockModel.cpp | 6 +++--- src/client/ClientStore.cpp | 32 +++++++++++++++----------------- src/client/ObjectModel.cpp | 7 +++---- src/client/PluginModel.cpp | 8 +++----- src/client/PortModel.cpp | 7 +++---- 5 files changed, 27 insertions(+), 33 deletions(-) (limited to 'src/client') diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp index cacba04c..eb982f0d 100644 --- a/src/client/BlockModel.cpp +++ b/src/client/BlockModel.cpp @@ -143,9 +143,9 @@ BlockModel::add_port(SharedPtr pm) SharedPtr BlockModel::get_port(const Raul::Symbol& symbol) const { - for (Ports::const_iterator i = _ports.begin(); i != _ports.end(); ++i) - if ((*i)->symbol() == symbol) - return (*i); + for (auto p : _ports) + if (p->symbol() == symbol) + return p; return SharedPtr(); } diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index a6b011a4..318d31a5 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -93,9 +93,8 @@ ClientStore::add_object(SharedPtr object) } typedef Resource::Properties::const_iterator Iterator; - for (Iterator i = object->properties().begin(); - i != object->properties().end(); ++i) - object->signal_property().emit(i->first, i->second); + for (auto p : object->properties()) + object->signal_property().emit(p.first, p.second); } SharedPtr @@ -217,9 +216,9 @@ ClientStore::put(const Raul::URI& uri, typedef Resource::Properties::const_iterator Iterator; #ifdef INGEN_CLIENT_STORE_DUMP std::cerr << "Put " << uri << " {" << endl; - for (Iterator i = properties.begin(); i != properties.end(); ++i) - std::cerr << '\t' << i->first << " = " << _uris.forge.str(i->second) - << " :: " << i->second.type() << endl; + for (auto p : properties) + std::cerr << '\t' << p.first << " = " << _uris.forge.str(p.second) + << " :: " << p.second.type() << endl; std::cerr << "}" << endl; #endif @@ -313,14 +312,14 @@ ClientStore::delta(const Raul::URI& uri, typedef Resource::Properties::const_iterator iterator; #ifdef INGEN_CLIENT_STORE_DUMP std::cerr << "Delta " << uri << " {" << endl; - for (iterator i = remove.begin(); i != remove.end(); ++i) - std::cerr << " - " << i->first - << " = " << _uris.forge.str(i->second) - << " :: " << i->second.type() << endl; - for (iterator i = add.begin(); i != add.end(); ++i) - std::cerr << " + " << i->first - << " = " << _uris.forge.str(i->second) - << " :: " << i->second.type() << endl; + for (auto r : remove) + std::cerr << " - " << r.first + << " = " << _uris.forge.str(r.second) + << " :: " << r.second.type() << endl; + for (auto a : add) + std::cerr << " + " << a.first + << " = " << _uris.forge.str(a.second) + << " :: " << a.second.type() << endl; std::cerr << "}" << endl; #endif @@ -459,9 +458,8 @@ ClientStore::disconnect_all(const Raul::Path& parent_graph, } const GraphModel::Arcs arcs = graph->arcs(); - for (GraphModel::Arcs::const_iterator i = arcs.begin(); - i != arcs.end(); ++i) { - SharedPtr arc = PtrCast(i->second); + for (auto a : arcs) { + SharedPtr arc = PtrCast(a.second); if (arc->tail()->parent() == object || arc->head()->parent() == object || arc->tail()->path() == path diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 5c2bae00..51427f90 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -79,10 +79,9 @@ ObjectModel::set(SharedPtr o) if (o->_parent) _parent = o->_parent; - for (Properties::const_iterator v = o->properties().begin(); - v != o->properties().end(); ++v) { - Resource::set_property(v->first, v->second); - _signal_property.emit(v->first, v->second); + for (auto v : o->properties()) { + Resource::set_property(v.first, v.second); + _signal_property.emit(v.first, v.second); } } diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 63113e54..8bf7aead 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -159,11 +159,9 @@ PluginModel::set(SharedPtr p) if (p->_lilv_plugin) _lilv_plugin = p->_lilv_plugin; - for (Properties::const_iterator v = p->properties().begin(); - v != p->properties().end(); - ++v) { - Resource::set_property(v->first, v->second); - _signal_property.emit(v->first, v->second); + for (auto v : p->properties()) { + Resource::set_property(v.first, v.second); + _signal_property.emit(v.first, v.second); } _signal_changed.emit(); diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp index e936a1e2..a4261202 100644 --- a/src/client/PortModel.cpp +++ b/src/client/PortModel.cpp @@ -54,10 +54,9 @@ bool PortModel::is_uri() const { // FIXME: Resource::has_property doesn't work, URI != URID - for (Resource::Properties::const_iterator i = properties().begin(); - i != properties().end(); ++i) { - if (i->second.type() == _uris.atom_URID && - static_cast(i->second.get_int32()) == _uris.atom_URID) { + for (auto p : properties()) { + if (p.second.type() == _uris.atom_URID && + static_cast(p.second.get_int32()) == _uris.atom_URID) { return true; } } -- cgit v1.2.1