sord(3)

๐Ÿ“ฆ
version 0.16.10 ยท 2 versions
, in epel 9

๐Ÿ’– NAME ๐Ÿ’–

okay so bestie, welcome to sord(3) โ€” the manual page for **Sord** ๐Ÿ’…

Sord is the lightweight RDF model library in question, and this is its vibe check ๐Ÿซถ


๐ŸŒˆ Detailed Description ๐ŸŒˆ

Okay so Sord is a lightweight RDF model library. It stores RDF (subject object predicate context) quads, where the context may be omitted (to represent triples in the default graph). That's the whole thing: quads, with the context optionally missing so you can rep the default graph. Periodt โœจ

๐Ÿงธ Typedefs ๐Ÿงธ

  • typedef struct SordWorldImpl SordWorld
  • typedef struct SordModelImpl SordModel
  • typedef struct SordInserterImpl SordInserter
  • typedef struct SordIterImpl SordIter
  • typedef struct SordNodeImpl SordNode
  • typedef const SordNode * SordQuad[4]

๐Ÿ”ข Enumerations ๐Ÿ”ข

  • enum SordQuadIndex { SORD_SUBJECT = 0, SORD_PREDICATE = 1, SORD_OBJECT = 2, SORD_GRAPH = 3 }
  • enum SordNodeType { SORD_URI = 1, SORD_BLANK = 2, SORD_LITERAL = 3 }
  • enum SordIndexOption { SORD_SPO = 1, SORD_SOP = 1 << 1, SORD_OPS = 1 << 2, SORD_OSP = 1 << 3, SORD_PSO = 1 << 4, SORD_POS = 1 << 5 }

๐ŸŒ World ๐ŸŒ

The <cyan>World</cyan> crew is here, bestie ๐Ÿ’™

  • SORD_API SordWorld * sord_world_new (void) โ€” the "new world" moment โœจ
  • SORD_API void sord_world_free (SordWorld *world) โ€” frees the world ๐Ÿซถ
  • SORD_API void sord_world_set_error_sink (SordWorld *world, SerdErrorSink error_sink, void *handle) โ€” sets the error sink with error_sink and handle

๐ŸŽ€ Node ๐ŸŽ€

Nodes are literally the little building blocks of quads, no cap ๐Ÿงš

  • SORD_API SordNode * sord_new_uri (SordWorld *world, const uint8_t *uri) โ€” makes a URI node from uri
  • SORD_API SordNode * sord_new_relative_uri (SordWorld *world, const uint8_t *uri, const uint8_t *base_uri) โ€” makes a relative URI node with uri and base_uri
  • SORD_API SordNode * sord_new_blank (SordWorld *world, const uint8_t *str) โ€” makes a blank node from str
  • SORD_API SordNode * sord_new_literal (SordWorld *world, SordNode *datatype, const uint8_t *str, const char *lang) โ€” makes a literal node with datatype, str, and lang
  • SORD_API SordNode * sord_node_copy (const SordNode *node) โ€” copies node
  • SORD_API void sord_node_free (SordWorld *world, SordNode *node) โ€” frees node from world
  • SORD_API SordNodeType sord_node_get_type (const SordNode *node) โ€” gets the type of node
  • SORD_API const uint8_t * sord_node_get_string (const SordNode *node) โ€” gets node's string
  • SORD_API const uint8_t * sord_node_get_string_counted (const SordNode *node, size_t *bytes) โ€” gets node's string with bytes
  • SORD_API const uint8_t * sord_node_get_string_measured (const SordNode *node, size_t *bytes, size_t *chars) โ€” gets node's string measured with bytes and chars
  • SORD_API const char * sord_node_get_language (const SordNode *node) โ€” gets node's language
  • SORD_API SordNode * sord_node_get_datatype (const SordNode *node) โ€” gets node's datatype
  • SORD_API SerdNodeFlags sord_node_get_flags (const SordNode *node) โ€” gets node's SerdNodeFlags
  • SORD_API bool sord_node_is_inline_object (const SordNode *node) โ€” checks if node is an inline object
  • SORD_API bool sord_node_equals (const SordNode *a, const SordNode *b) โ€” checks whether a equals b
  • SORD_API const SerdNode * sord_node_to_serd_node (const SordNode *node) โ€” converts node to a SerdNode
  • SORD_API SordNode * sord_node_from_serd_node (SordWorld *world, SerdEnv *env, const SerdNode *node, const SerdNode *datatype, const SerdNode *lang) โ€” converts from a SerdNode using world, env, node, datatype, and lang

