diff options
Diffstat (limited to 'include/sord/sord.h')
-rw-r--r-- | include/sord/sord.h | 150 |
1 files changed, 50 insertions, 100 deletions
diff --git a/include/sord/sord.h b/include/sord/sord.h index 93f9c07..663cb81 100644 --- a/include/sord/sord.h +++ b/include/sord/sord.h @@ -126,15 +126,13 @@ typedef enum { (e.g. nodes) can be shared between worlds, and this should be avoided if possible for performance reasons. */ -SORD_API -SordWorld* +SORD_API SordWorld* sord_world_new(void); /** Free `world`. */ -SORD_API -void +SORD_API void sord_world_free(SordWorld* world); /** @@ -143,8 +141,7 @@ sord_world_free(SordWorld* world); The `error_sink` will be called with `handle` as its first argument. If no error function is set, errors are printed to stderr. */ -SORD_API -void +SORD_API void sord_world_set_error_sink(SordWorld* world, SerdErrorSink error_sink, void* handle); @@ -161,15 +158,13 @@ sord_world_set_error_sink(SordWorld* world, Note this function measures `str`, which is a common bottleneck. Use sord_node_from_serd_node() instead if `str` is already measured. */ -SORD_API -SordNode* +SORD_API SordNode* sord_new_uri(SordWorld* world, const uint8_t* uri); /** Get a URI node from a relative URI string. */ -SORD_API -SordNode* +SORD_API SordNode* sord_new_relative_uri(SordWorld* world, const uint8_t* uri, const uint8_t* base_uri); @@ -180,8 +175,7 @@ sord_new_relative_uri(SordWorld* world, Note this function measures `str`, which is a common bottleneck. Use sord_node_from_serd_node() instead if `str` is already measured. */ -SORD_API -SordNode* +SORD_API SordNode* sord_new_blank(SordWorld* world, const uint8_t* str); /** @@ -190,8 +184,7 @@ sord_new_blank(SordWorld* world, const uint8_t* str); Note this function measures `str`, which is a common bottleneck. Use sord_node_from_serd_node() instead if `str` is already measured. */ -SORD_API -SordNode* +SORD_API SordNode* sord_new_literal(SordWorld* world, SordNode* datatype, const uint8_t* str, @@ -203,44 +196,38 @@ sord_new_literal(SordWorld* world, Node that since nodes are interned and reference counted, this does not actually create a deep copy of `node`. */ -SORD_API -SordNode* +SORD_API SordNode* sord_node_copy(const SordNode* node); /** Free a node (drop a reference). */ -SORD_API -void +SORD_API void sord_node_free(SordWorld* world, SordNode* node); /** Return the type of a node (SORD_URI, SORD_BLANK, or SORD_LITERAL). */ -SORD_API -SordNodeType +SORD_API SordNodeType sord_node_get_type(const SordNode* node); /** Return the string value of a node. */ -SORD_API -const uint8_t* +SORD_API const uint8_t* sord_node_get_string(const SordNode* node); /** Return the string value of a node, and set `bytes` to its length in bytes. */ -SORD_API -const uint8_t* +SORD_API const uint8_t* sord_node_get_string_counted(const SordNode* node, size_t* bytes); /** Return the string value of a node, and set `bytes` to its length in bytes, and `count` to its length in characters. */ -SORD_API -const uint8_t* +SORD_API const uint8_t* sord_node_get_string_measured(const SordNode* node, size_t* bytes, size_t* chars); @@ -248,22 +235,19 @@ sord_node_get_string_measured(const SordNode* node, /** Return the language of a literal node (or NULL). */ -SORD_API -const char* +SORD_API const char* sord_node_get_language(const SordNode* node); /** Return the datatype URI of a literal node (or NULL). */ -SORD_API -SordNode* +SORD_API SordNode* sord_node_get_datatype(const SordNode* node); /** Return the flags (string attributes) of a node. */ -SORD_API -SerdNodeFlags +SORD_API SerdNodeFlags sord_node_get_flags(const SordNode* node); /** @@ -273,8 +257,7 @@ sord_node_get_flags(const SordNode* node); of exactly one statement, and therefore can be inlined since it needn't be referred to by name. */ -SORD_API -bool +SORD_API bool sord_node_is_inline_object(const SordNode* node); /** @@ -282,8 +265,7 @@ sord_node_is_inline_object(const SordNode* node); Note this is much faster than comparing the node's strings. */ -SORD_API -bool +SORD_API bool sord_node_equals(const SordNode* a, const SordNode* b); /** @@ -291,8 +273,7 @@ sord_node_equals(const SordNode* a, const SordNode* b); The returned node is shared and must not be freed or modified. */ -SORD_API -const SerdNode* +SORD_API const SerdNode* sord_node_to_serd_node(const SordNode* node); /** @@ -300,8 +281,7 @@ sord_node_to_serd_node(const SordNode* node); The returned node must be freed using sord_node_free(). */ -SORD_API -SordNode* +SORD_API SordNode* sord_node_from_serd_node(SordWorld* world, SerdEnv* env, const SerdNode* node, @@ -325,22 +305,19 @@ sord_node_from_serd_node(SordWorld* world, @param graphs If true, store (and index) graph contexts. */ -SORD_API -SordModel* +SORD_API SordModel* sord_new(SordWorld* world, unsigned indices, bool graphs); /** Close and free `model`. */ -SORD_API -void +SORD_API void sord_free(SordModel* model); /** Get the world associated with `model`. */ -SORD_API -SordWorld* +SORD_API SordWorld* sord_get_world(SordModel* model); /** @@ -348,38 +325,33 @@ sord_get_world(SordModel* model); Nodes are included in this count iff they are a part of a quad in `world`. */ -SORD_API -size_t +SORD_API size_t sord_num_nodes(const SordWorld* world); /** Return the number of quads stored in `model`. */ -SORD_API -size_t +SORD_API size_t sord_num_quads(const SordModel* model); /** Return an iterator to the start of `model`. */ -SORD_API -SordIter* +SORD_API SordIter* sord_begin(const SordModel* model); /** Search for statements by a quad pattern. @return an iterator to the first match, or NULL if no matches found. */ -SORD_API -SordIter* +SORD_API SordIter* sord_find(SordModel* model, const SordQuad pat); /** Search for statements by nodes. @return an iterator to the first match, or NULL if no matches found. */ -SORD_API -SordIter* +SORD_API SordIter* sord_search(SordModel* model, const SordNode* s, const SordNode* p, @@ -392,8 +364,7 @@ sord_search(SordModel* model, 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_API SordNode* sord_get(SordModel* model, const SordNode* s, const SordNode* p, @@ -403,8 +374,7 @@ sord_get(SordModel* model, /** Return true iff a statement exists. */ -SORD_API -bool +SORD_API bool sord_ask(SordModel* model, const SordNode* s, const SordNode* p, @@ -414,8 +384,7 @@ sord_ask(SordModel* model, /** Return the number of matching statements. */ -SORD_API -uint64_t +SORD_API uint64_t sord_count(SordModel* model, const SordNode* s, const SordNode* p, @@ -427,8 +396,7 @@ sord_count(SordModel* model, @return true if `model` contains a match for `pat`, otherwise false. */ -SORD_API -bool +SORD_API bool sord_contains(SordModel* model, const SordQuad pat); /** @@ -438,8 +406,7 @@ sord_contains(SordModel* model, const SordQuad pat); @return true on success, false, on error. */ -SORD_API -bool +SORD_API bool sord_add(SordModel* model, const SordQuad tup); /** @@ -448,8 +415,7 @@ sord_add(SordModel* model, const SordQuad tup); Calling this function invalidates all iterators on `model`. To remove quads while iterating, use sord_erase() instead. */ -SORD_API -void +SORD_API void sord_remove(SordModel* model, const SordQuad tup); /** @@ -461,8 +427,7 @@ sord_remove(SordModel* model, const SordQuad tup); @param iter Iterator to the element to erase, which is incremented to the next value on return. */ -SORD_API -SerdStatus +SORD_API SerdStatus sord_erase(SordModel* model, SordIter* iter); /** @@ -474,15 +439,13 @@ sord_erase(SordModel* model, SordIter* iter); /** Create an inserter for writing statements to a model. */ -SORD_API -SordInserter* +SORD_API SordInserter* sord_inserter_new(SordModel* model, SerdEnv* env); /** Free an inserter. */ -SORD_API -void +SORD_API void sord_inserter_free(SordInserter* inserter); /** @@ -490,8 +453,7 @@ sord_inserter_free(SordInserter* inserter); Note this function can be safely casted to SerdBaseSink. */ -SORD_API -SerdStatus +SORD_API SerdStatus sord_inserter_set_base_uri(SordInserter* inserter, const SerdNode* uri); /** @@ -499,8 +461,7 @@ sord_inserter_set_base_uri(SordInserter* inserter, const SerdNode* uri); Note this function can be safely casted to SerdPrefixSink. */ -SORD_API -SerdStatus +SORD_API SerdStatus sord_inserter_set_prefix(SordInserter* inserter, const SerdNode* name, const SerdNode* uri); @@ -510,8 +471,7 @@ sord_inserter_set_prefix(SordInserter* inserter, Note this function can be safely casted to SerdStatementSink. */ -SORD_API -SerdStatus +SORD_API SerdStatus sord_inserter_write_statement(SordInserter* inserter, SerdStatementFlags flags, const SerdNode* graph, @@ -530,8 +490,7 @@ sord_inserter_write_statement(SordInserter* inserter, /** Set `quad` to the quad pointed to by `iter`. */ -SORD_API -void +SORD_API void sord_iter_get(const SordIter* iter, SordQuad tup); /** @@ -539,36 +498,31 @@ sord_iter_get(const SordIter* iter, SordQuad tup); Returns NULL if `iter` is NULL or is at the end. */ -SORD_API -const SordNode* +SORD_API const SordNode* sord_iter_get_node(const SordIter* iter, SordQuadIndex index); /** Return the store pointed to by `iter`. */ -SORD_API -const SordModel* +SORD_API const SordModel* sord_iter_get_model(SordIter* iter); /** Increment `iter` to point to the next statement. */ -SORD_API -bool +SORD_API bool sord_iter_next(SordIter* iter); /** Return true iff `iter` is at the end of its range. */ -SORD_API -bool +SORD_API bool sord_iter_end(const SordIter* iter); /** Free `iter`. */ -SORD_API -void +SORD_API void sord_iter_free(SordIter* iter); /** @@ -584,8 +538,7 @@ sord_iter_free(SordIter* iter); support (ID 0 is a wildcard). It does not actually read node data. @return true iff `x` and `y` match. */ -SORD_API -bool +SORD_API bool sord_quad_match(const SordQuad x, const SordQuad y); /** @@ -597,8 +550,7 @@ sord_quad_match(const SordQuad x, const SordQuad y); /** Return a reader that will read into `model`. */ -SORD_API -SerdReader* +SORD_API SerdReader* sord_new_reader(SordModel* model, SerdEnv* env, SerdSyntax syntax, @@ -607,8 +559,7 @@ sord_new_reader(SordModel* model, /** Write a model to a writer. */ -SORD_API -bool +SORD_API bool sord_write(SordModel* model, SerdWriter* writer, SordNode* graph); /** @@ -616,8 +567,7 @@ sord_write(SordModel* model, SerdWriter* writer, SordNode* graph); This increments `iter` to its end, then frees it. */ -SORD_API -bool +SORD_API bool sord_write_iter(SordIter* iter, SerdWriter* writer); /** |