summaryrefslogtreecommitdiffstats
path: root/sord
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-01-14 06:53:05 +0000
committerDavid Robillard <d@drobilla.net>2013-01-14 06:53:05 +0000
commit5cd549c8e512d9a85d7d666db5da8b8a444a281f (patch)
tree2aa2c443cf9aaf675588242bf86e8c6e0fb547e5 /sord
parentfb40f19426ce147083c26c2fe9a9805f89fb8e9b (diff)
downloadsord-5cd549c8e512d9a85d7d666db5da8b8a444a281f.tar.gz
sord-5cd549c8e512d9a85d7d666db5da8b8a444a281f.tar.bz2
sord-5cd549c8e512d9a85d7d666db5da8b8a444a281f.zip
Add sord_node_get() for easily getting single property values.
git-svn-id: http://svn.drobilla.net/sord/trunk@280 3d64ff67-21c5-427c-a301-fe4f08042e5a
Diffstat (limited to 'sord')
-rw-r--r--sord/sord.h13
-rw-r--r--sord/sordmm.hpp16
2 files changed, 29 insertions, 0 deletions
diff --git a/sord/sord.h b/sord/sord.h
index 8f1ef38..ee49764 100644
--- a/sord/sord.h
+++ b/sord/sord.h
@@ -397,6 +397,19 @@ sord_search(SordModel* model,
const SordNode* p,
const SordNode* o,
const SordNode* g);
+/**
+ Search for a single node that matches a pattern.
+ Exactly one of @p s, @p p, @p o must be NULL.
+ This function is mainly useful for predicates that only have one value.
+ @return the first matching node, or NULL if no matches are found.
+*/
+SORD_API
+const SordNode*
+sord_get(SordModel* model,
+ const SordNode* s,
+ const SordNode* p,
+ const SordNode* o,
+ const SordNode* g);
/**
Return true iff a statement exists.
diff --git a/sord/sordmm.hpp b/sord/sordmm.hpp
index 4ab25e2..da1e49c 100644
--- a/sord/sordmm.hpp
+++ b/sord/sordmm.hpp
@@ -466,6 +466,10 @@ public:
const Node& predicate,
const Node& object);
+ inline Node get(const Node& subject,
+ const Node& predicate,
+ const Node& object);
+
inline World& world() const { return _world; }
private:
@@ -631,6 +635,18 @@ Model::find(const Node& subject,
return Iter(_world, sord_find(_c_obj, quad));
}
+inline Node
+Model::get(const Node& subject,
+ const Node& predicate,
+ const Node& object)
+{
+ return Node(_world, sord_get(_c_obj,
+ subject.c_obj(),
+ predicate.c_obj(),
+ object.c_obj(),
+ NULL));
+}
+
} // namespace Sord
#endif // SORD_SORDMM_HPP