๐Ÿฆ‹ Model ๐Ÿฆ‹

A model is the indexed set of quads, and it's giving main character energy ๐Ÿ‘‘

  • SORD_API SordModel * sord_new (SordWorld *world, unsigned indices, bool graphs) โ€” makes a model with indices and graphs
  • SORD_API void sord_free (SordModel *model) โ€” frees model
  • SORD_API SordWorld * sord_get_world (SordModel *model) โ€” gets the world from model
  • SORD_API size_t sord_num_nodes (const SordWorld *world) โ€” counts nodes in world
  • SORD_API size_t sord_num_quads (const SordModel *model) โ€” counts quads in model
  • SORD_API SordIter * sord_begin (const SordModel *model) โ€” begins iteration over model
  • SORD_API SordIter * sord_find (SordModel *model, const SordQuad pat) โ€” finds with pat
  • SORD_API SordIter * sord_search (SordModel *model, const SordNode *s, const SordNode *p, const SordNode *o, const SordNode *g) โ€” searches with s, p, o, and g
  • SORD_API SordNode * sord_get (SordModel *model, const SordNode *s, const SordNode *p, const SordNode *o, const SordNode *g) โ€” gets with s, p, o, and g
  • SORD_API bool sord_ask (SordModel *model, const SordNode *s, const SordNode *p, const SordNode *o, const SordNode *g) โ€” asks with s, p, o, and g
  • SORD_API uint64_t sord_count (SordModel *model, const SordNode *s, const SordNode *p, const SordNode *o, const SordNode *g) โ€” counts with s, p, o, and g
  • SORD_API bool sord_contains (SordModel *model, const SordQuad pat) โ€” checks whether model contains pat
  • SORD_API bool sord_add (SordModel *model, const SordQuad tup) โ€” adds tup
  • SORD_API void sord_remove (SordModel *model, const SordQuad tup) โ€” removes tup
  • SORD_API SerdStatus sord_erase (SordModel *model, SordIter *iter) โ€” erases iter

๐ŸŒธ Inserter ๐ŸŒธ

Inserters are the Serd-sink-interface girlies ๐Ÿ’…

  • SORD_API SordInserter * sord_inserter_new (SordModel *model, SerdEnv *env) โ€” makes an inserter with model and env
  • SORD_API void sord_inserter_free (SordInserter *inserter) โ€” frees inserter
  • SORD_API SerdStatus sord_inserter_set_base_uri (SordInserter *inserter, const SerdNode *uri) โ€” sets the base URI to uri
  • SORD_API SerdStatus sord_inserter_set_prefix (SordInserter *inserter, const SerdNode *name, const SerdNode *uri) โ€” sets prefix name to uri
  • SORD_API SerdStatus sord_inserter_write_statement (SordInserter *inserter, SerdStatementFlags flags, const SerdNode *graph, const SerdNode *subject, const SerdNode *predicate, const SerdNode *object, const SerdNode *object_datatype, const SerdNode *object_lang) โ€” writes a statement with flags, graph, subject, predicate, object, object_datatype, and object_lang

๐Ÿ“ Iteration ๐Ÿ“

