diff options
Diffstat (limited to 'sord')
-rw-r--r-- | sord/sord.h | 13 | ||||
-rw-r--r-- | sord/sordmm.hpp | 16 |
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 |