summaryrefslogtreecommitdiffstats
path: root/src/gui/RDFS.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/RDFS.cpp')
-rw-r--r--src/gui/RDFS.cpp52
1 files changed, 24 insertions, 28 deletions
diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp
index 5a676cad..09af81af 100644
--- a/src/gui/RDFS.cpp
+++ b/src/gui/RDFS.cpp
@@ -14,21 +14,20 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Forge.hpp"
-#include "ingen/Log.hpp"
-#include "ingen/Properties.hpp"
-#include "ingen/URIs.hpp"
-#include "ingen/World.hpp"
-#include "ingen/client/ObjectModel.hpp"
-#include "lilv/lilv.h"
-
#include "RDFS.hpp"
+#include <ingen/Forge.hpp>
+#include <ingen/Log.hpp>
+#include <ingen/Properties.hpp>
+#include <ingen/URI.hpp>
+#include <ingen/URIs.hpp>
+#include <ingen/World.hpp>
+#include <ingen/client/ObjectModel.hpp>
+#include <lilv/lilv.h>
+
#include <utility>
-namespace ingen {
-namespace gui {
-namespace rdfs {
+namespace ingen::gui::rdfs {
std::string
label(World& world, const LilvNode* node)
@@ -76,10 +75,10 @@ closure(World& world, const LilvNode* pred, URISet& types, bool super)
world.lilv_world(), type, pred, nullptr)
: lilv_world_find_nodes(
world.lilv_world(), nullptr, pred, type);
- LILV_FOREACH(nodes, m, matches) {
+ LILV_FOREACH (nodes, m, matches) {
const LilvNode* klass_node = lilv_nodes_get(matches, m);
if (lilv_node_is_uri(klass_node)) {
- URI klass(lilv_node_as_uri(klass_node));
+ const URI klass{lilv_node_as_uri(klass_node)};
if (!types.count(klass)) {
++added;
klasses.insert(klass);
@@ -118,20 +117,17 @@ 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) {
const URI type(world.forge().str(t->second, false));
types.insert(type);
if (world.uris().ingen_Graph == type) {
- // Add lv2:Plugin as a type for graphs so plugin properties show up
+ // Add lv2:Plugin as a type so plugin properties show up
types.insert(world.uris().lv2_Plugin);
}
} else {
@@ -149,8 +145,8 @@ URISet
properties(World& world,
const std::shared_ptr<const client::ObjectModel>& model)
{
- URISet properties;
- URISet types = rdfs::types(world, model);
+ URISet properties;
+ const URISet types = rdfs::types(world, model);
LilvNode* rdf_type = lilv_new_uri(world.lilv_world(),
LILV_NS_RDF "type");
@@ -161,13 +157,13 @@ properties(World& world,
LilvNodes* props = lilv_world_find_nodes(
world.lilv_world(), nullptr, rdf_type, rdf_Property);
- LILV_FOREACH(nodes, p, props) {
+ LILV_FOREACH (nodes, p, props) {
const LilvNode* prop = lilv_nodes_get(props, p);
if (lilv_node_is_uri(prop)) {
LilvNodes* domains = lilv_world_find_nodes(
world.lilv_world(), prop, rdfs_domain, nullptr);
unsigned n_matching_domains = 0;
- LILV_FOREACH(nodes, d, domains) {
+ LILV_FOREACH (nodes, d, domains) {
const LilvNode* domain_node = lilv_nodes_get(domains, d);
if (!lilv_node_is_uri(domain_node)) {
// TODO: Blank node domains (e.g. unions)
@@ -208,7 +204,7 @@ instances(World& world, const URISet& types)
LilvNode* type = lilv_new_uri(world.lilv_world(), t.c_str());
LilvNodes* objects = lilv_world_find_nodes(
world.lilv_world(), nullptr, rdf_type, type);
- LILV_FOREACH(nodes, o, objects) {
+ LILV_FOREACH (nodes, o, objects) {
const LilvNode* object = lilv_nodes_get(objects, o);
if (!lilv_node_is_uri(object)) {
continue;
@@ -233,8 +229,10 @@ range(World& world, const LilvNode* prop, bool recursive)
world.lilv_world(), prop, rdfs_range, nullptr);
URISet ranges;
- LILV_FOREACH(nodes, n, nodes) {
- ranges.insert(URI(lilv_node_as_string(lilv_nodes_get(nodes, n))));
+ LILV_FOREACH (nodes, n, nodes) {
+ if (lilv_node_is_uri(lilv_nodes_get(nodes, n))) {
+ ranges.insert(URI(lilv_node_as_string(lilv_nodes_get(nodes, n))));
+ }
}
if (recursive) {
@@ -258,6 +256,4 @@ is_a(World& world, const LilvNode* inst, const LilvNode* klass)
return is_instance;
}
-} // namespace rdfs
-} // namespace gui
-} // namespace ingen
+} // namespace ingen::gui::rdfs