Iteration is lowkey iconic, fr fr ๐ŸŽ€

  • SORD_API void sord_iter_get (const SordIter *iter, SordQuad tup) โ€” gets tup from iter
  • SORD_API const SordNode * sord_iter_get_node (const SordIter *iter, SordQuadIndex index) โ€” gets the node at index from iter
  • SORD_API const SordModel * sord_iter_get_model (SordIter *iter) โ€” gets the model from iter
  • SORD_API bool sord_iter_next (SordIter *iter) โ€” moves iter next
  • SORD_API bool sord_iter_end (const SordIter *iter) โ€” checks if iter is at the end
  • SORD_API void sord_iter_free (SordIter *iter) โ€” frees iter

๐Ÿงš Utilities ๐Ÿงš

  • SORD_API bool sord_quad_match (const SordQuad x, const SordQuad y) โ€” matches quad x against quad y

๐Ÿ‘‘ Serialisation ๐Ÿ‘‘

Writing and reading, the glamorous part โœจ

  • SORD_API SerdReader * sord_new_reader (SordModel *model, SerdEnv *env, SerdSyntax syntax, SordNode *graph) โ€” makes a reader with model, env, syntax, and graph
  • SORD_API bool sord_write (SordModel *model, SerdWriter *writer, SordNode *graph) โ€” writes model to writer with graph
  • SORD_API bool sord_write_iter (SordIter *iter, SerdWriter *writer) โ€” writes iter to writer

๐Ÿชฉ Typedef Documentation ๐Ÿชฉ

typedef struct SordWorldImpl SordWorld

Sord World. The World represents all library state, including interned strings. Basically the whole library's state lives here, bestie ๐ŸŒ

typedef struct SordModelImpl SordModel

Sord Model. A model is an indexed set of Quads (i.e. it can contain several RDF graphs). It may be searched using various patterns depending on which indices are enabled. That's the tea โ˜•

typedef struct SordInserterImpl SordInserter

Model Inserter. An inserter is used for writing statements to a model using the Serd sink interface. This makes it simple to write to a model directly using a SerdReader, or any other code that writes statements to a SerdStatementSink. Slay ๐Ÿซถ

typedef struct SordIterImpl SordIter

Model Iterator. That's it, that's the whole note ๐Ÿ’ซ

typedef struct SordNodeImpl SordNode

RDF Node. A Node is a component of a Quad. Nodes may be URIs, blank nodes, or (in the case of quad objects only) string literals. Literal nodes may have an associate language or datatype (but not both) โ€” not both is the rule, no cap ๐ŸŽ€

typedef const SordNode* SordQuad[4]

Quad of nodes (a statement), or a quad pattern. Nodes are ordered (S P O G). The ID of the default graph is 0. Remember that zero, bestie โ€” it's important ๐Ÿ’…


๐Ÿ”ฎ Enumeration Type Documentation ๐Ÿ”ฎ

enum SordQuadIndex

Index into a SordQuad.

Enumerator

  • SORD_SUBJECT โ€” Subject.
  • SORD_PREDICATE โ€” Predicate ('key')
  • SORD_OBJECT โ€” Object ('value')
  • SORD_GRAPH โ€” Graph ('context')

enum SordNodeType

Type of a node.

Enumerator

  • SORD_URI โ€” URI.
  • SORD_BLANK โ€” Blank node identifier.
  • SORD_LITERAL โ€” Literal (string with optional lang or datatype)

enum SordIndexOption

Indexing option.

Enumerator

  • SORD_SPO โ€” Subject, Predicate, Object.
  • SORD_SOP โ€” Subject, Object, Predicate.
  • SORD_OPS โ€” Object, Predicate, Subject.
  • SORD_OSP โ€” Object, Subject, Predicate.
  • SORD_PSO โ€” Predicate, Subject, Object.
  • SORD_POS โ€” Predicate, Object, Subject.

๐Ÿ’ซ FUNCTION DOCUMENTATION ๐Ÿ’ซ

okay bestie, this is the function era of the page โ€” every single one, no skips, no cap. โœจ

sord_world_new

SORD_API SordWorld* sord_world_new (void)

