sord.h   sord.h 
/* /*
Copyright 2011-2012 David Robillard <http://drobilla.net> Copyright 2011-2013 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies. copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
skipping to change at line 400 skipping to change at line 400
Search for statements by nodes. Search for statements by nodes.
@return an iterator to the first match, or NULL if no matches found. @return an iterator to the first match, or NULL if no matches found.
*/ */
SORD_API SORD_API
SordIter* SordIter*
sord_search(SordModel* model, sord_search(SordModel* model,
const SordNode* s, const SordNode* s,
const SordNode* p, const SordNode* p,
const SordNode* o, const SordNode* o,
const SordNode* g); 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.
The returned node must be freed using sord_node_free.
@return the first matching node, or NULL if no matches are found.
*/
SORD_API
SordNode*
sord_get(SordModel* model,
const SordNode* s,
const SordNode* p,
const SordNode* o,
const SordNode* g);
/** /**
Return true iff a statement exists. Return true iff a statement exists.
*/ */
SORD_API SORD_API
bool bool
sord_ask(SordModel* model, sord_ask(SordModel* model,
const SordNode* s, const SordNode* s,
const SordNode* p, const SordNode* p,
const SordNode* o, const SordNode* o,
 End of changes. 2 change blocks. 
1 lines changed or deleted 15 lines changed or added


 sordmm.hpp   sordmm.hpp 
/* /*
Copyright 2011-2012 David Robillard <http://drobilla.net> Copyright 2011-2013 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies. copyright notice and this permission notice appear in all copies.
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
skipping to change at line 116 skipping to change at line 116
} }
}; };
/** Sord library state. */ /** Sord library state. */
class World : public Noncopyable, public Wrapper<SordWorld*> { class World : public Noncopyable, public Wrapper<SordWorld*> {
public: public:
inline World() inline World()
: _next_blank_id(0) : _next_blank_id(0)
{ {
_c_obj = sord_world_new(); _c_obj = sord_world_new();
add_prefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-n s#");
} }
inline ~World() { inline ~World() {
sord_world_free(_c_obj); sord_world_free(_c_obj);
} }
inline uint64_t blank_id() { return _next_blank_id++; } inline uint64_t blank_id() { return _next_blank_id++; }
inline void add_prefix(const std::string& prefix, const std::string& uri) { inline void add_prefix(const std::string& prefix, const std::string& uri) {
_prefixes.add(prefix, uri); _prefixes.add(prefix, uri);
skipping to change at line 154 skipping to change at line 153
URI = SORD_URI, URI = SORD_URI,
BLANK = SORD_BLANK, BLANK = SORD_BLANK,
LITERAL = SORD_LITERAL LITERAL = SORD_LITERAL
}; };
inline Node() : Wrapper<SordNode*>(NULL), _world(NULL) {} inline Node() : Wrapper<SordNode*>(NULL), _world(NULL) {}
inline Node(World& world, Type t, const std::string& s); inline Node(World& world, Type t, const std::string& s);
inline Node(World& world); inline Node(World& world);
inline Node(World& world, const SordNode* node); inline Node(World& world, const SordNode* node);
inline Node(World& world, SordNode* node, bool copy=false);
inline Node(const Node& other); inline Node(const Node& other);
inline ~Node(); inline ~Node();
inline Type type() const { inline Type type() const {
return _c_obj ? (Type)sord_node_get_type(_c_obj) : UNKNOWN; return _c_obj ? (Type)sord_node_get_type(_c_obj) : UNKNOWN;
} }
inline const SordNode* get_node() const { return _c_obj; } inline const SordNode* get_node() const { return _c_obj; }
inline SordNode* get_node() { return _c_obj; } inline SordNode* get_node() { return _c_obj; }
const SerdNode* to_serd_node() {
return sord_node_to_serd_node(_c_obj);
}
inline bool is_valid() const { return type() != UNKNOWN; } inline bool is_valid() const { return type() != UNKNOWN; }
inline bool operator<(const Node& other) const { inline bool operator<(const Node& other) const {
if (type() != other.type()) { if (type() != other.type()) {
return type() < other.type(); return type() < other.type();
} else { } else {
return to_string() < other.to_string(); return to_string() < other.to_string();
} }
} }
skipping to change at line 243 skipping to change at line 247
class Curie : public Node { class Curie : public Node {
public: public:
inline Curie(World& world, const std::string& s) inline Curie(World& world, const std::string& s)
: Node(world, Node::URI, world.prefixes().expand(s)) {} : Node(world, Node::URI, world.prefixes().expand(s)) {}
}; };
class Literal : public Node { class Literal : public Node {
public: public:
inline Literal(World& world, const std::string& s) inline Literal(World& world, const std::string& s)
: Node(world, Node::LITERAL, s) {} : Node(world, Node::LITERAL, s) {}
static inline Node decimal(World& world, double d, unsigned frac_dig
its) {
const SerdNode val = serd_node_new_decimal(d, 7);
const SerdNode type = serd_node_from_string(
SERD_URI, (const uint8_t*)SORD_NS_XSD "decimal");
return Node(
world,
sord_node_from_serd_node(
world.c_obj(), world.prefixes().c_obj(), &va
l, &type, NULL),
false);
}
static inline Node integer(World& world, int64_t i) {
const SerdNode val = serd_node_new_integer(i);
const SerdNode type = serd_node_from_string(
SERD_URI, (const uint8_t*)SORD_NS_XSD "integer");
return Node(
world,
sord_node_from_serd_node(
world.c_obj(), world.prefixes().c_obj(), &va
l, &type, NULL),
false);
}
}; };
inline inline
Node::Node(World& world, Type type, const std::string& s) Node::Node(World& world, Type type, const std::string& s)
: _world(&world) : _world(&world)
{ {
switch (type) { switch (type) {
case URI: case URI:
_c_obj = sord_new_uri( _c_obj = sord_new_uri(
world.world(), (const unsigned char*)s.c_str()); world.world(), (const unsigned char*)s.c_str());
skipping to change at line 281 skipping to change at line 309
: _world(&world) : _world(&world)
{ {
Node me = blank_id(world); Node me = blank_id(world);
*this = me; *this = me;
} }
inline inline
Node::Node(World& world, const SordNode* node) Node::Node(World& world, const SordNode* node)
: _world(&world) : _world(&world)
{ {
_c_obj = node ? sord_node_copy(node) : NULL; _c_obj = sord_node_copy(node);
}
inline
Node::Node(World& world, SordNode* node, bool copy)
: _world(&world)
{
_c_obj = copy ? sord_node_copy(node) : node;
} }
inline inline
Node::Node(const Node& other) Node::Node(const Node& other)
: Wrapper<SordNode*>() : Wrapper<SordNode*>()
, _world(other._world) , _world(other._world)
{ {
if (_world) { if (_world) {
_c_obj = other._c_obj ? sord_node_copy(other._c_obj) : NULL; _c_obj = other._c_obj ? sord_node_copy(other._c_obj) : NULL;
} }
skipping to change at line 434 skipping to change at line 469
|SERD_STYLE_RESOLVED )); |SERD_STYLE_RESOLVED ));
inline void add_statement(const Node& subject, inline void add_statement(const Node& subject,
const Node& predicate, const Node& predicate,
const Node& object); const Node& object);
inline Iter find(const Node& subject, inline Iter find(const Node& subject,
const Node& predicate, const Node& predicate,
const Node& object); const Node& object);
inline Node get(const Node& subject,
const Node& predicate,
const Node& object);
inline World& world() const { return _world; } inline World& world() const { return _world; }
private: private:
World& _world; World& _world;
Node _base; Node _base;
SerdWriter* _writer; SerdWriter* _writer;
size_t _next_blank_id; size_t _next_blank_id;
}; };
/** Create an empty in-memory RDF model. /** Create an empty in-memory RDF model.
skipping to change at line 599 skipping to change at line 638
const Node& object) const Node& object)
{ {
SordQuad quad = { subject.c_obj(), SordQuad quad = { subject.c_obj(),
predicate.c_obj(), predicate.c_obj(),
object.c_obj(), object.c_obj(),
NULL }; NULL };
return Iter(_world, sord_find(_c_obj, quad)); return Iter(_world, sord_find(_c_obj, quad));
} }
inline Node
Model::get(const Node& subject,
const Node& predicate,
const Node& object)
{
SordNode* c_node = sord_get(
_c_obj, subject.c_obj(), predicate.c_obj(), object.c_obj(),
NULL);
Node node(_world, c_node);
sord_node_free(_world.c_obj(), c_node);
return node;
}
} // namespace Sord } // namespace Sord
#endif // SORD_SORDMM_HPP #endif // SORD_SORDMM_HPP
 End of changes. 8 change blocks. 
3 lines changed or deleted 58 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/