sord.h   sord.h 
skipping to change at line 153 skipping to change at line 153
Create a new Sord World. Create a new Sord World.
It is safe to use multiple worlds in one process, though no data It is safe to use multiple worlds in one process, though no data
(e.g. nodes) can be shared between worlds, and this should be avoided if (e.g. nodes) can be shared between worlds, and this should be avoided if
possible for performance reasons. possible for performance reasons.
*/ */
SORD_API SORD_API
SordWorld* SordWorld*
sord_world_new(void); sord_world_new(void);
/** /**
Free @c world. Free `world`.
*/ */
SORD_API SORD_API
void void
sord_world_free(SordWorld* world); sord_world_free(SordWorld* world);
/** /**
Set a function to be called when errors occur. Set a function to be called when errors occur.
The @p error_sink will be called with @p handle as its first argument. If The `error_sink` will be called with `handle` as its first argument. If
no error function is set, errors are printed to stderr. no error function is set, errors are printed to stderr.
*/ */
SORD_API SORD_API
void void
sord_world_set_error_sink(SordWorld* world, sord_world_set_error_sink(SordWorld* world,
SerdErrorSink error_sink, SerdErrorSink error_sink,
void* handle); void* handle);
/** /**
@} @}
@name Node @name Node
@{ @{
*/ */
/** /**
Get a URI node from a string. Get a URI node from a string.
Note this function measures @c str, which is a common bottleneck. Note this function measures `str`, which is a common bottleneck.
Use sord_node_from_serd_node instead if @c str is already measured. Use sord_node_from_serd_node instead if `str` is already measured.
*/ */
SORD_API SORD_API
SordNode* SordNode*
sord_new_uri(SordWorld* world, const uint8_t* uri); sord_new_uri(SordWorld* world, const uint8_t* uri);
/** /**
Get a URI node from a relative URI string. Get a URI node from a relative URI string.
*/ */
SORD_API SORD_API
SordNode* SordNode*
sord_new_relative_uri(SordWorld* world, sord_new_relative_uri(SordWorld* world,
const uint8_t* str, const uint8_t* str,
const uint8_t* base_uri); const uint8_t* base_uri);
/** /**
Get a blank node from a string. Get a blank node from a string.
Note this function measures @c str, which is a common bottleneck. Note this function measures `str`, which is a common bottleneck.
Use sord_node_from_serd_node instead if @c str is already measured. Use sord_node_from_serd_node instead if `str` is already measured.
*/ */
SORD_API SORD_API
SordNode* SordNode*
sord_new_blank(SordWorld* world, const uint8_t* str); sord_new_blank(SordWorld* world, const uint8_t* str);
/** /**
Get a literal node from a string. Get a literal node from a string.
Note this function measures @c str, which is a common bottleneck. Note this function measures `str`, which is a common bottleneck.
Use sord_node_from_serd_node instead if @c str is already measured. Use sord_node_from_serd_node instead if `str` is already measured.
*/ */
SORD_API SORD_API
SordNode* SordNode*
sord_new_literal(SordWorld* world, sord_new_literal(SordWorld* world,
SordNode* datatype, SordNode* datatype,
const uint8_t* str, const uint8_t* str,
const char* lang); const char* lang);
/** /**
Copy a node (obtain a reference). Copy a node (obtain a reference).
Node that since nodes are interned and reference counted, this does not Node that since nodes are interned and reference counted, this does not
actually create a deep copy of @c node. actually create a deep copy of `node`.
*/ */
SORD_API SORD_API
SordNode* SordNode*
sord_node_copy(const SordNode* node); sord_node_copy(const SordNode* node);
/** /**
Free a node (drop a reference). Free a node (drop a reference).
*/ */
SORD_API SORD_API
void void
skipping to change at line 251 skipping to change at line 251
sord_node_get_type(const SordNode* node); sord_node_get_type(const SordNode* node);
/** /**
Return the string value of a node. Return the string value of a node.
*/ */
SORD_API SORD_API
const uint8_t* const uint8_t*
sord_node_get_string(const SordNode* node); sord_node_get_string(const SordNode* node);
/** /**
Return the string value of a node, and set @c len to its length. Return the string value of a node, and set `len` to its length.
*/ */
SORD_API SORD_API
const uint8_t* const uint8_t*
sord_node_get_string_counted(const SordNode* node, size_t* len); sord_node_get_string_counted(const SordNode* node, size_t* len);
/** /**
Return the language of a literal node (or NULL). Return the language of a literal node (or NULL).
*/ */
SORD_API SORD_API
const char* const char*
skipping to change at line 290 skipping to change at line 290
More specifically, this returns true iff the node is the object field More specifically, this returns true iff the node is the object field
of exactly one statement, and therefore can be inlined since it needn't of exactly one statement, and therefore can be inlined since it needn't
be referred to by name. be referred to by name.
*/ */
SORD_API SORD_API
bool bool
sord_node_is_inline_object(const SordNode* node); sord_node_is_inline_object(const SordNode* node);
/** /**
Return true iff @c a is equal to @c b. Return true iff `a` is equal to `b`.
Note this is much faster than comparing the node's strings. Note this is much faster than comparing the node's strings.
*/ */
SORD_API SORD_API
bool bool
sord_node_equals(const SordNode* a, sord_node_equals(const SordNode* a,
const SordNode* b); const SordNode* b);
/** /**
Return a SordNode as a SerdNode. Return a SordNode as a SerdNode.
skipping to change at line 345 skipping to change at line 345
@param graphs If true, store (and index) graph contexts. @param graphs If true, store (and index) graph contexts.
*/ */
SORD_API SORD_API
SordModel* SordModel*
sord_new(SordWorld* world, sord_new(SordWorld* world,
unsigned indices, unsigned indices,
bool graphs); bool graphs);
/** /**
Close and free @c model. Close and free `model`.
*/ */
SORD_API SORD_API
void void
sord_free(SordModel* model); sord_free(SordModel* model);
/** /**
Get the world associated with @c model. Get the world associated with `model`.
*/ */
SORD_API SORD_API
SordWorld* SordWorld*
sord_get_world(SordModel* model); sord_get_world(SordModel* model);
/** /**
Return the number of nodes stored in @c world. Return the number of nodes stored in `world`.
Nodes are included in this count iff they are a part of a quad in @c wor ld. Nodes are included in this count iff they are a part of a quad in `world `.
*/ */
SORD_API SORD_API
size_t size_t
sord_num_nodes(const SordWorld* world); sord_num_nodes(const SordWorld* world);
/** /**
Return the number of quads stored in @c model. Return the number of quads stored in `model`.
*/ */
SORD_API SORD_API
size_t size_t
sord_num_quads(const SordModel* model); sord_num_quads(const SordModel* model);
/** /**
Return an iterator to the start of @c model. Return an iterator to the start of `model`.
*/ */
SORD_API SORD_API
SordIter* SordIter*
sord_begin(const SordModel* model); sord_begin(const SordModel* model);
/** /**
Search for statements by a quad pattern. Search for statements by a quad pattern.
@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
skipping to change at line 402 skipping to change at line 402
*/ */
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. Search for a single node that matches a pattern.
Exactly one of @p s, @p p, @p o must be NULL. Exactly one of `s`, `p`, `o` must be NULL.
This function is mainly useful for predicates that only have one value. This function is mainly useful for predicates that only have one value.
The returned node must be freed using sord_node_free. The returned node must be freed using sord_node_free.
@return the first matching node, or NULL if no matches are found. @return the first matching node, or NULL if no matches are found.
*/ */
SORD_API SORD_API
SordNode* SordNode*
sord_get(SordModel* model, sord_get(SordModel* model,
const SordNode* s, const SordNode* s,
const SordNode* p, const SordNode* p,
const SordNode* o, const SordNode* o,
skipping to change at line 438 skipping to change at line 438
*/ */
SORD_API SORD_API
uint64_t uint64_t
sord_count(SordModel* model, sord_count(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);
/** /**
Check if @a model contains a triple pattern. Check if `model` contains a triple pattern.
*/ */
SORD_API SORD_API
bool bool
sord_contains(SordModel* model, const SordQuad pat); sord_contains(SordModel* model, const SordQuad pat);
/** /**
Add a quad to a model. Add a quad to a model.
*/ */
SORD_API SORD_API
bool bool
sord_add(SordModel* model, const SordQuad quad); sord_add(SordModel* model, const SordQuad quad);
/** /**
Remove a quad from a model. Remove a quad from a model.
Note that is it illegal to remove while iterating over @c model. Note that is it illegal to remove while iterating over `model`.
*/ */
SORD_API SORD_API
void void
sord_remove(SordModel* model, const SordQuad quad); sord_remove(SordModel* model, const SordQuad quad);
/** /**
@} @}
@name Inserter @name Inserter
@{ @{
*/ */
skipping to change at line 525 skipping to change at line 525
const SerdNode* object_datatype, const SerdNode* object_datatype,
const SerdNode* object_lang); const SerdNode* object_lang);
/** /**
@} @}
@name Iteration @name Iteration
@{ @{
*/ */
/** /**
Set @c quad to the quad pointed to by @c iter. Set `quad` to the quad pointed to by `iter`.
*/ */
SORD_API SORD_API
void void
sord_iter_get(const SordIter* iter, SordQuad quad); sord_iter_get(const SordIter* iter, SordQuad quad);
/** /**
Return a field of the quad pointed to by @c iter. Return a field of the quad pointed to by `iter`.
*/ */
SORD_API SORD_API
const SordNode* const SordNode*
sord_iter_get_node(const SordIter* iter, SordQuadIndex index); sord_iter_get_node(const SordIter* iter, SordQuadIndex index);
/** /**
Return the store pointed to by @c iter. Return the store pointed to by `iter`.
*/ */
SORD_API SORD_API
const SordModel* const SordModel*
sord_iter_get_model(SordIter* iter); sord_iter_get_model(SordIter* iter);
/** /**
Increment @c iter to point to the next statement. Increment `iter` to point to the next statement.
*/ */
SORD_API SORD_API
bool bool
sord_iter_next(SordIter* iter); sord_iter_next(SordIter* iter);
/** /**
Return true iff @c iter is at the end of its range. Return true iff `iter` is at the end of its range.
*/ */
SORD_API SORD_API
bool bool
sord_iter_end(const SordIter* iter); sord_iter_end(const SordIter* iter);
/** /**
Free @c iter. Free `iter`.
*/ */
SORD_API SORD_API
void void
sord_iter_free(SordIter* iter); sord_iter_free(SordIter* iter);
/** /**
@} @}
@name Utilities @name Utilities
@{ @{
*/ */
/** /**
Match two quads (using ID comparison only). Match two quads (using ID comparison only).
This function is a straightforward and fast equivalence match with wildc ard This function is a straightforward and fast equivalence match with wildc ard
support (ID 0 is a wildcard). It does not actually read node data. support (ID 0 is a wildcard). It does not actually read node data.
@return true iff @c x and @c y match. @return true iff `x` and `y` match.
*/ */
SORD_API SORD_API
bool bool
sord_quad_match(const SordQuad x, const SordQuad y); sord_quad_match(const SordQuad x, const SordQuad y);
/** /**
@} @}
@name Serialisation @name Serialisation
@{ @{
*/ */
/** /**
Return a reader that will read into @c model. Return a reader that will read into `model`.
*/ */
SORD_API SORD_API
SerdReader* SerdReader*
sord_new_reader(SordModel* model, sord_new_reader(SordModel* model,
SerdEnv* env, SerdEnv* env,
SerdSyntax syntax, SerdSyntax syntax,
SordNode* graph); SordNode* graph);
/** /**
Write a model to a writer. Write a model to a writer.
*/ */
SORD_API SORD_API
bool bool
sord_write(SordModel* model, sord_write(SordModel* model,
SerdWriter* writer, SerdWriter* writer,
SordNode* graph); SordNode* graph);
/** /**
Write a range to a writer. Write a range to a writer.
This increments @c iter to its end, then frees it. This increments `iter` to its end, then frees it.
*/ */
SORD_API SORD_API
bool bool
sord_write_iter(SordIter* iter, sord_write_iter(SordIter* iter,
SerdWriter* writer); SerdWriter* writer);
/** /**
@} @}
@} @}
*/ */
 End of changes. 26 change blocks. 
29 lines changed or deleted 29 lines changed or added


 sordmm.hpp   sordmm.hpp 
skipping to change at line 476 skipping to change at line 476
const Node& predicate, const Node& predicate,
const Node& object); const Node& object);
inline Node get(const Node& subject, inline Node get(const Node& subject,
const Node& predicate, const Node& predicate,
const Node& object); 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;
size_t _next_blank_id;
}; };
/** Create an empty in-memory RDF model. /** Create an empty in-memory RDF model.
*/ */
inline inline
Model::Model(World& world, Model::Model(World& world,
const std::string& base_uri, const std::string& base_uri,
unsigned indices, unsigned indices,
bool graphs) bool graphs)
: _world(world) : _world(world)
, _base(world, Node::URI, base_uri) , _base(world, Node::URI, base_uri)
, _writer(NULL)
{ {
_c_obj = sord_new(_world.world(), indices, graphs); _c_obj = sord_new(_world.world(), indices, graphs);
} }
inline void inline void
Model::load_string(SerdEnv* env, Model::load_string(SerdEnv* env,
SerdSyntax syntax, SerdSyntax syntax,
const char* str, const char* str,
size_t len, size_t len,
const std::string& base_uri) const std::string& base_uri)
 End of changes. 2 change blocks. 
5 lines changed or deleted 2 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/