Creates a brand-new Sord World. Itโ€™s totally safe to use multiple worlds in one process, though no data (e.g. nodes) can be shared between worlds โ€” and honestly this should be avoided if possible for performance reasons. ๐Ÿ’…

sord_world_free

SORD_API void sord_world_free (SordWorld * world)

Frees the world. Thatโ€™s it. Bye ๐Ÿ‘‹

sord_world_set_error_sink

SORD_API void sord_world_set_error_sink (SordWorld * world, SerdErrorSink
    error_sink, void * handle)

Sets the function that gets called when errors occur. The error_sink will be called with handle as its first argument. If no error function is set, errors are printed to stderr. ๐Ÿซถ

sord_new_uri

SORD_API SordNode* sord_new_uri (SordWorld * world, const uint8_t * uri)

Gets a URI node from a string. Heads up: this function measures str, which is a common bottleneck. Use sord_node_from_serd_node() instead if str is already measured. ๐Ÿ”ฅ

sord_new_relative_uri

SORD_API SordNode* sord_new_relative_uri (SordWorld * world, const uint8_t *
    uri, const uint8_t * base_uri)

Gets a URI node from a relative URI string. โœจ

sord_new_blank

SORD_API SordNode* sord_new_blank (SordWorld * world, const uint8_t * str)

Gets a blank node from a string. Same warning, bestie: this function measures str, which is a common bottleneck. Use sord_node_from_serd_node() instead if str is already measured. ๐ŸŽ€

sord_new_literal

SORD_API SordNode* sord_new_literal (SordWorld * world, SordNode * datatype,
    const uint8_t * str, const char * lang)

Gets a literal node from a string. Again: this function measures str, which is a common bottleneck. Use sord_node_from_serd_node() instead if str is already measured. ๐Ÿ’–

sord_node_copy

SORD_API SordNode* sord_node_copy (const SordNode * node)

Copies a node โ€” aka obtains a reference. Note that since nodes are interned and reference counted, this does not actually create a deep copy of node. Itโ€™s giving โ€œsame node, extra refโ€ energy. ๐Ÿ’…

sord_node_free

SORD_API void sord_node_free (SordWorld * world, SordNode * node)

Frees a node โ€” aka drops a reference. ๐Ÿฆ‹

sord_node_get_type

SORD_API SordNodeType sord_node_get_type (const SordNode * node)

Returns the type of a node: SORD_URI, SORD_BLANK, or SORD_LITERAL. Slay. ๐Ÿ”ฅ

sord_node_get_string

SORD_API const uint8_t* sord_node_get_string (const SordNode * node)

Returns the string value of a node. โญ

sord_node_get_string_counted

SORD_API const uint8_t* sord_node_get_string_counted (const SordNode * node,
    size_t * bytes)

Returns the string value of a node, and sets bytes to its length in bytes. ๐ŸŒธ

sord_node_get_string_measured

SORD_API const uint8_t* sord_node_get_string_measured (const SordNode *
    node, size_t * bytes, size_t * chars)

Returns the string value of a node, and sets bytes to its length in bytes, and count to its length in characters. (Thatโ€™s the word on the page, bestie โ€” passing it straight through. ๐Ÿซถ)

sord_node_get_language

SORD_API const char* sord_node_get_language (const SordNode * node)

Returns the language of a literal node, or NULL. ๐ŸŽ€

sord_node_get_datatype

SORD_API SordNode* sord_node_get_datatype (const SordNode * node)

Returns the datatype URI of a literal node, or NULL. โœจ

sord_node_get_flags

SORD_API SerdNodeFlags sord_node_get_flags (const SordNode * node)

Returns the flags (string attributes) of a node. ๐Ÿ’…

sord_node_is_inline_object

SORD_API bool sord_node_is_inline_object (const SordNode * node)

Returns true iff node can be serialised as an inline object. 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 be referred to by name. Iconic logic tbh. ๐Ÿ‘‘

