sord(3)
๐ 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 SordWorldtypedef struct SordModelImpl SordModeltypedef struct SordInserterImpl SordInsertertypedef struct SordIterImpl SordItertypedef struct SordNodeImpl SordNodetypedef 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 witherror_sinkandhandle
๐ 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 fromuriSORD_API SordNode * sord_new_relative_uri (SordWorld *world, const uint8_t *uri, const uint8_t *base_uri)โ makes a relative URI node withuriandbase_uriSORD_API SordNode * sord_new_blank (SordWorld *world, const uint8_t *str)โ makes a blank node fromstrSORD_API SordNode * sord_new_literal (SordWorld *world, SordNode *datatype, const uint8_t *str, const char *lang)โ makes a literal node withdatatype,str, andlangSORD_API SordNode * sord_node_copy (const SordNode *node)โ copiesnodeSORD_API void sord_node_free (SordWorld *world, SordNode *node)โ freesnodefromworldSORD_API SordNodeType sord_node_get_type (const SordNode *node)โ gets the type ofnodeSORD_API const uint8_t * sord_node_get_string (const SordNode *node)โ getsnode's stringSORD_API const uint8_t * sord_node_get_string_counted (const SordNode *node, size_t *bytes)โ getsnode's string withbytesSORD_API const uint8_t * sord_node_get_string_measured (const SordNode *node, size_t *bytes, size_t *chars)โ getsnode's string measured withbytesandcharsSORD_API const char * sord_node_get_language (const SordNode *node)โ getsnode's languageSORD_API SordNode * sord_node_get_datatype (const SordNode *node)โ getsnode's datatypeSORD_API SerdNodeFlags sord_node_get_flags (const SordNode *node)โ getsnode'sSerdNodeFlagsSORD_API bool sord_node_is_inline_object (const SordNode *node)โ checks ifnodeis an inline objectSORD_API bool sord_node_equals (const SordNode *a, const SordNode *b)โ checks whetheraequalsbSORD_API const SerdNode * sord_node_to_serd_node (const SordNode *node)โ convertsnodeto aSerdNodeSORD_API SordNode * sord_node_from_serd_node (SordWorld *world, SerdEnv *env, const SerdNode *node, const SerdNode *datatype, const SerdNode *lang)โ converts from aSerdNodeusingworld,env,node,datatype, andlang
๐ฆ 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 withindicesandgraphsSORD_API void sord_free (SordModel *model)โ freesmodelSORD_API SordWorld * sord_get_world (SordModel *model)โ gets the world frommodelSORD_API size_t sord_num_nodes (const SordWorld *world)โ counts nodes inworldSORD_API size_t sord_num_quads (const SordModel *model)โ counts quads inmodelSORD_API SordIter * sord_begin (const SordModel *model)โ begins iteration overmodelSORD_API SordIter * sord_find (SordModel *model, const SordQuad pat)โ finds withpatSORD_API SordIter * sord_search (SordModel *model, const SordNode *s, const SordNode *p, const SordNode *o, const SordNode *g)โ searches withs,p,o, andgSORD_API SordNode * sord_get (SordModel *model, const SordNode *s, const SordNode *p, const SordNode *o, const SordNode *g)โ gets withs,p,o, andgSORD_API bool sord_ask (SordModel *model, const SordNode *s, const SordNode *p, const SordNode *o, const SordNode *g)โ asks withs,p,o, andgSORD_API uint64_t sord_count (SordModel *model, const SordNode *s, const SordNode *p, const SordNode *o, const SordNode *g)โ counts withs,p,o, andgSORD_API bool sord_contains (SordModel *model, const SordQuad pat)โ checks whethermodelcontainspatSORD_API bool sord_add (SordModel *model, const SordQuad tup)โ addstupSORD_API void sord_remove (SordModel *model, const SordQuad tup)โ removestupSORD_API SerdStatus sord_erase (SordModel *model, SordIter *iter)โ erasesiter
๐ธ Inserter ๐ธ
Inserters are the Serd-sink-interface girlies ๐
SORD_API SordInserter * sord_inserter_new (SordModel *model, SerdEnv *env)โ makes an inserter withmodelandenvSORD_API void sord_inserter_free (SordInserter *inserter)โ freesinserterSORD_API SerdStatus sord_inserter_set_base_uri (SordInserter *inserter, const SerdNode *uri)โ sets the base URI touriSORD_API SerdStatus sord_inserter_set_prefix (SordInserter *inserter, const SerdNode *name, const SerdNode *uri)โ sets prefixnametouriSORD_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 withflags,graph,subject,predicate,object,object_datatype, andobject_lang
๐ Iteration ๐
Iteration is lowkey iconic, fr fr ๐
SORD_API void sord_iter_get (const SordIter *iter, SordQuad tup)โ getstupfromiterSORD_API const SordNode * sord_iter_get_node (const SordIter *iter, SordQuadIndex index)โ gets the node atindexfromiterSORD_API const SordModel * sord_iter_get_model (SordIter *iter)โ gets the model fromiterSORD_API bool sord_iter_next (SordIter *iter)โ movesiternextSORD_API bool sord_iter_end (const SordIter *iter)โ checks ifiteris at the endSORD_API void sord_iter_free (SordIter *iter)โ freesiter
๐ง Utilities ๐ง
SORD_API bool sord_quad_match (const SordQuad x, const SordQuad y)โ matches quadxagainst quady
๐ Serialisation ๐
Writing and reading, the glamorous part โจ
SORD_API SerdReader * sord_new_reader (SordModel *model, SerdEnv *env, SerdSyntax syntax, SordNode *graph)โ makes a reader withmodel,env,syntax, andgraphSORD_API bool sord_write (SordModel *model, SerdWriter *writer, SordNode *graph)โ writesmodeltowriterwithgraphSORD_API bool sord_write_iter (SordIter *iter, SerdWriter *writer)โ writesitertowriter
๐ชฉ 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โSordIndexOptionflags (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 eitherSORD_OPSorSORD_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
NULLif no matches found.
sord_search
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
NULLif 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
NULLif 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
trueifmodelcontains a match forpat, otherwisefalse.
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
trueon 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 whichiterpoints 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
trueiffxandymatch.
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
- epel 9: sord-devel 0.16.10-2.el9 ยท ISC
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms