diff options
34 files changed, 156 insertions, 175 deletions
diff --git a/.clang-tidy b/.clang-tidy index 5783b344..eef48627 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -9,7 +9,6 @@ Checks: > -*-non-private-member-variables-in-classes, -*-special-member-functions, -*-uppercase-literal-suffix, - -*-use-auto, -abseil-string-find-str-contains, -altera-*, -android-cloexec-*, diff --git a/include/ingen/Properties.hpp b/include/ingen/Properties.hpp index 300d1a78..95b7eaf9 100644 --- a/include/ingen/Properties.hpp +++ b/include/ingen/Properties.hpp @@ -82,7 +82,7 @@ public: } bool contains(const URI& key, const Atom& value) { - for (const_iterator i = find(key); i != end() && i->first == key; ++i) { + for (auto i = find(key); i != end() && i->first == key; ++i) { if (i->second == value) { return true; } diff --git a/include/ingen/Store.hpp b/include/ingen/Store.hpp index 67ea16fa..1eb7a41a 100644 --- a/include/ingen/Store.hpp +++ b/include/ingen/Store.hpp @@ -44,7 +44,7 @@ public: void add(Node* o); Node* get(const raul::Path& path) { - const iterator i = find(path); + const auto i = find(path); return (i == end()) ? nullptr : i->second.get(); } diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp index ece002f8..7c770cea 100644 --- a/src/ClashAvoider.cpp +++ b/src/ClashAvoider.cpp @@ -72,8 +72,6 @@ ClashAvoider::map_path(const raul::Path& in) if (m != _symbol_map.end()) { return m->second; } else { - using InsertRecord = std::pair<SymbolMap::iterator, bool>; - // See if parent is mapped raul::Path parent = in.parent(); do { @@ -81,7 +79,7 @@ ClashAvoider::map_path(const raul::Path& in) if (p != _symbol_map.end()) { const raul::Path mapped = raul::Path( p->second.base() + in.substr(parent.base().length())); - InsertRecord i = _symbol_map.emplace(in, mapped); + auto i = _symbol_map.emplace(in, mapped); return i.first->second; } parent = parent.parent(); @@ -89,7 +87,7 @@ ClashAvoider::map_path(const raul::Path& in) if (!exists(in) && _symbol_map.find(in) == _symbol_map.end()) { // No clash, use symbol unmodified - InsertRecord i = _symbol_map.emplace(in, in); + auto i = _symbol_map.emplace(in, in); assert(i.second); return i.first->second; @@ -120,7 +118,7 @@ ClashAvoider::map_path(const raul::Path& in) } raul::Symbol sym(name); std::string str = ss.str(); - InsertRecord i = _symbol_map.emplace(in, raul::Path(str)); + auto i = _symbol_map.emplace(in, raul::Path(str)); offset = _store.child_name_offset(in.parent(), sym, false); _offsets.emplace(base_path, offset); return i.first->second; diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 5b5d75bd..9e760805 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -170,7 +170,7 @@ Configuration::parse(int argc, char** argv) for (int i = 1; i < argc; ++i) { if (argv[i][0] != '-' || !strcmp(argv[i], "-")) { // File argument - const Options::iterator o = _options.find("load"); + const auto o = _options.find("load"); if (!o->second.value.is_valid()) { _options.find("load")->second.value = _forge.alloc(argv[i]); } else { @@ -184,7 +184,7 @@ Configuration::parse(int argc, char** argv) name = name.substr(0, name.find('=')); } - const Options::iterator o = _options.find(name); + const auto o = _options.find(name); if (o == _options.end()) { throw OptionError(fmt("Unrecognized option `%1%'", name)); } else if (o->second.type == _forge.Bool) { // --flag @@ -200,13 +200,13 @@ Configuration::parse(int argc, char** argv) // Short option const size_t len = strlen(argv[i]); for (size_t j = 1; j < len; ++j) { - const char letter = argv[i][j]; - const ShortNames::iterator n = _short_names.find(letter); + const char letter = argv[i][j]; + const auto n = _short_names.find(letter); if (n == _short_names.end()) { throw OptionError(fmt("Unrecognized option `%1%'", letter)); } - const Options::iterator o = _options.find(n->second); + const auto o = _options.find(n->second); if (j < len - 1) { // Non-final POSIX style flag if (o->second.type != _forge.Bool) { throw OptionError( @@ -244,12 +244,12 @@ Configuration::load(const FilePath& path) Sord::Node nodemm(world, Sord::Node::URI, reinterpret_cast<const char*>(node.buf)); Sord::Node nil; - for (Sord::Iter i = model.find(nodemm, nil, nil); !i.end(); ++i) { - const Sord::Node& pred = i.get_predicate(); - const Sord::Node& obj = i.get_object(); + for (auto i = model.find(nodemm, nil, nil); !i.end(); ++i) { + const auto& pred = i.get_predicate(); + const auto& obj = i.get_object(); if (pred.to_string().substr(0, sizeof(INGEN_NS) - 1) == INGEN_NS) { const std::string key = pred.to_string().substr(sizeof(INGEN_NS) - 1); - const Keys::iterator k = _keys.find(key); + const auto k = _keys.find(key); if (k != _keys.end() && obj.type() == Sord::Node::LITERAL) { set_value_from_string(_options.find(k->second)->second, obj.to_string()); diff --git a/src/Parser.cpp b/src/Parser.cpp index f54c4249..f853d1b5 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -66,16 +66,17 @@ Parser::find_resources(Sord::World& world, model.load_file(env, SERD_TURTLE, manifest_uri.string()); std::set<ResourceRecord> resources; - for (Sord::Iter i = model.find(nil, rdf_type, type); !i.end(); ++i) { - const Sord::Node resource = i.get_subject(); - const std::string resource_uri = resource.to_c_string(); - Sord::Iter f = model.find(resource, rdfs_seeAlso, nil); - std::string file_path; + for (auto i = model.find(nil, rdf_type, type); !i.end(); ++i) { + const auto resource = i.get_subject(); + auto f = model.find(resource, rdfs_seeAlso, nil); + + std::string file_path; if (!f.end()) { uint8_t* p = serd_file_uri_parse(f.get_object().to_u_string(), nullptr); file_path = reinterpret_cast<const char*>(p); serd_free(p); } + resources.insert(ResourceRecord(resource, file_path)); } @@ -112,7 +113,7 @@ get_properties(ingen::World& world, const Sord::Node nil; Properties props; - for (Sord::Iter i = model.find(subject, nil, nil); !i.end(); ++i) { + for (auto i = model.find(subject, nil, nil); !i.end(); ++i) { if (!skip_property(world.uris(), i.get_predicate())) { forge.clear(); forge.read( @@ -162,7 +163,7 @@ get_port(ingen::World& world, // Get index if requested (for Graphs) if (index) { - Properties::const_iterator i = props.find(uris.lv2_index); + const auto i = props.find(uris.lv2_index); if (i == props.end() || i->second.type() != world.forge().Int || i->second.get<int32_t>() < 0) { @@ -173,8 +174,8 @@ get_port(ingen::World& world, } // Get symbol - Properties::const_iterator s = props.find(uris.lv2_symbol); - std::string sym; + auto s = props.find(uris.lv2_symbol); + std::string sym; if (s != props.end() && s->second.type() == world.forge().String) { sym = s->second.ptr<char>(); } else { @@ -353,7 +354,7 @@ parse_graph(ingen::World& world, // For each port on this graph using PortRecords = std::map<uint32_t, PortRecord>; PortRecords ports; - for (Sord::Iter p = model.find(graph, lv2_port, nil); !p.end(); ++p) { + for (auto p = model.find(graph, lv2_port, nil); !p.end(); ++p) { Sord::Node port = p.get_object(); // Get all properties @@ -386,7 +387,7 @@ parse_graph(ingen::World& world, } // For each block in this graph - for (Sord::Iter n = model.find(subject, ingen_block, nil); !n.end(); ++n) { + for (auto n = model.find(subject, ingen_block, nil); !n.end(); ++n) { Sord::Node node = n.get_object(); URI node_uri = node; assert(!node_uri.path().empty() && node_uri.path() != "/"); @@ -398,7 +399,7 @@ parse_graph(ingen::World& world, boost::optional<Properties>()); // For each port on this block - for (Sord::Iter p = model.find(node, lv2_port, nil); !p.end(); ++p) { + for (auto p = model.find(node, lv2_port, nil); !p.end(); ++p) { Sord::Node port = p.get_object(); Resource::Graph subctx = Resource::Graph::DEFAULT; @@ -443,8 +444,8 @@ parse_arc(ingen::World& world, const Sord::URI ingen_head(*world.rdf_world(), uris.ingen_head); const Sord::Node nil; - Sord::Iter t = model.find(subject, ingen_tail, nil); - Sord::Iter h = model.find(subject, ingen_head, nil); + auto t = model.find(subject, ingen_tail, nil); + auto h = model.find(subject, ingen_head, nil); if (t.end()) { world.log().error("Arc has no tail\n"); @@ -492,7 +493,7 @@ parse_arcs(ingen::World& world, const Sord::URI ingen_arc(*world.rdf_world(), world.uris().ingen_arc); const Sord::Node nil; - for (Sord::Iter i = model.find(subject, ingen_arc, nil); !i.end(); ++i) { + for (auto i = model.find(subject, ingen_arc, nil); !i.end(); ++i) { parse_arc(world, target, model, base_uri, i.get_object(), graph); } @@ -531,7 +532,7 @@ parse(ingen::World& world, // Get all subjects and their types (?subject a ?type) using Subjects = std::map< Sord::Node, std::set<Sord::Node> >; Subjects subjects; - for (Sord::Iter i = model.find(subject, rdf_type, nil); !i.end(); ++i) { + for (auto i = model.find(subject, rdf_type, nil); !i.end(); ++i) { const Sord::Node& rdf_class = i.get_object(); assert(rdf_class.is_uri()); diff --git a/src/Resource.cpp b/src/Resource.cpp index 0bd4b95f..48d541f8 100644 --- a/src/Resource.cpp +++ b/src/Resource.cpp @@ -29,9 +29,8 @@ bool Resource::add_property(const URI& uri, const Atom& value, Graph ctx) { // Ignore duplicate statements - using iterator = Properties::const_iterator; - const std::pair<iterator, iterator> range = _properties.equal_range(uri); - for (iterator i = range.first; i != range.second && i != _properties.end(); ++i) { + const auto range = _properties.equal_range(uri); + for (auto i = range.first; i != range.second && i != _properties.end(); ++i) { if (i->second == value && i->second.context() == ctx) { return false; } @@ -119,8 +118,9 @@ Resource::has_property(const URI& uri, const Atom& value) const bool Resource::has_property(const URI& uri, const URIs::Quark& value) const { - Properties::const_iterator i = _properties.find(uri); - for (; (i != _properties.end()) && (i->first == uri); ++i) { + for (auto i = _properties.find(uri); + (i != _properties.end()) && (i->first == uri); + ++i) { if (value == i->second) { return true; } @@ -138,7 +138,8 @@ const Atom& Resource::get_property(const URI& uri) const { static const Atom nil; - Properties::const_iterator i = _properties.find(uri); + + const auto i = _properties.find(uri); return (i != _properties.end()) ? i->second : nil; } @@ -150,11 +151,10 @@ Resource::type(const URIs& uris, bool& port, bool& is_output) { - using iterator = Properties::const_iterator; - const std::pair<iterator, iterator> types_range = properties.equal_range(uris.rdf_type); + const auto types_range = properties.equal_range(uris.rdf_type); graph = block = port = is_output = false; - for (iterator i = types_range.first; i != types_range.second; ++i) { + for (auto i = types_range.first; i != types_range.second; ++i) { const Atom& atom = i->second; if (atom.type() != uris.forge.URI && atom.type() != uris.forge.URID) { continue; // Non-URI type, ignore garbage data diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index 3dfa862b..1109c825 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -352,7 +352,7 @@ Serialiser::Impl::serialise_graph(const std::shared_ptr<const Node>& graph, std::set<const Resource*> plugins; const Store::const_range kids = _world.store()->children_range(graph); - for (Store::const_iterator n = kids.first; n != kids.second; ++n) { + for (auto n = kids.first; n != kids.second; ++n) { if (n->first.parent() != graph->path()) { continue; } diff --git a/src/Store.cpp b/src/Store.cpp index fe5527a5..1dd5b146 100644 --- a/src/Store.cpp +++ b/src/Store.cpp @@ -67,7 +67,7 @@ Store::find_descendants_end(const iterator parent) Store::const_iterator Store::find_descendants_end(const const_iterator parent) const { - const_iterator descendants_end = parent; + auto descendants_end = parent; ++descendants_end; while (descendants_end != end() && descendants_end->first.is_child_of(parent->first)) { @@ -80,9 +80,9 @@ Store::find_descendants_end(const const_iterator parent) const Store::const_range Store::children_range(const std::shared_ptr<const Node>& o) const { - const const_iterator parent = find(o->path()); + const auto parent = find(o->path()); if (parent != end()) { - const_iterator first_child = parent; + auto first_child = parent; ++first_child; return std::make_pair(first_child, find_descendants_end(parent)); } @@ -93,7 +93,7 @@ void Store::remove(const iterator top, Objects& removed) { if (top != end()) { - const iterator descendants_end = find_descendants_end(top); + const auto descendants_end = find_descendants_end(top); removed.insert(top, descendants_end); erase(top, descendants_end); } @@ -109,15 +109,15 @@ Store::rename(const iterator top, const raul::Path& new_path) remove(top, removed); // Rename all the removed objects - for (Objects::const_iterator i = removed.begin(); i != removed.end(); ++i) { - const raul::Path path = (i->first == old_path) + for (const auto& r : removed) { + const raul::Path path = (r.first == old_path) ? new_path : new_path.child( - raul::Path(i->first.substr(old_path.base().length() - 1))); + raul::Path(r.first.substr(old_path.base().length() - 1))); - i->second->set_path(path); - assert(find(path) == end()); // Shouldn't be dropping objects! - emplace(path, i->second); + r.second->set_path(path); + assert(find(path) == end()); // Shouldn't be dropping objects! + emplace(path, r.second); } } diff --git a/src/World.cpp b/src/World.cpp index c6f1b715..b0ae635f 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -389,7 +389,7 @@ std::shared_ptr<Interface> World::new_interface(const URI& engine_uri, const std::shared_ptr<Interface>& respondee) { - const Impl::InterfaceFactories::const_iterator i = + const auto i = _impl->interface_factories.find(std::string{engine_uri.scheme()}); if (i == _impl->interface_factories.end()) { log().warn("Unknown URI scheme `%1%'\n", engine_uri.scheme()); @@ -403,8 +403,7 @@ World::new_interface(const URI& engine_uri, bool World::run(const std::string& mime_type, const std::string& filename) { - const Impl::ScriptRunners::const_iterator i = - _impl->script_runners.find(mime_type); + const auto i = _impl->script_runners.find(mime_type); if (i == _impl->script_runners.end()) { log().warn("Unknown script MIME type `%1%'\n", mime_type); return false; diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index d8238c8a..9728cc4f 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -103,7 +103,7 @@ std::shared_ptr<ObjectModel> ClientStore::remove_object(const raul::Path& path) { // Find the object, the "top" of the tree to remove - const iterator top = find(path); + const auto top = find(path); if (top == end()) { return nullptr; } @@ -142,7 +142,7 @@ ClientStore::remove_object(const raul::Path& path) std::shared_ptr<PluginModel> ClientStore::_plugin(const URI& uri) { - const Plugins::iterator i = _plugins->find(uri); + const auto i = _plugins->find(uri); return (i == _plugins->end()) ? std::shared_ptr<PluginModel>() : (*i).second; } @@ -152,7 +152,7 @@ ClientStore::_plugin(const Atom& uri) /* FIXME: Should probably be stored with URIs rather than strings, to make this a fast case. */ - const Plugins::iterator i = _plugins->find(URI(_uris.forge.str(uri, false))); + const auto i = _plugins->find(URI(_uris.forge.str(uri, false))); return (i == _plugins->end()) ? std::shared_ptr<PluginModel>() : (*i).second; } @@ -165,7 +165,7 @@ ClientStore::plugin(const URI& uri) const std::shared_ptr<ObjectModel> ClientStore::_object(const raul::Path& path) { - const iterator i = find(path); + const auto i = find(path); if (i == end()) { return nullptr; } else { @@ -235,7 +235,7 @@ ClientStore::operator()(const Copy&) void ClientStore::operator()(const Move& msg) { - const iterator top = find(msg.old_path); + const auto top = find(msg.old_path); if (top != end()) { rename(top, msg.new_path); } @@ -250,8 +250,6 @@ ClientStore::message(const Message& msg) void ClientStore::operator()(const Put& msg) { - using Iterator = Properties::const_iterator; - const auto& uri = msg.uri; const auto& properties = msg.properties; @@ -263,12 +261,12 @@ ClientStore::operator()(const Put& msg) is_graph, is_block, is_port, is_output); // Check for specially handled types - const Iterator t = properties.find(_uris.rdf_type); + const auto t = properties.find(_uris.rdf_type); if (t != properties.end()) { const Atom& type(t->second); if (_uris.pset_Preset == type) { - const Iterator p = properties.find(_uris.lv2_appliesTo); - const Iterator l = properties.find(_uris.rdfs_label); + const auto p = properties.find(_uris.lv2_appliesTo); + const auto l = properties.find(_uris.rdfs_label); std::shared_ptr<PluginModel> plug; if (p == properties.end()) { _log.error("Preset <%1%> with no plugin\n", uri.c_str()); @@ -341,8 +339,8 @@ ClientStore::operator()(const Put& msg) PortModel::Direction pdir = (is_output) ? PortModel::Direction::OUTPUT : PortModel::Direction::INPUT; - uint32_t index = 0; - const Iterator i = properties.find(_uris.lv2_index); + uint32_t index = 0; + const auto i = properties.find(_uris.lv2_index); if (i != properties.end() && i->second.type() == _uris.forge.Int) { index = i->second.get<int32_t>(); } diff --git a/src/gui/.clang-tidy b/src/gui/.clang-tidy index c99c9007..e258f145 100644 --- a/src/gui/.clang-tidy +++ b/src/gui/.clang-tidy @@ -9,7 +9,6 @@ Checks: > -*-non-private-member-variables-in-classes, -*-special-member-functions, -*-uppercase-literal-suffix, - -*-use-auto, -abseil-string-find-str-contains, -altera-*, -android-cloexec-*, diff --git a/src/gui/App.cpp b/src/gui/App.cpp index dc51df1d..3187548a 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -376,7 +376,7 @@ App::status_text() const void App::port_activity(Port* port) { - std::pair<ActivityPorts::iterator, bool> inserted = _activity_ports.emplace(port, false); + const auto inserted = _activity_ports.emplace(port, false); if (inserted.second) { inserted.first->second = false; } diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp index ee3013b1..14258a5a 100644 --- a/src/gui/GraphBox.cpp +++ b/src/gui/GraphBox.cpp @@ -717,18 +717,17 @@ GraphBox::event_export_image() dialog.set_transient_for(*_window); } - using Types = std::map<std::string, std::string>; - Types types; + std::map<std::string, std::string> types; types["*.dot"] = "Graphviz DOT"; types["*.pdf"] = "Portable Document Format"; types["*.ps"] = "PostScript"; types["*.svg"] = "Scalable Vector Graphics"; - for (Types::const_iterator t = types.begin(); t != types.end(); ++t) { + for (const auto& t : types) { Gtk::FileFilter filt; - filt.add_pattern(t->first); - filt.set_name(t->second); + filt.add_pattern(t.first); + filt.set_name(t.second); dialog.add_filter(filt); - if (t->first == "*.pdf") { + if (t.first == "*.pdf") { dialog.set_filter(filt); } } diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 77c33052..6b62e0de 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -284,7 +284,7 @@ GraphCanvas::build() const Store::const_range kids = _app.store()->children_range(_graph); // Create modules for blocks - for (Store::const_iterator i = kids.first; i != kids.second; ++i) { + for (auto i = kids.first; i != kids.second; ++i) { auto block = std::dynamic_pointer_cast<BlockModel>(i->second); if (block && block->parent() == _graph) { add_block(block); @@ -707,8 +707,6 @@ GraphCanvas::copy_selection() void GraphCanvas::paste() { - using PropIter = Properties::const_iterator; - std::lock_guard<std::mutex> lock(_app.world().rdf_mutex()); const Glib::ustring str = Gtk::Clipboard::get()->wait_for_text(); @@ -807,8 +805,8 @@ GraphCanvas::paste() } // Set coordinates so paste origin is at the mouse pointer - PropIter xi = node->properties().find(uris.ingen_canvasX); - PropIter yi = node->properties().find(uris.ingen_canvasY); + const auto xi = node->properties().find(uris.ingen_canvasX); + const auto yi = node->properties().find(uris.ingen_canvasY); if (xi != node->properties().end()) { const float x = xi->second.get<float>() - min_x + paste_x; props.insert({xi->first, Property(_app.forge().make(x), diff --git a/src/gui/GraphTreeWindow.cpp b/src/gui/GraphTreeWindow.cpp index e1ef158f..98b90ff0 100644 --- a/src/gui/GraphTreeWindow.cpp +++ b/src/gui/GraphTreeWindow.cpp @@ -108,8 +108,8 @@ void GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm) { if (!pm->parent()) { - Gtk::TreeModel::iterator iter = _graph_treestore->append(); - Gtk::TreeModel::Row row = *iter; + const auto iter = _graph_treestore->append(); + auto row = *iter; if (pm->path().is_root()) { row[_graph_tree_columns.name_col] = _app->interface()->uri().string(); } else { @@ -119,12 +119,13 @@ GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm) row[_graph_tree_columns.graph_model_col] = pm; _graphs_treeview->expand_row(_graph_treestore->get_path(iter), true); } else { - Gtk::TreeModel::Children children = _graph_treestore->children(); - Gtk::TreeModel::iterator c = find_graph(children, pm->parent()); + const auto& children = _graph_treestore->children(); + auto c = find_graph(children, pm->parent()); if (c != children.end()) { - Gtk::TreeModel::iterator iter = _graph_treestore->append(c->children()); - Gtk::TreeModel::Row row = *iter; + const auto iter = _graph_treestore->append(c->children()); + auto row = *iter; + row[_graph_tree_columns.name_col] = pm->symbol().c_str(); row[_graph_tree_columns.enabled_col] = pm->enabled(); row[_graph_tree_columns.graph_model_col] = pm; @@ -148,7 +149,7 @@ GraphTreeWindow::add_graph(const std::shared_ptr<GraphModel>& pm) void GraphTreeWindow::remove_graph(const std::shared_ptr<GraphModel>& pm) { - Gtk::TreeModel::iterator i = find_graph(_graph_treestore->children(), pm); + const auto i = find_graph(_graph_treestore->children(), pm); if (i != _graph_treestore->children().end()) { _graph_treestore->erase(i); } @@ -158,12 +159,12 @@ Gtk::TreeModel::iterator GraphTreeWindow::find_graph(Gtk::TreeModel::Children root, const std::shared_ptr<client::ObjectModel>& graph) { - for (Gtk::TreeModel::iterator c = root.begin(); c != root.end(); ++c) { + for (auto c = root.begin(); c != root.end(); ++c) { std::shared_ptr<GraphModel> pm = (*c)[_graph_tree_columns.graph_model_col]; if (graph == pm) { return c; } else if (!(*c)->children().empty()) { - Gtk::TreeModel::iterator ret = find_graph(c->children(), graph); + auto ret = find_graph(c->children(), graph); if (ret != c->children().end()) { return ret; } @@ -177,10 +178,12 @@ GraphTreeWindow::find_graph(Gtk::TreeModel::Children root, void GraphTreeWindow::show_graph_menu(GdkEventButton* ev) { - Gtk::TreeModel::iterator active = _graph_tree_selection->get_selected(); + const auto active = _graph_tree_selection->get_selected(); if (active) { - Gtk::TreeModel::Row row = *active; - std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; + auto row = *active; + auto col = _graph_tree_columns.graph_model_col; + + const std::shared_ptr<GraphModel>& pm = row[col]; if (pm) { _app->log().warn("TODO: graph menu from tree window"); } @@ -191,9 +194,10 @@ void GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path, Gtk::TreeView::Column* col) { - Gtk::TreeModel::iterator active = _graph_treestore->get_iter(path); - Gtk::TreeModel::Row row = *active; - std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; + const auto active = _graph_treestore->get_iter(path); + auto row = *active; + + std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; _app->window_factory()->present_graph(pm); } @@ -201,9 +205,9 @@ GraphTreeWindow::event_graph_activated(const Gtk::TreeModel::Path& path, void GraphTreeWindow::event_graph_enabled_toggled(const Glib::ustring& path_str) { - Gtk::TreeModel::Path path(path_str); - Gtk::TreeModel::iterator active = _graph_treestore->get_iter(path); - Gtk::TreeModel::Row row = *active; + Gtk::TreeModel::Path path(path_str); + auto active = _graph_treestore->get_iter(path); + auto row = *active; std::shared_ptr<GraphModel> pm = row[_graph_tree_columns.graph_model_col]; assert(pm); @@ -224,9 +228,9 @@ GraphTreeWindow::graph_property_changed( const URIs& uris = _app->uris(); _enable_signal = false; if (key == uris.ingen_enabled && value.type() == uris.forge.Bool) { - Gtk::TreeModel::iterator i = find_graph(_graph_treestore->children(), graph); + const auto i = find_graph(_graph_treestore->children(), graph); if (i != _graph_treestore->children().end()) { - Gtk::TreeModel::Row row = *i; + auto row = *i; row[_graph_tree_columns.enabled_col] = value.get<int32_t>(); } else { _app->log().error("Unable to find graph %1%\n", graph->path()); @@ -240,11 +244,9 @@ GraphTreeWindow::graph_moved(const std::shared_ptr<GraphModel>& graph) { _enable_signal = false; - Gtk::TreeModel::iterator i - = find_graph(_graph_treestore->children(), graph); - + auto i = find_graph(_graph_treestore->children(), graph); if (i != _graph_treestore->children().end()) { - Gtk::TreeModel::Row row = *i; + auto row = *i; row[_graph_tree_columns.name_col] = graph->symbol().c_str(); } else { _app->log().error("Unable to find graph %1%\n", graph->path()); diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index 5a9536a2..e147fdf2 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -102,8 +102,9 @@ LoadPluginWindow::LoadPluginWindow(BaseObjectType* cobject, _criteria_liststore = Gtk::ListStore::create(_criteria_columns); _filter_combo->set_model(_criteria_liststore); - Gtk::TreeModel::iterator iter = _criteria_liststore->append(); - Gtk::TreeModel::Row row = *iter; + auto iter = _criteria_liststore->append(); + auto row = *iter; + row[_criteria_columns._col_label] = "Name contains"; row[_criteria_columns._col_criteria] = CriteriaColumns::Criteria::NAME; _filter_combo->set_active(iter); @@ -326,8 +327,8 @@ LoadPluginWindow::add_plugin(const std::shared_ptr<const PluginModel>& plugin) return; } - Gtk::TreeModel::iterator iter = _plugins_liststore->append(); - Gtk::TreeModel::Row row = *iter; + auto iter = _plugins_liststore->append(); + auto row = *iter; _rows.emplace(plugin->uri(), iter); set_row(row, plugin); @@ -355,13 +356,16 @@ LoadPluginWindow::plugin_selection_changed() _name_entry->set_text(""); _name_entry->set_sensitive(false); } else if (n_selected == 1) { - Gtk::TreeModel::iterator iter = _plugins_liststore->get_iter( - *_selection->get_selected_rows().begin()); + auto iter = _plugins_liststore->get_iter( + *_selection->get_selected_rows().begin()); if (iter) { - Gtk::TreeModel::Row row = *iter; - auto p = row.get_value(_plugins_columns._col_plugin); - _name_offset = _app->store()->child_name_offset( - _graph->path(), p->default_block_symbol()); + auto row = *iter; + auto p = row.get_value(_plugins_columns._col_plugin); + + _name_offset = + _app->store()->child_name_offset(_graph->path(), + p->default_block_symbol()); + _name_entry->set_text(generate_module_name(p, _name_offset)); _name_entry->set_sensitive(true); } else { @@ -397,11 +401,11 @@ LoadPluginWindow::generate_module_name( void LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter) { - const URIs& uris = _app->uris(); - Gtk::TreeModel::Row row = *iter; - auto plugin = row.get_value(_plugins_columns._col_plugin); - bool polyphonic = _polyphonic_checkbutton->get_active(); - string name = _name_entry->get_text(); + const URIs& uris = _app->uris(); + auto row = *iter; + auto plugin = row.get_value(_plugins_columns._col_plugin); + bool polyphonic = _polyphonic_checkbutton->get_active(); + string name = _name_entry->get_text(); if (name.empty()) { name = generate_module_name(plugin, _name_offset); @@ -451,7 +455,7 @@ LoadPluginWindow::filter_changed() transform(search.begin(), search.end(), search.begin(), ::toupper); // Get selected criteria - const Gtk::TreeModel::Row row = *(_filter_combo->get_active()); + const auto row = *(_filter_combo->get_active()); CriteriaColumns::Criteria criteria = row[_criteria_columns._col_criteria]; string field; @@ -523,7 +527,7 @@ LoadPluginWindow::plugin_property_changed(const URI& plugin, { const URIs& uris = _app->uris(); if (predicate == uris.doap_name) { - Rows::const_iterator i = _rows.find(plugin); + const auto i = _rows.find(plugin); if (i != _rows.end() && value.type() == uris.forge.String) { (*i->second)[_plugins_columns._col_name] = value.ptr<char>(); } diff --git a/src/gui/PluginMenu.cpp b/src/gui/PluginMenu.cpp index 7ddfd075..66cf9b35 100644 --- a/src/gui/PluginMenu.cpp +++ b/src/gui/PluginMenu.cpp @@ -78,8 +78,6 @@ PluginMenu::clear() void PluginMenu::add_plugin(const std::shared_ptr<client::PluginModel>& p) { - using iterator = ClassMenus::iterator; - if (!p->lilv_plugin() || lilv_plugin_is_replaced(p->lilv_plugin())) { return; } @@ -88,7 +86,7 @@ PluginMenu::add_plugin(const std::shared_ptr<client::PluginModel>& p) const LilvNode* class_uri = lilv_plugin_class_get_uri(pc); const char* class_uri_str = lilv_node_as_string(class_uri); - std::pair<iterator, iterator> range = _class_menus.equal_range(class_uri_str); + const auto range = _class_menus.equal_range(class_uri_str); if (range.first == _class_menus.end() || range.first == range.second || range.first->second.menu == this) { // Add to uncategorized plugin menu @@ -112,16 +110,14 @@ PluginMenu::build_plugin_class_menu(Gtk::Menu* menu, const LilvNode* class_uri = lilv_plugin_class_get_uri(plugin_class); const char* class_uri_str = lilv_node_as_string(class_uri); - const std::pair<LV2Children::const_iterator, LV2Children::const_iterator> kids - = children.equal_range(class_uri_str); - + const auto kids = children.equal_range(class_uri_str); if (kids.first == children.end()) { return 0; } // Add submenus ancestors.insert(class_uri_str); - for (LV2Children::const_iterator i = kids.first; i != kids.second; ++i) { + for (auto i = kids.first; i != kids.second; ++i) { const LilvPluginClass* c = i->second; const char* sub_label_str = lilv_node_as_string(lilv_plugin_class_get_label(c)); const char* sub_uri_str = lilv_node_as_string(lilv_plugin_class_get_uri(c)); diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index afcfa827..cd2a6bd1 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -276,8 +276,9 @@ PropertiesWindow::set_object(const std::shared_ptr<const ObjectModel>& model) } for (const auto& e : entries) { - Gtk::ListStore::iterator ki = _key_store->append(); - Gtk::ListStore::Row row = *ki; + auto ki = _key_store->append(); + auto row = *ki; + row[_combo_columns.uri_col] = e.second.string(); row[_combo_columns.label_col] = e.first; } @@ -521,7 +522,7 @@ PropertiesWindow::on_change(const URI& key) std::string PropertiesWindow::active_key() const { - const Gtk::ListStore::iterator iter = _key_combo->get_active(); + const auto iter = _key_combo->get_active(); if (!iter) { return ""; } diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp index ed8d7e8c..fc722479 100644 --- a/src/gui/RDFS.cpp +++ b/src/gui/RDFS.cpp @@ -118,13 +118,10 @@ datatypes(World& world, URISet& types, bool super) URISet types(World& world, const std::shared_ptr<const client::ObjectModel>& model) { - using PropIter = Properties::const_iterator; - using PropRange = std::pair<PropIter, PropIter>; - // Start with every rdf:type URISet types; types.insert(URI(LILV_NS_RDFS "Resource")); - PropRange range = model->properties().equal_range(world.uris().rdf_type); + const auto range = model->properties().equal_range(world.uris().rdf_type); for (auto t = range.first; t != range.second; ++t) { if (t->second.type() == world.forge().URI || t->second.type() == world.forge().URID) { diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp index ae396b61..b4117b08 100644 --- a/src/gui/WindowFactory.cpp +++ b/src/gui/WindowFactory.cpp @@ -18,7 +18,6 @@ #include "App.hpp" #include "GraphBox.hpp" -#include "GraphView.hpp" #include "GraphWindow.hpp" #include "LoadGraphWindow.hpp" #include "LoadPluginWindow.hpp" diff --git a/src/server/.clang-tidy b/src/server/.clang-tidy index b5c1b4a1..deab7090 100644 --- a/src/server/.clang-tidy +++ b/src/server/.clang-tidy @@ -8,7 +8,6 @@ Checks: > -*-non-private-member-variables-in-classes, -*-special-member-functions, -*-uppercase-literal-suffix, - -*-use-auto, -*-vararg, -abseil-string-find-str-contains, -altera-*, diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp index d36924ae..2186b779 100644 --- a/src/server/BlockFactory.cpp +++ b/src/server/BlockFactory.cpp @@ -98,7 +98,7 @@ PluginImpl* BlockFactory::plugin(const URI& uri) { load_plugin(uri); - const Plugins::const_iterator i = _plugins.find(uri); + const auto i = _plugins.find(uri); return ((i != _plugins.end()) ? i->second.get() : nullptr); } diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp index 8bf52dfd..8ae4f7c2 100644 --- a/src/server/ControlBindings.cpp +++ b/src/server/ControlBindings.cpp @@ -426,7 +426,7 @@ ControlBindings::pre_process(RunContext& ctx, Buffer* buffer) // Set all controls bound to this key const Binding k = {key, nullptr}; - for (Bindings::const_iterator i = _bindings->lower_bound(k); + for (auto i = _bindings->lower_bound(k); i != _bindings->end() && i->key == key; ++i) { set_port_value(ctx, i->port, key.type, value); diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index 026b7d06..eb2ed346 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -729,7 +729,7 @@ LV2Block::save_preset(const URI& uri, nullptr)}; if (state) { - const Properties::const_iterator l = props.find(_uris.rdfs_label); + const auto l = props.find(_uris.rdfs_label); if (l != props.end() && l->second.type() == _uris.atom_String) { lilv_state_set_label(state.get(), l->second.ptr<char>()); } diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp index 9ce7ead6..ebfea41d 100644 --- a/src/server/events/Copy.cpp +++ b/src/server/events/Copy.cpp @@ -69,7 +69,7 @@ Copy::pre_process(PreProcessContext& ctx) const raul::Path old_path = uri_to_path(_msg.old_uri); // Find the old node - const Store::iterator i = _engine.store()->find(old_path); + const auto i = _engine.store()->find(old_path); if (i == _engine.store()->end()) { return Event::pre_process_done(Status::NOT_FOUND, old_path); } @@ -115,8 +115,8 @@ Copy::engine_to_engine(PreProcessContext& ctx) } // Find new parent graph - const raul::Path parent_path = new_path.parent(); - const Store::iterator p = _engine.store()->find(parent_path); + const raul::Path parent_path = new_path.parent(); + const auto p = _engine.store()->find(parent_path); if (p == _engine.store()->end()) { return Event::pre_process_done(Status::NOT_FOUND, parent_path); } diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index 0898a6a0..742eabfe 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -73,8 +73,6 @@ CreateBlock::~CreateBlock() = default; bool CreateBlock::pre_process(PreProcessContext& ctx) { - using iterator = Properties::const_iterator; - const ingen::URIs& uris = _engine.world().uris(); const std::shared_ptr<Store> store = _engine.store(); @@ -88,7 +86,7 @@ CreateBlock::pre_process(PreProcessContext& ctx) } // Map old ingen:prototype to new lv2:prototype - auto range = _properties.equal_range(uris.ingen_prototype); + const auto range = _properties.equal_range(uris.ingen_prototype); for (auto i = range.first; i != range.second;) { const auto value = i->second; auto next = i; @@ -98,7 +96,7 @@ CreateBlock::pre_process(PreProcessContext& ctx) } // Get prototype - iterator t = _properties.find(uris.lv2_prototype); + const auto t = _properties.find(uris.lv2_prototype); if (t == _properties.end() || !uris.forge.is_uri(t->second)) { // Missing/invalid prototype return Event::pre_process_done(Status::BAD_REQUEST); @@ -107,10 +105,10 @@ CreateBlock::pre_process(PreProcessContext& ctx) const URI prototype(uris.forge.str(t->second, false)); // Find polyphony - const iterator p = _properties.find(uris.ingen_polyphonic); - const bool polyphonic = (p != _properties.end() && - p->second.type() == uris.forge.Bool && - p->second.get<int32_t>()); + const auto p = _properties.find(uris.ingen_polyphonic); + const bool polyphonic = (p != _properties.end() && + p->second.type() == uris.forge.Bool && + p->second.get<int32_t>()); // Find and instantiate/duplicate prototype (plugin/existing node) if (uri_is_path(prototype)) { diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp index 2a74ddf0..895a84e7 100644 --- a/src/server/events/CreateGraph.cpp +++ b/src/server/events/CreateGraph.cpp @@ -136,11 +136,9 @@ CreateGraph::pre_process(PreProcessContext& ctx) const ingen::URIs& uris = _engine.world().uris(); - using iterator = Properties::const_iterator; - - uint32_t ext_poly = 1; - uint32_t int_poly = 1; - iterator p = _properties.find(uris.ingen_polyphony); + uint32_t ext_poly = 1; + uint32_t int_poly = 1; + const auto p = _properties.find(uris.ingen_polyphony); if (p != _properties.end() && p->second.type() == uris.forge.Int) { int_poly = p->second.get<int32_t>(); } @@ -156,7 +154,7 @@ CreateGraph::pre_process(PreProcessContext& ctx) const raul::Symbol symbol(_path.is_root() ? "graph" : _path.symbol()); // Get graph prototype - iterator t = _properties.find(uris.lv2_prototype); + auto t = _properties.find(uris.lv2_prototype); if (t == _properties.end()) { t = _properties.find(uris.lv2_prototype); } diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 1fa2a528..ba2c9a9a 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -66,11 +66,8 @@ CreatePort::CreatePort(Engine& engine, { const ingen::URIs& uris = _engine.world().uris(); - using Iterator = Properties::const_iterator; - using Range = std::pair<Iterator, Iterator>; - - const Range types = properties.equal_range(uris.rdf_type); - for (Iterator i = types.first; i != types.second; ++i) { + const auto types = properties.equal_range(uris.rdf_type); + for (auto i = types.first; i != types.second; ++i) { const Atom& type = i->second; if (type == uris.lv2_AudioPort) { _port_type = PortType::AUDIO; @@ -87,8 +84,8 @@ CreatePort::CreatePort(Engine& engine, } } - const Range buffer_types = properties.equal_range(uris.atom_bufferType); - for (Iterator i = buffer_types.first; i != buffer_types.second; ++i) { + const auto buffer_types = properties.equal_range(uris.atom_bufferType); + for (auto i = buffer_types.first; i != buffer_types.second; ++i) { if (uris.forge.is_uri(i->second)) { _buf_type = _engine.world().uri_map().map_uri( uris.forge.str(i->second, false)); @@ -123,10 +120,8 @@ CreatePort::pre_process(PreProcessContext&) const uint32_t buf_size = bufs.default_size(_buf_type); const int32_t old_n_ports = _graph->num_ports_non_rt(); - using PropIter = Properties::const_iterator; - - PropIter index_i = _properties.find(uris.lv2_index); - int32_t index = 0; + auto index_i = _properties.find(uris.lv2_index); + int32_t index = 0; if (index_i != _properties.end()) { // Ensure given index is sane and not taken if (index_i->second.type() != uris.forge.Int) { @@ -144,7 +139,7 @@ CreatePort::pre_process(PreProcessContext&) _engine.world().forge().make(index)); } - const PropIter poly_i = _properties.find(uris.ingen_polyphonic); + const auto poly_i = _properties.find(uris.ingen_polyphonic); const bool polyphonic = (poly_i != _properties.end() && poly_i->second.type() == uris.forge.Bool && poly_i->second.get<int32_t>()); diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index 3347b549..bdd25f1b 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -72,7 +72,7 @@ Delete::Delete(Engine& engine, Delete::~Delete() { - for (ControlBindings::Binding* b : _removed_bindings) { + for (auto* b : _removed_bindings) { delete b; } } diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index 17f3c716..09d9c3b2 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -515,7 +515,7 @@ Delta::execute(RunContext& ctx) auto* const block = dynamic_cast<BlockImpl*>(_object); auto* const port = dynamic_cast<PortImpl*>(_object); - std::vector<SpecialType>::const_iterator t = _types.begin(); + auto t = _types.begin(); for (const auto& p : _properties) { const URI& key = p.first; const Atom& value = p.second; diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index 220418e4..729b102c 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -123,7 +123,7 @@ DisconnectAll::pre_process(PreProcessContext& ctx) // Create disconnect events to erase adjacent arcs in parent's parent if (_port && _parent->parent()) { - GraphImpl* parent_parent = dynamic_cast<GraphImpl*>(_parent->parent()); + auto* const parent_parent = dynamic_cast<GraphImpl*>(_parent->parent()); for (const auto& a : adjacent_arcs(parent_parent)) { _impls.push_back( new Disconnect::Impl(_engine, diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index d85451c8..ddee82b7 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -53,7 +53,7 @@ Move::pre_process(PreProcessContext&) return Event::pre_process_done(Status::PARENT_DIFFERS, _msg.new_path); } - const Store::iterator i = _engine.store()->find(_msg.old_path); + const auto i = _engine.store()->find(_msg.old_path); if (i == _engine.store()->end()) { return Event::pre_process_done(Status::NOT_FOUND, _msg.old_path); } diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp index 87e02e9f..f6d3f966 100644 --- a/tests/ingen_test.cpp +++ b/tests/ingen_test.cpp @@ -166,7 +166,8 @@ run(int argc, char** argv) std::string subject_str = fmt("msg%1%", n_events); Sord::URI subject(*world->rdf_world(), subject_str, reinterpret_cast<const char*>(cmds_file_uri.buf)); - Sord::Iter iter = cmds->find(subject, nil, nil); + + auto iter = cmds->find(subject, nil, nil); if (iter.end()) { break; } |