sord_node_equals

SORD_API bool sord_node_equals (const SordNode * a, const SordNode * b)

Returns true iff a is equal to b. Note this is much faster than comparing the nodeโ€™s strings. No cap. ๐Ÿ”ฅ

sord_node_to_serd_node

SORD_API const SerdNode* sord_node_to_serd_node (const SordNode * node)

Returns a SordNode as a SerdNode. The returned node is shared and must not be freed or modified. โš ๏ธ

sord_node_from_serd_node

SORD_API SordNode* sord_node_from_serd_node (SordWorld * world, SerdEnv *
    env, const SerdNode * node, const SerdNode * datatype, const SerdNode *
    lang)

Creates a new SordNode from a SerdNode. The returned node must be freed using sord_node_free(). ๐Ÿซถ

sord_new

SORD_API SordModel* sord_new (SordWorld * world, unsigned indices, bool
    graphs)

Creates a new model. โœจ

Parameters

  • world โ€” the world in which to make this model.
  • indices โ€” SordIndexOption flags (e.g. SORD_SPO|SORD_OPS). Be sure to enable an index where the most significant node(s) are not variables in your queries (e.g. to make (? P O) queries, enable either SORD_OPS or SORD_POS). ๐Ÿ’…
  • graphs โ€” if true, store (and index) graph contexts.

sord_free

SORD_API void sord_free (SordModel * model)

Closes and frees model. Bye bestie ๐Ÿ‘‹

sord_get_world

SORD_API SordWorld* sord_get_world (SordModel * model)

Gets the world associated with model. ๐ŸŒˆ

sord_num_nodes

SORD_API size_t sord_num_nodes (const SordWorld * world)

Returns the number of nodes stored in world. Nodes are included in this count iff they are a part of a quad in world. โญ

sord_num_quads

SORD_API size_t sord_num_quads (const SordModel * model)

Returns the number of quads stored in model. ๐Ÿ’–

sord_begin

SORD_API SordIter* sord_begin (const SordModel * model)

Returns an iterator to the start of model. ๐ŸŽ€

sord_find

SORD_API SordIter* sord_find (SordModel * model, const SordQuad pat)

Searches for statements by a quad pattern. ๐Ÿฆ‹

Returns

  • an iterator to the first match, or NULL if no matches found.
SORD_API SordIter* sord_search (SordModel * model, const SordNode * s, const
    SordNode * p, const SordNode * o, const SordNode * g)

Searches for statements by nodes. ๐Ÿ”

Returns

  • an iterator to the first match, or NULL if no matches found.

sord_get

SORD_API SordNode* sord_get (SordModel * model, const SordNode * s, const
    SordNode * p, const SordNode * o, const SordNode * g)

Searches for a single node that matches a pattern. Exactly one of s, 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(). ๐Ÿ’…

Returns

  • the first matching node, or NULL if no matches are found.

sord_ask

SORD_API bool sord_ask (SordModel * model, const SordNode * s, const
    SordNode * p, const SordNode * o, const SordNode * g)

Returns true iff a statement exists. ๐Ÿ‘‘

sord_count

SORD_API uint64_t sord_count (SordModel * model, const SordNode * s, const
    SordNode * p, const SordNode * o, const SordNode * g)

Returns the number of matching statements. ๐Ÿ”ข

sord_contains

SORD_API bool sord_contains (SordModel * model, const SordQuad pat)

Checks if model contains a triple pattern. ๐ŸŒธ

Returns

  • true if model contains a match for pat, otherwise false.

sord_add

SORD_API bool sord_add (SordModel * model, const SordQuad tup)

Adds a quad to a model. Calling this function invalidates all iterators on model. ๐Ÿ˜ญ

Returns

  • true on success, false, on error.

sord_remove

SORD_API void sord_remove (SordModel * model, const SordQuad tup)

Removes a quad from a model. Calling this function invalidates all iterators on model. To remove quads while iterating, use sord_erase() instead. ๐Ÿ’…

