Chris@0: /* Chris@0: Copyright 2011-2013 David Robillard Chris@0: Chris@0: Permission to use, copy, modify, and/or distribute this software for any Chris@0: purpose with or without fee is hereby granted, provided that the above Chris@0: copyright notice and this permission notice appear in all copies. Chris@0: Chris@0: THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES Chris@0: WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF Chris@0: MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR Chris@0: ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES Chris@0: WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN Chris@0: ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF Chris@0: OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Chris@0: */ Chris@0: Chris@0: /** Chris@0: @file sordmm.hpp Chris@0: Public Sord C++ API. Chris@0: */ Chris@0: Chris@0: #ifndef SORD_SORDMM_HPP Chris@0: #define SORD_SORDMM_HPP Chris@0: Chris@0: #include Chris@0: #include Chris@0: #include Chris@0: #include Chris@0: #include Chris@0: #include Chris@0: #include Chris@0: Chris@0: #include "serd/serd.h" Chris@0: #include "sord/sord.h" Chris@0: Chris@0: #define SORD_NS_XSD "http://www.w3.org/2001/XMLSchema#" Chris@0: Chris@0: namespace Sord { Chris@0: Chris@0: /** Utility base class to prevent copying. */ Chris@0: class Noncopyable { Chris@0: protected: Chris@0: Noncopyable() {} Chris@0: ~Noncopyable() {} Chris@0: private: Chris@0: Noncopyable(const Noncopyable&); Chris@0: const Noncopyable& operator=(const Noncopyable&); Chris@0: }; Chris@0: Chris@0: /** C++ wrapper for a Sord object. */ Chris@0: template Chris@0: class Wrapper { Chris@0: public: Chris@0: inline Wrapper(T c_obj = NULL) : _c_obj(c_obj) {} Chris@0: Chris@0: inline T c_obj() { return _c_obj; } Chris@0: inline const T c_obj() const { return _c_obj; } Chris@0: Chris@0: protected: Chris@0: T _c_obj; Chris@0: }; Chris@0: Chris@0: /** Collection of RDF namespaces with prefixes. */ Chris@0: class Namespaces : public Wrapper { Chris@0: public: Chris@0: Namespaces() : Wrapper(serd_env_new(NULL)) {} Chris@0: ~Namespaces() { serd_env_free(_c_obj); } Chris@0: Chris@0: static inline SerdNode string_to_node(SerdType type, const std::string& s) { Chris@0: SerdNode ret = { Chris@0: (const uint8_t*)s.c_str(), s.length(), s.length(), 0, type }; Chris@0: return ret; Chris@0: } Chris@0: Chris@0: inline void add(const std::string& name, Chris@0: const std::string& uri) { Chris@0: const SerdNode name_node = string_to_node(SERD_LITERAL, name); Chris@0: const SerdNode uri_node = string_to_node(SERD_URI, uri); Chris@0: serd_env_set_prefix(_c_obj, &name_node, &uri_node); Chris@0: } Chris@0: Chris@0: inline std::string qualify(std::string uri) const { Chris@0: const SerdNode uri_node = string_to_node(SERD_URI, uri); Chris@0: SerdNode prefix; Chris@0: SerdChunk suffix; Chris@0: if (serd_env_qualify(_c_obj, &uri_node, &prefix, &suffix)) { Chris@0: std::string ret((const char*)prefix.buf, prefix.n_bytes); Chris@0: ret.append(":").append((const char*)suffix.buf, suffix.len); Chris@0: return ret; Chris@0: } Chris@0: return uri; Chris@0: } Chris@0: Chris@0: inline std::string expand(const std::string& curie) const { Chris@0: assert(curie.find(":") != std::string::npos); Chris@0: SerdNode curie_node = string_to_node(SERD_CURIE, curie); Chris@0: SerdChunk uri_prefix; Chris@0: SerdChunk uri_suffix; Chris@0: if (!serd_env_expand(_c_obj, &curie_node, &uri_prefix, &uri_suffix)) { Chris@0: std::string ret((const char*)uri_prefix.buf, uri_prefix.len); Chris@0: ret.append((const char*)uri_suffix.buf, uri_suffix.len); Chris@0: return ret; Chris@0: } Chris@0: std::cerr << "CURIE `" << curie << "' has unknown prefix." << std::endl; Chris@0: return curie; Chris@0: } Chris@0: }; Chris@0: Chris@0: /** Sord library state. */ Chris@0: class World : public Noncopyable, public Wrapper { Chris@0: public: Chris@0: inline World() Chris@0: : _next_blank_id(0) Chris@0: { Chris@0: _c_obj = sord_world_new(); Chris@0: } Chris@0: Chris@0: inline ~World() { Chris@0: sord_world_free(_c_obj); Chris@0: } Chris@0: Chris@0: inline uint64_t blank_id() { return _next_blank_id++; } Chris@0: Chris@0: inline void add_prefix(const std::string& prefix, const std::string& uri) { Chris@0: _prefixes.add(prefix, uri); Chris@0: } Chris@0: Chris@0: inline const Namespaces& prefixes() const { return _prefixes; } Chris@0: inline SordWorld* world() { return _c_obj; } Chris@0: Chris@0: private: Chris@0: Namespaces _prefixes; Chris@0: std::set _blank_ids; Chris@0: uint64_t _next_blank_id; Chris@0: }; Chris@0: Chris@0: /** An RDF Node (resource, literal, etc) Chris@0: */ Chris@0: class Node : public Wrapper { Chris@0: public: Chris@0: enum Type { Chris@0: UNKNOWN = 0, Chris@0: URI = SORD_URI, Chris@0: BLANK = SORD_BLANK, Chris@0: LITERAL = SORD_LITERAL Chris@0: }; Chris@0: Chris@0: inline Node() : Wrapper(NULL), _world(NULL) {} Chris@0: Chris@0: inline Node(World& world, Type t, const std::string& s); Chris@0: inline Node(World& world); Chris@0: inline Node(World& world, const SordNode* node); Chris@0: inline Node(World& world, SordNode* node, bool copy=false); Chris@0: inline Node(const Node& other); Chris@0: inline ~Node(); Chris@0: Chris@0: inline Type type() const { Chris@0: return _c_obj ? (Type)sord_node_get_type(_c_obj) : UNKNOWN; Chris@0: } Chris@0: Chris@0: inline const SordNode* get_node() const { return _c_obj; } Chris@0: inline SordNode* get_node() { return _c_obj; } Chris@0: Chris@0: const SerdNode* to_serd_node() { Chris@0: return sord_node_to_serd_node(_c_obj); Chris@0: } Chris@0: Chris@0: inline bool is_valid() const { return type() != UNKNOWN; } Chris@0: Chris@0: inline bool operator<(const Node& other) const { Chris@0: if (type() != other.type()) { Chris@0: return type() < other.type(); Chris@0: } else { Chris@0: return to_string() < other.to_string(); Chris@0: } Chris@0: } Chris@0: Chris@0: Node& operator=(const Node& other) { Chris@0: if (&other != this) { Chris@0: if (_c_obj) { Chris@0: sord_node_free(_world->c_obj(), _c_obj); Chris@0: } Chris@0: _world = other._world; Chris@0: _c_obj = other._c_obj ? sord_node_copy(other._c_obj) : NULL; Chris@0: } Chris@0: return *this; Chris@0: } Chris@0: Chris@0: inline bool operator==(const Node& other) const { Chris@0: return sord_node_equals(_c_obj, other._c_obj); Chris@0: } Chris@0: Chris@0: inline const uint8_t* to_u_string() const; Chris@0: inline const char* to_c_string() const; Chris@0: inline std::string to_string() const; Chris@0: Chris@0: inline bool is_literal_type(const char* type_uri) const; Chris@0: Chris@0: inline bool is_uri() const { return _c_obj && type() == URI; } Chris@0: inline bool is_blank() const { return _c_obj && type() == BLANK; } Chris@0: inline bool is_int() const { return is_literal_type(SORD_NS_XSD "integer"); } Chris@0: inline bool is_float() const { return is_literal_type(SORD_NS_XSD "decimal"); } Chris@0: inline bool is_bool() const { return is_literal_type(SORD_NS_XSD "boolean"); } Chris@0: Chris@0: inline int to_int() const; Chris@0: inline float to_float() const; Chris@0: inline bool to_bool() const; Chris@0: Chris@0: inline static Node blank_id(World& world, const std::string base="b") { Chris@0: const uint64_t num = world.blank_id(); Chris@0: std::ostringstream ss; Chris@0: ss << base << num; Chris@0: return Node(world, Node::BLANK, ss.str()); Chris@0: } Chris@0: Chris@0: private: Chris@0: World* _world; Chris@0: }; Chris@0: Chris@0: inline std::ostream& Chris@0: operator<<(std::ostream& os, const Node& node) Chris@0: { Chris@0: return os << node.to_string(); Chris@0: } Chris@0: Chris@0: class URI : public Node { Chris@0: public: Chris@0: inline URI(World& world, const std::string& s) Chris@0: : Node(world, Node::URI, s) {} Chris@0: inline URI(World& world, const std::string& s, const std::string& base) Chris@0: : Node(world, sord_new_relative_uri(world.world(), Chris@0: (const uint8_t*)s.c_str(), Chris@0: (const uint8_t*)base.c_str())) Chris@0: {} Chris@0: }; Chris@0: Chris@0: class Curie : public Node { Chris@0: public: Chris@0: inline Curie(World& world, const std::string& s) Chris@0: : Node(world, Node::URI, world.prefixes().expand(s)) {} Chris@0: }; Chris@0: Chris@0: class Literal : public Node { Chris@0: public: Chris@0: inline Literal(World& world, const std::string& s) Chris@0: : Node(world, Node::LITERAL, s) {} Chris@0: Chris@0: static inline Node decimal(World& world, double d, unsigned frac_digits) { Chris@0: const SerdNode val = serd_node_new_decimal(d, 7); Chris@0: const SerdNode type = serd_node_from_string( Chris@0: SERD_URI, (const uint8_t*)SORD_NS_XSD "decimal"); Chris@0: Chris@0: return Node( Chris@0: world, Chris@0: sord_node_from_serd_node( Chris@0: world.c_obj(), world.prefixes().c_obj(), &val, &type, NULL), Chris@0: false); Chris@0: } Chris@0: Chris@0: static inline Node integer(World& world, int64_t i) { Chris@0: const SerdNode val = serd_node_new_integer(i); Chris@0: const SerdNode type = serd_node_from_string( Chris@0: SERD_URI, (const uint8_t*)SORD_NS_XSD "integer"); Chris@0: Chris@0: return Node( Chris@0: world, Chris@0: sord_node_from_serd_node( Chris@0: world.c_obj(), world.prefixes().c_obj(), &val, &type, NULL), Chris@0: false); Chris@0: } Chris@0: }; Chris@0: Chris@0: inline Chris@0: Node::Node(World& world, Type type, const std::string& s) Chris@0: : _world(&world) Chris@0: { Chris@0: switch (type) { Chris@0: case URI: Chris@0: _c_obj = sord_new_uri( Chris@0: world.world(), (const unsigned char*)s.c_str()); Chris@0: break; Chris@0: case LITERAL: Chris@0: _c_obj = sord_new_literal( Chris@0: world.world(), NULL, (const unsigned char*)s.c_str(), NULL); Chris@0: break; Chris@0: case BLANK: Chris@0: _c_obj = sord_new_blank( Chris@0: world.world(), (const unsigned char*)s.c_str()); Chris@0: break; Chris@0: default: Chris@0: _c_obj = NULL; Chris@0: } Chris@0: Chris@0: assert(this->type() == type); Chris@0: } Chris@0: Chris@0: inline Chris@0: Node::Node(World& world) Chris@0: : _world(&world) Chris@0: { Chris@0: Node me = blank_id(world); Chris@0: *this = me; Chris@0: } Chris@0: Chris@0: inline Chris@0: Node::Node(World& world, const SordNode* node) Chris@0: : _world(&world) Chris@0: { Chris@0: _c_obj = sord_node_copy(node); Chris@0: } Chris@0: Chris@0: inline Chris@0: Node::Node(World& world, SordNode* node, bool copy) Chris@0: : _world(&world) Chris@0: { Chris@0: _c_obj = copy ? sord_node_copy(node) : node; Chris@0: } Chris@0: Chris@0: inline Chris@0: Node::Node(const Node& other) Chris@0: : Wrapper() Chris@0: , _world(other._world) Chris@0: { Chris@0: if (_world) { Chris@0: _c_obj = other._c_obj ? sord_node_copy(other._c_obj) : NULL; Chris@0: } Chris@0: Chris@0: assert((!_c_obj && !other._c_obj) || to_string() == other.to_string()); Chris@0: } Chris@0: Chris@0: inline Chris@0: Node::~Node() Chris@0: { Chris@0: if (_world) { Chris@0: sord_node_free(_world->c_obj(), _c_obj); Chris@0: } Chris@0: } Chris@0: Chris@0: inline std::string Chris@0: Node::to_string() const Chris@0: { Chris@0: return _c_obj ? (const char*)sord_node_get_string(_c_obj) : ""; Chris@0: } Chris@0: Chris@0: inline const char* Chris@0: Node::to_c_string() const Chris@0: { Chris@0: return (const char*)sord_node_get_string(_c_obj); Chris@0: } Chris@0: Chris@0: inline const uint8_t* Chris@0: Node::to_u_string() const Chris@0: { Chris@0: return sord_node_get_string(_c_obj); Chris@0: } Chris@0: Chris@0: inline bool Chris@0: Node::is_literal_type(const char* type_uri) const Chris@0: { Chris@0: if (_c_obj && sord_node_get_type(_c_obj) == SORD_LITERAL) { Chris@0: const SordNode* datatype = sord_node_get_datatype(_c_obj); Chris@0: if (datatype && !strcmp((const char*)sord_node_get_string(datatype), Chris@0: type_uri)) Chris@0: return true; Chris@0: } Chris@0: return false; Chris@0: } Chris@0: Chris@0: inline int Chris@0: Node::to_int() const Chris@0: { Chris@0: assert(is_int()); Chris@0: char* endptr; Chris@0: return strtol((const char*)sord_node_get_string(_c_obj), &endptr, 10); Chris@0: } Chris@0: Chris@0: inline float Chris@0: Node::to_float() const Chris@0: { Chris@0: assert(is_float()); Chris@0: char* endptr; Chris@0: return serd_strtod((const char*)sord_node_get_string(_c_obj), &endptr); Chris@0: } Chris@0: Chris@0: inline bool Chris@0: Node::to_bool() const Chris@0: { Chris@0: assert(is_bool()); Chris@0: return !strcmp((const char*)sord_node_get_string(_c_obj), "true"); Chris@0: } Chris@0: Chris@0: struct Iter : public Wrapper { Chris@0: inline Iter(World& world, SordIter* c_obj) Chris@0: : Wrapper(c_obj), _world(world) {} Chris@0: inline ~Iter() { sord_iter_free(_c_obj); } Chris@0: inline bool end() const { return sord_iter_end(_c_obj); } Chris@0: inline bool next() const { return sord_iter_next(_c_obj); } Chris@0: inline Iter& operator++() { Chris@0: assert(!end()); Chris@0: next(); Chris@0: return *this; Chris@0: } Chris@0: inline const Node get_subject() const { Chris@0: SordQuad quad; Chris@0: sord_iter_get(_c_obj, quad); Chris@0: return Node(_world, quad[SORD_SUBJECT]); Chris@0: } Chris@0: inline const Node get_predicate() const { Chris@0: SordQuad quad; Chris@0: sord_iter_get(_c_obj, quad); Chris@0: return Node(_world, quad[SORD_PREDICATE]); Chris@0: } Chris@0: inline const Node get_object() const { Chris@0: SordQuad quad; Chris@0: sord_iter_get(_c_obj, quad); Chris@0: return Node(_world, quad[SORD_OBJECT]); Chris@0: } Chris@0: World& _world; Chris@0: }; Chris@0: Chris@0: /** An RDF Model (collection of triples). Chris@0: */ Chris@0: class Model : public Noncopyable, public Wrapper { Chris@0: public: Chris@0: inline Model(World& world, Chris@0: const std::string& base_uri, Chris@0: unsigned indices = (SORD_SPO | SORD_OPS), Chris@0: bool graphs = true); Chris@0: Chris@0: inline ~Model(); Chris@0: Chris@0: inline const Node& base_uri() const { return _base; } Chris@0: Chris@0: size_t num_quads() const { return sord_num_quads(_c_obj); } Chris@0: Chris@0: inline void load_file(SerdEnv* env, Chris@0: SerdSyntax syntax, Chris@0: const std::string& uri, Chris@0: const std::string& base_uri=""); Chris@0: Chris@0: inline void load_string(SerdEnv* env, Chris@0: SerdSyntax syntax, Chris@0: const char* str, Chris@0: size_t len, Chris@0: const std::string& base_uri); Chris@0: Chris@0: inline SerdStatus write_to_file( Chris@0: const std::string& uri, Chris@0: SerdSyntax syntax = SERD_TURTLE, Chris@0: SerdStyle style = (SerdStyle)(SERD_STYLE_ABBREVIATED Chris@0: |SERD_STYLE_CURIED Chris@0: |SERD_STYLE_RESOLVED)); Chris@0: Chris@0: inline std::string write_to_string( Chris@0: const std::string& base_uri, Chris@0: SerdSyntax syntax = SERD_TURTLE, Chris@0: SerdStyle style = (SerdStyle)(SERD_STYLE_ABBREVIATED Chris@0: |SERD_STYLE_CURIED Chris@0: |SERD_STYLE_RESOLVED)); Chris@0: Chris@0: inline void add_statement(const Node& subject, Chris@0: const Node& predicate, Chris@0: const Node& object); Chris@0: Chris@0: inline Iter find(const Node& subject, Chris@0: const Node& predicate, Chris@0: const Node& object); Chris@0: Chris@0: inline Node get(const Node& subject, Chris@0: const Node& predicate, Chris@0: const Node& object); Chris@0: Chris@0: inline World& world() const { return _world; } Chris@0: Chris@0: private: Chris@0: World& _world; Chris@0: Node _base; Chris@0: SerdWriter* _writer; Chris@0: size_t _next_blank_id; Chris@0: }; Chris@0: Chris@0: /** Create an empty in-memory RDF model. Chris@0: */ Chris@0: inline Chris@0: Model::Model(World& world, Chris@0: const std::string& base_uri, Chris@0: unsigned indices, Chris@0: bool graphs) Chris@0: : _world(world) Chris@0: , _base(world, Node::URI, base_uri) Chris@0: , _writer(NULL) Chris@0: { Chris@0: _c_obj = sord_new(_world.world(), indices, graphs); Chris@0: } Chris@0: Chris@0: inline void Chris@0: Model::load_string(SerdEnv* env, Chris@0: SerdSyntax syntax, Chris@0: const char* str, Chris@0: size_t len, Chris@0: const std::string& base_uri) Chris@0: { Chris@0: SerdReader* reader = sord_new_reader(_c_obj, env, syntax, NULL); Chris@0: serd_reader_read_string(reader, (const uint8_t*)str); Chris@0: serd_reader_free(reader); Chris@0: } Chris@0: Chris@0: inline Model::~Model() Chris@0: { Chris@0: sord_free(_c_obj); Chris@0: } Chris@0: Chris@0: inline void Chris@0: Model::load_file(SerdEnv* env, Chris@0: SerdSyntax syntax, Chris@0: const std::string& data_uri, Chris@0: const std::string& base_uri) Chris@0: { Chris@0: uint8_t* path = serd_file_uri_parse((const uint8_t*)data_uri.c_str(), NULL); Chris@0: if (!path) { Chris@0: fprintf(stderr, "Failed to parse file URI <%s>\n", data_uri.c_str()); Chris@0: return; Chris@0: } Chris@0: Chris@0: // FIXME: blank prefix parameter? Chris@0: SerdReader* reader = sord_new_reader(_c_obj, env, syntax, NULL); Chris@0: serd_reader_read_file(reader, path); Chris@0: serd_reader_free(reader); Chris@0: free(path); Chris@0: } Chris@0: Chris@0: inline SerdStatus Chris@0: Model::write_to_file(const std::string& uri, SerdSyntax syntax, SerdStyle style) Chris@0: { Chris@0: uint8_t* path = serd_file_uri_parse((const uint8_t*)uri.c_str(), NULL); Chris@0: if (!path) { Chris@0: fprintf(stderr, "Failed to parse file URI <%s>\n", uri.c_str()); Chris@0: return SERD_ERR_BAD_ARG; Chris@0: } Chris@0: Chris@0: FILE* const fd = fopen((const char*)path, "w"); Chris@0: if (!fd) { Chris@0: fprintf(stderr, "Failed to open file %s\n", path); Chris@0: free(path); Chris@0: return SERD_ERR_UNKNOWN; Chris@0: } Chris@0: free(path); Chris@0: Chris@0: SerdURI base_uri = SERD_URI_NULL; Chris@0: if (serd_uri_parse((const uint8_t*)uri.c_str(), &base_uri)) { Chris@0: fprintf(stderr, "Invalid base URI <%s>\n", uri.c_str()); Chris@0: fclose(fd); Chris@0: return SERD_ERR_BAD_ARG; Chris@0: } Chris@0: Chris@0: SerdWriter* writer = serd_writer_new(syntax, Chris@0: style, Chris@0: _world.prefixes().c_obj(), Chris@0: &base_uri, Chris@0: serd_file_sink, Chris@0: fd); Chris@0: Chris@0: serd_env_foreach(_world.prefixes().c_obj(), Chris@0: (SerdPrefixSink)serd_writer_set_prefix, Chris@0: writer); Chris@0: Chris@0: sord_write(_c_obj, writer, 0); Chris@0: serd_writer_free(writer); Chris@0: fclose(fd); Chris@0: Chris@0: return SERD_SUCCESS; Chris@0: } Chris@0: Chris@0: static size_t Chris@0: string_sink(const void* buf, size_t len, void* stream) Chris@0: { Chris@0: std::string* str = (std::string*)stream; Chris@0: str->append((const char*)buf, len); Chris@0: return len; Chris@0: } Chris@0: Chris@0: inline std::string Chris@0: Model::write_to_string(const std::string& base_uri_str, Chris@0: SerdSyntax syntax, Chris@0: SerdStyle style) Chris@0: { Chris@0: SerdURI base_uri = SERD_URI_NULL; Chris@0: if (serd_uri_parse((const uint8_t*)base_uri_str.c_str(), &base_uri)) { Chris@0: fprintf(stderr, "Invalid base URI <%s>\n", base_uri_str.c_str()); Chris@0: return ""; Chris@0: } Chris@0: Chris@0: std::string ret; Chris@0: Chris@0: SerdWriter* writer = serd_writer_new(syntax, Chris@0: style, Chris@0: _world.prefixes().c_obj(), Chris@0: &base_uri, Chris@0: string_sink, Chris@0: &ret); Chris@0: Chris@0: serd_env_foreach(_world.prefixes().c_obj(), Chris@0: (SerdPrefixSink)serd_writer_set_prefix, Chris@0: writer); Chris@0: Chris@0: sord_write(_c_obj, writer, 0); Chris@0: Chris@0: serd_writer_free(writer); Chris@0: return ret; Chris@0: } Chris@0: Chris@0: inline void Chris@0: Model::add_statement(const Node& subject, Chris@0: const Node& predicate, Chris@0: const Node& object) Chris@0: { Chris@0: SordQuad quad = { subject.c_obj(), Chris@0: predicate.c_obj(), Chris@0: object.c_obj(), Chris@0: NULL }; Chris@0: Chris@0: sord_add(_c_obj, quad); Chris@0: } Chris@0: Chris@0: inline Iter Chris@0: Model::find(const Node& subject, Chris@0: const Node& predicate, Chris@0: const Node& object) Chris@0: { Chris@0: SordQuad quad = { subject.c_obj(), Chris@0: predicate.c_obj(), Chris@0: object.c_obj(), Chris@0: NULL }; Chris@0: Chris@0: return Iter(_world, sord_find(_c_obj, quad)); Chris@0: } Chris@0: Chris@0: inline Node Chris@0: Model::get(const Node& subject, Chris@0: const Node& predicate, Chris@0: const Node& object) Chris@0: { Chris@0: SordNode* c_node = sord_get( Chris@0: _c_obj, subject.c_obj(), predicate.c_obj(), object.c_obj(), NULL); Chris@0: Node node(_world, c_node); Chris@0: sord_node_free(_world.c_obj(), c_node); Chris@0: return node; Chris@0: } Chris@0: Chris@0: } // namespace Sord Chris@0: Chris@0: #endif // SORD_SORDMM_HPP Chris@0: