From 37729e5b314e39fb750a3fb46a005acdb15b4ac2 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 25 Dec 2017 16:37:00 -0500 Subject: Use auto for iterators --- src/ClashAvoider.cpp | 6 +++--- src/Configuration.cpp | 4 ++-- src/Parser.cpp | 2 +- src/Resource.cpp | 6 +++--- src/World.cpp | 4 ++-- src/client/BlockModel.cpp | 4 ++-- src/client/ClientStore.cpp | 6 +++--- src/client/GraphModel.cpp | 8 ++++---- src/client/ObjectModel.cpp | 2 +- src/gui/App.cpp | 6 +++--- src/gui/GraphCanvas.cpp | 4 ++-- src/gui/PluginMenu.cpp | 2 +- src/gui/Port.cpp | 3 +-- src/gui/PropertiesWindow.cpp | 4 ++-- src/gui/RDFS.cpp | 2 +- src/gui/WindowFactory.cpp | 18 +++++++++--------- src/server/BlockFactory.cpp | 4 ++-- src/server/DuplexPort.cpp | 3 +-- src/server/GraphImpl.cpp | 8 ++++---- src/server/NodeImpl.cpp | 2 +- src/server/events/CreateBlock.cpp | 2 +- src/server/events/Delete.cpp | 2 +- src/server/events/Disconnect.cpp | 4 ++-- src/server/ingen_lv2.cpp | 2 +- 24 files changed, 53 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp index acfdab4e..3ec3a12d 100644 --- a/src/ClashAvoider.cpp +++ b/src/ClashAvoider.cpp @@ -59,7 +59,7 @@ ClashAvoider::map_path(const Raul::Path& in) Raul::Path base_path(base_path_str); - SymbolMap::iterator m = _symbol_map.find(in); + auto m = _symbol_map.find(in); if (m != _symbol_map.end()) { return m->second; } else { @@ -68,7 +68,7 @@ ClashAvoider::map_path(const Raul::Path& in) // See if parent is mapped Raul::Path parent = in.parent(); do { - SymbolMap::iterator p = _symbol_map.find(parent); + auto p = _symbol_map.find(parent); if (p != _symbol_map.end()) { const Raul::Path mapped = Raul::Path( p->second.base() + in.substr(parent.base().length())); @@ -87,7 +87,7 @@ ClashAvoider::map_path(const Raul::Path& in) } else { // Append _2 _3 etc until an unused symbol is found while (true) { - Offsets::iterator o = _offsets.find(base_path); + auto o = _offsets.find(base_path); if (o != _offsets.end()) { offset = ++o->second; } else { diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 3e7b13ba..a65967b5 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -372,7 +372,7 @@ const Atom& Configuration::option(const std::string& long_name) const { static const Atom nil; - Options::const_iterator o = _options.find(long_name); + auto o = _options.find(long_name); if (o == _options.end()) { return nil; } else { @@ -383,7 +383,7 @@ Configuration::option(const std::string& long_name) const bool Configuration::set(const std::string& long_name, const Atom& value) { - Options::iterator o = _options.find(long_name); + auto o = _options.find(long_name); if (o != _options.end()) { o->second.value = value; return true; diff --git a/src/Parser.cpp b/src/Parser.cpp index ed130e94..d3b139af 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -588,7 +588,7 @@ parse(Ingen::World* world, const Sord::Node& rdf_class = i.get_object(); assert(rdf_class.is_uri()); - Subjects::iterator s = subjects.find(subject); + auto s = subjects.find(subject); if (s == subjects.end()) { std::set types; types.insert(rdf_class); diff --git a/src/Resource.cpp b/src/Resource.cpp index ae44723c..5d980f8e 100644 --- a/src/Resource.cpp +++ b/src/Resource.cpp @@ -56,9 +56,9 @@ Resource::set_property(const Raul::URI& uri, Resource::Graph ctx) { // Erase existing property in this context - for (Properties::iterator i = _properties.find(uri); + for (auto i = _properties.find(uri); (i != _properties.end()) && (i->first == uri);) { - Properties::iterator next = i; + auto next = i; ++next; if (i->second.context() == ctx) { const Atom value(i->second); @@ -94,7 +94,7 @@ Resource::remove_property(const Raul::URI& uri, const Atom& value) if (_uris.patch_wildcard == value) { _properties.erase(uri); } else { - for (Properties::iterator i = _properties.find(uri); + for (auto i = _properties.find(uri); i != _properties.end() && (i->first == uri); ++i) { if (i->second == value) { diff --git a/src/World.cpp b/src/World.cpp index 3c9a94db..84202244 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -274,7 +274,7 @@ URIMap& World::uri_map() { return *_impl->uri_map; } bool World::load_module(const char* name) { - Impl::Modules::iterator i = _impl->modules.find(name); + auto i = _impl->modules.find(name); if (i != _impl->modules.end()) { return true; } @@ -299,7 +299,7 @@ World::load_module(const char* name) bool World::run_module(const char* name) { - Impl::Modules::iterator i = _impl->modules.find(name); + auto i = _impl->modules.find(name); if (i == _impl->modules.end()) { log().error(fmt("Attempt to run unloaded module `%1%'\n") % name); return false; diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp index 95819c1e..cf778408 100644 --- a/src/client/BlockModel.cpp +++ b/src/client/BlockModel.cpp @@ -67,7 +67,7 @@ BlockModel::~BlockModel() void BlockModel::remove_port(SPtr port) { - for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) { + for (auto i = _ports.begin(); i != _ports.end(); ++i) { if ((*i) == port) { _ports.erase(i); break; @@ -79,7 +79,7 @@ BlockModel::remove_port(SPtr port) void BlockModel::remove_port(const Raul::Path& port_path) { - for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) { + for (auto i = _ports.begin(); i != _ports.end(); ++i) { if ((*i)->path() == port_path) { _ports.erase(i); break; diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 123b9050..356a6b31 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -55,7 +55,7 @@ ClientStore::add_object(SPtr object) { // If we already have "this" object, merge the existing one into the new // one (with precedence to the new values). - iterator existing = find(object->path()); + auto existing = find(object->path()); if (existing != end()) { dynamic_ptr_cast(existing->second)->set(object); } else { @@ -202,7 +202,7 @@ ClientStore::operator()(const Del& del) if (uri_is_path(del.uri)) { remove_object(uri_to_path(del.uri)); } else { - Plugins::iterator p = _plugins->find(del.uri); + auto p = _plugins->find(del.uri); if (p != _plugins->end()) { _plugins->erase(p); _signal_plugin_deleted.emit(del.uri); @@ -296,7 +296,7 @@ ClientStore::operator()(const Put& msg) model->set_properties(properties); add_object(model); } else if (is_block) { - Iterator p = properties.find(_uris.lv2_prototype); + auto p = properties.find(_uris.lv2_prototype); if (p == properties.end()) { p = properties.find(_uris.ingen_prototype); } diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp index 762ed8ed..b5838d19 100644 --- a/src/client/GraphModel.cpp +++ b/src/client/GraphModel.cpp @@ -67,8 +67,8 @@ GraphModel::remove_arcs_on(SPtr p) { // Remove any connections which referred to this object, // since they can't possibly exist anymore - for (Arcs::iterator j = _arcs.begin(); j != _arcs.end();) { - Arcs::iterator next = j; + for (auto j = _arcs.begin(); j != _arcs.end();) { + auto next = j; ++next; SPtr arc = dynamic_ptr_cast(j->second); @@ -97,7 +97,7 @@ GraphModel::clear() SPtr GraphModel::get_arc(const Node* tail, const Node* head) { - Arcs::iterator i = _arcs.find(std::make_pair(tail, head)); + auto i = _arcs.find(std::make_pair(tail, head)); if (i != _arcs.end()) { return dynamic_ptr_cast(i->second); } else { @@ -144,7 +144,7 @@ GraphModel::add_arc(SPtr arc) void GraphModel::remove_arc(const Node* tail, const Node* head) { - Arcs::iterator i = _arcs.find(std::make_pair(tail, head)); + auto i = _arcs.find(std::make_pair(tail, head)); if (i != _arcs.end()) { SPtr arc = dynamic_ptr_cast(i->second); _signal_removed_arc.emit(arc); diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 5aee03ce..45136546 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -58,7 +58,7 @@ const Atom& ObjectModel::get_property(const Raul::URI& key) const { static const Atom null_atom; - Properties::const_iterator i = properties().find(key); + auto i = properties().find(key); return (i != properties().end()) ? i->second : null_atom; } diff --git a/src/gui/App.cpp b/src/gui/App.cpp index 565f3b19..1473320b 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -361,7 +361,7 @@ App::port_activity(Port* port) void App::activity_port_destroyed(Port* port) { - ActivityPorts::iterator i = _activity_ports.find(port); + auto i = _activity_ports.find(port); if (i != _activity_ports.end()) { _activity_ports.erase(i); } @@ -372,8 +372,8 @@ App::activity_port_destroyed(Port* port) bool App::animate() { - for (ActivityPorts::iterator i = _activity_ports.begin(); i != _activity_ports.end(); ) { - ActivityPorts::iterator next = i; + for (auto i = _activity_ports.begin(); i != _activity_ports.end(); ) { + auto next = i; ++next; if ((*i).second) { // saw it last time, unhighlight and pop diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 8db0ef9c..3078e347 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -347,7 +347,7 @@ GraphCanvas::add_block(SPtr bm) void GraphCanvas::remove_block(SPtr bm) { - Views::iterator i = _views.find(bm); + auto i = _views.find(bm); if (i != _views.end()) { const guint n_ports = i->second->num_ports(); @@ -370,7 +370,7 @@ GraphCanvas::add_port(SPtr pm) void GraphCanvas::remove_port(SPtr pm) { - Views::iterator i = _views.find(pm); + auto i = _views.find(pm); // Port on this graph if (i != _views.end()) { diff --git a/src/gui/PluginMenu.cpp b/src/gui/PluginMenu.cpp index 08102221..e512d587 100644 --- a/src/gui/PluginMenu.cpp +++ b/src/gui/PluginMenu.cpp @@ -81,7 +81,7 @@ PluginMenu::add_plugin(SPtr p) add_plugin_to_menu(_classless_menu, p); } else { // For each menu that represents plugin's class (possibly several) - for (iterator i = range.first; i != range.second ; ++i) { + for (auto i = range.first; i != range.second ; ++i) { add_plugin_to_menu(i->second, p); } } diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 4f8e085e..9622a7f5 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -234,8 +234,7 @@ Port::build_enum_menu() PluginModel::ScalePoints points = block->plugin_model()->port_scale_points( model()->index()); - for (PluginModel::ScalePoints::iterator i = points.begin(); - i != points.end(); ++i) { + for (auto i = points.begin(); i != points.end(); ++i) { menu->items().push_back(Gtk::Menu_Helpers::MenuElem(i->second)); Gtk::MenuItem* menu_item = &(menu->items().back()); menu_item->signal_activate().connect( diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index c259a92f..31e0aff4 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -392,7 +392,7 @@ PropertiesWindow::on_show() void PropertiesWindow::change_property(const Raul::URI& key, const Atom& value) { - Records::iterator r = _records.find(key); + auto r = _records.find(key); if (r == _records.end()) { add_property(key, value); _table->show_all(); @@ -467,7 +467,7 @@ PropertiesWindow::get_value(LV2_URID type, Gtk::Widget* value_widget) void PropertiesWindow::on_change(const Raul::URI& key) { - Records::iterator r = _records.find(key); + auto r = _records.find(key); if (r == _records.end()) { return; } diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp index 4dd21e28..1a5e190a 100644 --- a/src/gui/RDFS.cpp +++ b/src/gui/RDFS.cpp @@ -122,7 +122,7 @@ types(World* world, SPtr model) URISet types; types.insert(Raul::URI(LILV_NS_RDFS "Resource")); PropRange range = model->properties().equal_range(world->uris().rdf_type); - for (PropIter t = range.first; t != range.second; ++t) { + for (auto t = range.first; t != range.second; ++t) { if (t->second.type() == world->forge().URI || t->second.type() == world->forge().URID) { const Raul::URI type(world->forge().str(t->second, false)); diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp index 7e6afb77..5dbdbe98 100644 --- a/src/gui/WindowFactory.cpp +++ b/src/gui/WindowFactory.cpp @@ -113,7 +113,7 @@ WindowFactory::graph_window(SPtr graph) return nullptr; } - GraphWindowMap::iterator w = _graph_windows.find(graph->path()); + auto w = _graph_windows.find(graph->path()); return (w == _graph_windows.end()) ? nullptr : w->second; } @@ -141,7 +141,7 @@ WindowFactory::present_graph(SPtr graph, { assert(!view || view->graph() == graph); - GraphWindowMap::iterator w = _graph_windows.find(graph->path()); + auto w = _graph_windows.find(graph->path()); if (w != _graph_windows.end()) { (*w).second->present(); @@ -192,7 +192,7 @@ WindowFactory::remove_graph_window(GraphWindow* win, GdkEventAny* ignored) return !_app.quit(win); } - GraphWindowMap::iterator w = _graph_windows.find(win->graph()->path()); + auto w = _graph_windows.find(win->graph()->path()); assert((*w).second == win); _graph_windows.erase(w); @@ -208,7 +208,7 @@ WindowFactory::present_load_plugin(SPtr graph, { _app.request_plugins_if_necessary(); - GraphWindowMap::iterator w = _graph_windows.find(graph->path()); + auto w = _graph_windows.find(graph->path()); if (w != _graph_windows.end()) { _load_plugin_win->set_transient_for(*w->second); @@ -230,7 +230,7 @@ void WindowFactory::present_load_graph(SPtr graph, Properties data) { - GraphWindowMap::iterator w = _graph_windows.find(graph->path()); + auto w = _graph_windows.find(graph->path()); if (w != _graph_windows.end()) { _load_graph_win->set_transient_for(*w->second); @@ -243,7 +243,7 @@ void WindowFactory::present_load_subgraph(SPtr graph, Properties data) { - GraphWindowMap::iterator w = _graph_windows.find(graph->path()); + auto w = _graph_windows.find(graph->path()); if (w != _graph_windows.end()) { _load_graph_win->set_transient_for(*w->second); @@ -256,7 +256,7 @@ void WindowFactory::present_new_subgraph(SPtr graph, Properties data) { - GraphWindowMap::iterator w = _graph_windows.find(graph->path()); + auto w = _graph_windows.find(graph->path()); if (w != _graph_windows.end()) { _new_subgraph_win->set_transient_for(*w->second); @@ -268,7 +268,7 @@ WindowFactory::present_new_subgraph(SPtr graph, void WindowFactory::present_rename(SPtr object) { - GraphWindowMap::iterator w = _graph_windows.find(object->path()); + auto w = _graph_windows.find(object->path()); if (w == _graph_windows.end()) { w = _graph_windows.find(object->path().parent()); } @@ -283,7 +283,7 @@ WindowFactory::present_rename(SPtr object) void WindowFactory::present_properties(SPtr object) { - GraphWindowMap::iterator w = _graph_windows.find(object->path()); + auto w = _graph_windows.find(object->path()); if (w == _graph_windows.end()) { w = _graph_windows.find(object->path().parent()); } diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp index 1cae6f58..d33be9fc 100644 --- a/src/server/BlockFactory.cpp +++ b/src/server/BlockFactory.cpp @@ -82,7 +82,7 @@ BlockFactory::refresh() // Add any new plugins to response std::set new_plugins; for (const auto& p : _plugins) { - Plugins::const_iterator o = old_plugins.find(p.first); + auto o = old_plugins.find(p.first); if (o == old_plugins.end()) { new_plugins.insert(p.second); } @@ -213,7 +213,7 @@ BlockFactory::load_lv2_plugins() continue; } - Plugins::iterator p = _plugins.find(uri); + auto p = _plugins.find(uri); if (p == _plugins.end()) { LV2Plugin* const plugin = new LV2Plugin(_world, lv2_plug); _plugins.insert(make_pair(uri, plugin)); diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp index a9076239..e81114ff 100644 --- a/src/server/DuplexPort.cpp +++ b/src/server/DuplexPort.cpp @@ -111,8 +111,7 @@ DuplexPort::inherit_neighbour(const PortImpl* port, add.insert(std::make_pair(uris.lv2_maximum, port->maximum())); } } else if (_type == PortType::ATOM) { - for (Properties::const_iterator i = port->properties().find( - uris.atom_supports); + for (auto i = port->properties().find(uris.atom_supports); i != port->properties().end() && i->first == uris.atom_supports; ++i) { set_property(i->first, i->second); diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp index ec73a8c8..f9c4cb54 100644 --- a/src/server/GraphImpl.cpp +++ b/src/server/GraphImpl.cpp @@ -110,8 +110,8 @@ GraphImpl::duplicate(Engine& engine, for (const auto& a : _arcs) { SPtr arc = dynamic_ptr_cast(a.second); if (arc) { - PortMap::iterator t = port_map.find(arc->tail()); - PortMap::iterator h = port_map.find(arc->head()); + auto t = port_map.find(arc->tail()); + auto h = port_map.find(arc->head()); if (t != port_map.end() && h != port_map.end()) { dup->add_arc(SPtr(new ArcImpl(t->second, h->second))); } @@ -277,7 +277,7 @@ SPtr GraphImpl::remove_arc(const PortImpl* tail, const PortImpl* dst_port) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - Arcs::iterator i = _arcs.find(std::make_pair(tail, dst_port)); + auto i = _arcs.find(std::make_pair(tail, dst_port)); if (i != _arcs.end()) { SPtr arc = dynamic_ptr_cast(i->second); _arcs.erase(i); @@ -291,7 +291,7 @@ bool GraphImpl::has_arc(const PortImpl* tail, const PortImpl* dst_port) const { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - Arcs::const_iterator i = _arcs.find(std::make_pair(tail, dst_port)); + auto i = _arcs.find(std::make_pair(tail, dst_port)); return (i != _arcs.end()); } diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp index 852dfd63..d26fa51f 100644 --- a/src/server/NodeImpl.cpp +++ b/src/server/NodeImpl.cpp @@ -36,7 +36,7 @@ NodeImpl::get_property(const Raul::URI& key) const { ThreadManager::assert_not_thread(THREAD_PROCESS); static const Atom null_atom; - Properties::const_iterator i = properties().find(key); + auto i = properties().find(key); return (i != properties().end()) ? i->second : null_atom; } diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index d2a7d350..1a70223c 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -117,7 +117,7 @@ CreateBlock::pre_process(PreProcessContext& ctx) // Load state from directory if given in properties LilvState* state = nullptr; - Properties::iterator s = _properties.find(uris.state_state); + auto s = _properties.find(uris.state_state); if (s != _properties.end() && s->second.type() == uris.forge.Path) { state = LV2Block::load_state(_engine.world(), s->second.ptr()); } diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index e50e5fa8..310579aa 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -67,7 +67,7 @@ Delete::pre_process(PreProcessContext& ctx) _engine.control_bindings()->get_all(_path, _removed_bindings); - Store::iterator iter = _engine.store()->find(_path); + auto iter = _engine.store()->find(_path); if (iter == _engine.store()->end()) { return Event::pre_process_done(Status::NOT_FOUND, _path); } diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 7e38ffe1..4553c8a2 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -68,13 +68,13 @@ Disconnect::Impl::Impl(Engine& e, BlockImpl* const head_block = _head->parent_block(); // Remove tail from head's providers - std::set::iterator hp = head_block->providers().find(tail_block); + auto hp = head_block->providers().find(tail_block); if (hp != head_block->providers().end()) { head_block->providers().erase(hp); } // Remove head from tail's providers - std::set::iterator td = tail_block->dependants().find(head_block); + auto td = tail_block->dependants().find(head_block); if (td != tail_block->dependants().end()) { tail_block->dependants().erase(td); } diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 92cb52b0..8dfea405 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -700,7 +700,7 @@ ingen_save(LV2_Handle instance, char* real_path = make_path->path(make_path->handle, "main.ttl"); char* state_path = map_path->abstract_path(map_path->handle, real_path); - Ingen::Store::iterator root = plugin->world->store()->find(Raul::Path("/")); + auto root = plugin->world->store()->find(Raul::Path("/")); { std::lock_guard lock(plugin->world->rdf_mutex()); -- cgit v1.2.1