sord_erase

SORD_API SerdStatus sord_erase (SordModel * model, SordIter * iter)

Removes a quad from a model via an iterator. Calling this function invalidates all iterators on model except iter. ๐Ÿซถ

Parameters

  • model โ€” the model which iter points to.
  • iter โ€” iterator to the element to erase, which is incremented to the next value on return.

sord_inserter_new

SORD_API SordInserter* sord_inserter_new (SordModel * model, SerdEnv * env)

Creates an inserter for writing statements to a model. โœจ

sord_inserter_free

SORD_API void sord_inserter_free (SordInserter * inserter)

Frees an inserter. ๐Ÿฆ‹

sord_inserter_set_base_uri

SORD_API SerdStatus sord_inserter_set_base_uri (SordInserter * inserter,
    const SerdNode * uri)

Sets the current base URI for writing to the model. Note this function can be safely casted to SerdBaseSink. ๐Ÿ’…

sord_inserter_set_prefix

SORD_API SerdStatus sord_inserter_set_prefix (SordInserter * inserter, const
    SerdNode * name, const SerdNode * uri)

Sets a namespace prefix for writing to the model. Note this function can be safely casted to SerdPrefixSink. ๐ŸŽ€

sord_inserter_write_statement

SORD_API SerdStatus sord_inserter_write_statement (SordInserter * inserter,
    SerdStatementFlags flags, const SerdNode * graph, const SerdNode *
    subject, const SerdNode * predicate, const SerdNode * object, const
    SerdNode * object_datatype, const SerdNode * object_lang)

Writes a statement to the model. Note this function can be safely casted to SerdStatementSink. ๐Ÿ”ฅ

sord_iter_get

SORD_API void sord_iter_get (const SordIter * iter, SordQuad tup)

Sets the quad output to the quad pointed to by iter. ๐ŸŒธ

sord_iter_get_node

SORD_API const SordNode* sord_iter_get_node (const SordIter * iter,
    SordQuadIndex index)

Returns a field of the quad pointed to by iter. Returns NULL if iter is NULL or is at the end. ๐Ÿซถ

sord_iter_get_model

SORD_API const SordModel* sord_iter_get_model (SordIter * iter)

Returns the store pointed to by iter. ๐Ÿ’–

sord_iter_next

SORD_API bool sord_iter_next (SordIter * iter)

Increments iter to point to the next statement. โญ

sord_iter_end

SORD_API bool sord_iter_end (const SordIter * iter)

Returns true iff iter is at the end of its range. ๐ŸŽ€

sord_iter_free

SORD_API void sord_iter_free (SordIter * iter)

Frees iter. ๐Ÿ’…

sord_quad_match

SORD_API bool sord_quad_match (const SordQuad x, const SordQuad y)

Matches two quads (using ID comparison only). This function is a straightforward and fast equivalence match with wildcard support โ€” ID 0 is a wildcard. It does not actually read node data. ๐Ÿ”ฅ

Returns

  • true iff x and y match.

sord_new_reader

SORD_API SerdReader* sord_new_reader (SordModel * model, SerdEnv * env,
    SerdSyntax syntax, SordNode * graph)

Returns a reader that will read into model. ๐Ÿ“–

sord_write

SORD_API bool sord_write (SordModel * model, SerdWriter * writer, SordNode *
    graph)

Writes a model to a writer. โœ๏ธ

sord_write_iter

SORD_API bool sord_write_iter (SordIter * iter, SerdWriter * writer)

Writes a range to a writer. This increments iter to its end, then frees it. ๐Ÿซถ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Generated automatically by Doxygen for Sord from the source code. No human author energy, just Doxygen doing its thing. ๐Ÿ’…


Thatโ€™s the whole page, bestie ๐Ÿซถ โ€” Version 0.16.10, dated Sat Jul 23 2022, and the page is sord(3). Periodt. ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from