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