.TH "Sord" 3 "Fri Aug 15 2014" "Version 0.12.2" "Sord" \" -*- nroff -*- .ad l .nh .SH NAME Sord \- .SH "Detailed Description" .PP A lightweight RDF model library\&. Sord stores RDF (subject object predicate context) quads, where the context may be omitted (to represent triples in the default graph)\&. .SS "Typedefs" .in +1c .ti -1c .RI "typedef struct SordWorldImpl \fBSordWorld\fP" .br .ti -1c .RI "typedef struct SordModelImpl \fBSordModel\fP" .br .ti -1c .RI "typedef struct SordInserterImpl \fBSordInserter\fP" .br .ti -1c .RI "typedef struct SordIterImpl \fBSordIter\fP" .br .ti -1c .RI "typedef struct SordNodeImpl \fBSordNode\fP" .br .ti -1c .RI "typedef const \fBSordNode\fP * \fBSordQuad\fP [4]" .br .in -1c .SS "Enumerations" .in +1c .ti -1c .RI "enum \fBSordQuadIndex\fP { \fBSORD_SUBJECT\fP = 0, \fBSORD_PREDICATE\fP = 1, \fBSORD_OBJECT\fP = 2, \fBSORD_GRAPH\fP = 3 }" .br .ti -1c .RI "enum \fBSordNodeType\fP { \fBSORD_URI\fP = 1, \fBSORD_BLANK\fP = 2, \fBSORD_LITERAL\fP = 3 }" .br .ti -1c .RI "enum \fBSordIndexOption\fP { \fBSORD_SPO\fP = 1, \fBSORD_SOP\fP = 1 << 1, \fBSORD_OPS\fP = 1 << 2, \fBSORD_OSP\fP = 1 << 3, \fBSORD_PSO\fP = 1 << 4, \fBSORD_POS\fP = 1 << 5 }" .br .in -1c .SS "World" .in +1c .ti -1c .RI "\fBSordWorld\fP * \fBsord_world_new\fP (void)" .br .ti -1c .RI "void \fBsord_world_free\fP (\fBSordWorld\fP *world)" .br .ti -1c .RI "void \fBsord_world_set_error_sink\fP (\fBSordWorld\fP *world, SerdErrorSink error_sink, void *handle)" .br .in -1c .SS "Node" .in +1c .ti -1c .RI "\fBSordNode\fP * \fBsord_new_uri\fP (\fBSordWorld\fP *world, const uint8_t *uri)" .br .ti -1c .RI "\fBSordNode\fP * \fBsord_new_relative_uri\fP (\fBSordWorld\fP *world, const uint8_t *str, const uint8_t *base_uri)" .br .ti -1c .RI "\fBSordNode\fP * \fBsord_new_blank\fP (\fBSordWorld\fP *world, const uint8_t *str)" .br .ti -1c .RI "\fBSordNode\fP * \fBsord_new_literal\fP (\fBSordWorld\fP *world, \fBSordNode\fP *datatype, const uint8_t *str, const char *lang)" .br .ti -1c .RI "\fBSordNode\fP * \fBsord_node_copy\fP (const \fBSordNode\fP *node)" .br .ti -1c .RI "void \fBsord_node_free\fP (\fBSordWorld\fP *world, \fBSordNode\fP *node)" .br .ti -1c .RI "\fBSordNodeType\fP \fBsord_node_get_type\fP (const \fBSordNode\fP *node)" .br .ti -1c .RI "const uint8_t * \fBsord_node_get_string\fP (const \fBSordNode\fP *node)" .br .ti -1c .RI "const uint8_t * \fBsord_node_get_string_counted\fP (const \fBSordNode\fP *node, size_t *len)" .br .ti -1c .RI "const char * \fBsord_node_get_language\fP (const \fBSordNode\fP *node)" .br .ti -1c .RI "\fBSordNode\fP * \fBsord_node_get_datatype\fP (const \fBSordNode\fP *node)" .br .ti -1c .RI "SerdNodeFlags \fBsord_node_get_flags\fP (const \fBSordNode\fP *node)" .br .ti -1c .RI "bool \fBsord_node_is_inline_object\fP (const \fBSordNode\fP *node)" .br .ti -1c .RI "bool \fBsord_node_equals\fP (const \fBSordNode\fP *a, const \fBSordNode\fP *b)" .br .ti -1c .RI "const SerdNode * \fBsord_node_to_serd_node\fP (const \fBSordNode\fP *node)" .br .ti -1c .RI "\fBSordNode\fP * \fBsord_node_from_serd_node\fP (\fBSordWorld\fP *world, SerdEnv *env, const SerdNode *node, const SerdNode *datatype, const SerdNode *lang)" .br .in -1c .SS "Model" .in +1c .ti -1c .RI "\fBSordModel\fP * \fBsord_new\fP (\fBSordWorld\fP *world, unsigned indices, bool graphs)" .br .ti -1c .RI "void \fBsord_free\fP (\fBSordModel\fP *model)" .br .ti -1c .RI "\fBSordWorld\fP * \fBsord_get_world\fP (\fBSordModel\fP *model)" .br .ti -1c .RI "size_t \fBsord_num_nodes\fP (const \fBSordWorld\fP *world)" .br .ti -1c .RI "size_t \fBsord_num_quads\fP (const \fBSordModel\fP *model)" .br .ti -1c .RI "\fBSordIter\fP * \fBsord_begin\fP (const \fBSordModel\fP *model)" .br .ti -1c .RI "\fBSordIter\fP * \fBsord_find\fP (\fBSordModel\fP *model, const \fBSordQuad\fP pat)" .br .ti -1c .RI "\fBSordIter\fP * \fBsord_search\fP (\fBSordModel\fP *model, const \fBSordNode\fP *s, const \fBSordNode\fP *p, const \fBSordNode\fP *o, const \fBSordNode\fP *g)" .br .ti -1c .RI "\fBSordNode\fP * \fBsord_get\fP (\fBSordModel\fP *model, const \fBSordNode\fP *s, const \fBSordNode\fP *p, const \fBSordNode\fP *o, const \fBSordNode\fP *g)" .br .ti -1c .RI "bool \fBsord_ask\fP (\fBSordModel\fP *model, const \fBSordNode\fP *s, const \fBSordNode\fP *p, const \fBSordNode\fP *o, const \fBSordNode\fP *g)" .br .ti -1c .RI "uint64_t \fBsord_count\fP (\fBSordModel\fP *model, const \fBSordNode\fP *s, const \fBSordNode\fP *p, const \fBSordNode\fP *o, const \fBSordNode\fP *g)" .br .ti -1c .RI "bool \fBsord_contains\fP (\fBSordModel\fP *model, const \fBSordQuad\fP pat)" .br .ti -1c .RI "bool \fBsord_add\fP (\fBSordModel\fP *model, const \fBSordQuad\fP quad)" .br .ti -1c .RI "void \fBsord_remove\fP (\fBSordModel\fP *model, const \fBSordQuad\fP quad)" .br .in -1c .SS "Inserter" .in +1c .ti -1c .RI "\fBSordInserter\fP * \fBsord_inserter_new\fP (\fBSordModel\fP *model, SerdEnv *env)" .br .ti -1c .RI "void \fBsord_inserter_free\fP (\fBSordInserter\fP *inserter)" .br .ti -1c .RI "SerdStatus \fBsord_inserter_set_base_uri\fP (\fBSordInserter\fP *inserter, const SerdNode *uri)" .br .ti -1c .RI "SerdStatus \fBsord_inserter_set_prefix\fP (\fBSordInserter\fP *inserter, const SerdNode *name, const SerdNode *uri)" .br .ti -1c .RI "SerdStatus \fBsord_inserter_write_statement\fP (\fBSordInserter\fP *inserter, SerdStatementFlags flags, const SerdNode *graph, const SerdNode *subject, const SerdNode *predicate, const SerdNode *object, const SerdNode *object_datatype, const SerdNode *object_lang)" .br .in -1c .SS "Iteration" .in +1c .ti -1c .RI "void \fBsord_iter_get\fP (const \fBSordIter\fP *iter, \fBSordQuad\fP quad)" .br .ti -1c .RI "const \fBSordNode\fP * \fBsord_iter_get_node\fP (const \fBSordIter\fP *iter, \fBSordQuadIndex\fP index)" .br .ti -1c .RI "const \fBSordModel\fP * \fBsord_iter_get_model\fP (\fBSordIter\fP *iter)" .br .ti -1c .RI "bool \fBsord_iter_next\fP (\fBSordIter\fP *iter)" .br .ti -1c .RI "bool \fBsord_iter_end\fP (const \fBSordIter\fP *iter)" .br .ti -1c .RI "void \fBsord_iter_free\fP (\fBSordIter\fP *iter)" .br .in -1c .SS "Utilities" .in +1c .ti -1c .RI "bool \fBsord_quad_match\fP (const \fBSordQuad\fP x, const \fBSordQuad\fP y)" .br .in -1c .SS "Serialisation" .in +1c .ti -1c .RI "SerdReader * \fBsord_new_reader\fP (\fBSordModel\fP *model, SerdEnv *env, SerdSyntax syntax, \fBSordNode\fP *graph)" .br .ti -1c .RI "bool \fBsord_write\fP (\fBSordModel\fP *model, SerdWriter *writer, \fBSordNode\fP *graph)" .br .ti -1c .RI "bool \fBsord_write_iter\fP (\fBSordIter\fP *iter, SerdWriter *writer)" .br .in -1c .SH "Typedef Documentation" .PP .SS "typedef struct SordWorldImpl \fBSordWorld\fP" .PP Sord World\&. The World represents all library state, including interned strings\&. .SS "typedef struct SordModelImpl \fBSordModel\fP" .PP 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\&. .SS "typedef struct SordInserterImpl \fBSordInserter\fP" .PP 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\&. .SS "typedef struct SordIterImpl \fBSordIter\fP" .PP Model Iterator\&. .SS "typedef struct SordNodeImpl \fBSordNode\fP" .PP 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)\&. .SS "typedef const \fBSordNode\fP* SordQuad[4]" .PP Quad of nodes (a statement), or a quad pattern\&. Nodes are ordered (S P O G)\&. The ID of the default graph is 0\&. .SH "Enumeration Type Documentation" .PP .SS "enum \fBSordQuadIndex\fP" .PP Index into a SordQuad\&. .PP \fBEnumerator\fP .in +1c .TP \fB\fISORD_SUBJECT \fP\fP Subject\&. .TP \fB\fISORD_PREDICATE \fP\fP Predicate (a\&.k\&.a\&. 'key') .TP \fB\fISORD_OBJECT \fP\fP Object (a\&.k\&.a\&. 'value') .TP \fB\fISORD_GRAPH \fP\fP Graph (a\&.k\&.a\&. 'context') .SS "enum \fBSordNodeType\fP" .PP Type of a node\&. .PP \fBEnumerator\fP .in +1c .TP \fB\fISORD_URI \fP\fP URI\&. .TP \fB\fISORD_BLANK \fP\fP Blank node identifier\&. .TP \fB\fISORD_LITERAL \fP\fP Literal (string with optional lang or datatype) .SS "enum \fBSordIndexOption\fP" .PP Indexing option\&. .PP \fBEnumerator\fP .in +1c .TP \fB\fISORD_SPO \fP\fP Subject, Predicate, Object\&. .TP \fB\fISORD_SOP \fP\fP Subject, Object, Predicate\&. .TP \fB\fISORD_OPS \fP\fP Object, Predicate, Subject\&. .TP \fB\fISORD_OSP \fP\fP Object, Subject, Predicate\&. .TP \fB\fISORD_PSO \fP\fP Predicate, Subject, Object\&. .TP \fB\fISORD_POS \fP\fP Predicate, Object, Subject\&. .SH "Function Documentation" .PP .SS "\fBSordWorld\fP* sord_world_new (void)" .PP Create a new Sord World\&. 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 possible for performance reasons\&. .SS "void sord_world_free (\fBSordWorld\fP *world)" .PP Free \fCworld\fP\&. .SS "void sord_world_set_error_sink (\fBSordWorld\fP *world, SerdErrorSinkerror_sink, void *handle)" .PP Set a function to be called when errors occur\&. The \fCerror_sink\fP will be called with \fChandle\fP as its first argument\&. If no error function is set, errors are printed to stderr\&. .SS "\fBSordNode\fP* sord_new_uri (\fBSordWorld\fP *world, const uint8_t *uri)" .PP Get a URI node from a string\&. Note this function measures \fCstr\fP, which is a common bottleneck\&. Use sord_node_from_serd_node instead if \fCstr\fP is already measured\&. .SS "\fBSordNode\fP* sord_new_relative_uri (\fBSordWorld\fP *world, const uint8_t *str, const uint8_t *base_uri)" .PP Get a URI node from a relative URI string\&. .SS "\fBSordNode\fP* sord_new_blank (\fBSordWorld\fP *world, const uint8_t *str)" .PP Get a blank node from a string\&. Note this function measures \fCstr\fP, which is a common bottleneck\&. Use sord_node_from_serd_node instead if \fCstr\fP is already measured\&. .SS "\fBSordNode\fP* sord_new_literal (\fBSordWorld\fP *world, \fBSordNode\fP *datatype, const uint8_t *str, const char *lang)" .PP Get a literal node from a string\&. Note this function measures \fCstr\fP, which is a common bottleneck\&. Use sord_node_from_serd_node instead if \fCstr\fP is already measured\&. .SS "\fBSordNode\fP* sord_node_copy (const \fBSordNode\fP *node)" .PP Copy a node (obtain a reference)\&. Node that since nodes are interned and reference counted, this does not actually create a deep copy of \fCnode\fP\&. .SS "void sord_node_free (\fBSordWorld\fP *world, \fBSordNode\fP *node)" .PP Free a node (drop a reference)\&. .SS "\fBSordNodeType\fP sord_node_get_type (const \fBSordNode\fP *node)" .PP Return the type of a node (SORD_URI, SORD_BLANK, or SORD_LITERAL)\&. .SS "const uint8_t* sord_node_get_string (const \fBSordNode\fP *node)" .PP Return the string value of a node\&. .SS "const uint8_t* sord_node_get_string_counted (const \fBSordNode\fP *node, size_t *len)" .PP Return the string value of a node, and set \fClen\fP to its length\&. .SS "const char* sord_node_get_language (const \fBSordNode\fP *node)" .PP Return the language of a literal node (or NULL)\&. .SS "\fBSordNode\fP* sord_node_get_datatype (const \fBSordNode\fP *node)" .PP Return the datatype URI of a literal node (or NULL)\&. .SS "SerdNodeFlags sord_node_get_flags (const \fBSordNode\fP *node)" .PP Return the flags (string attributes) of a node\&. .SS "bool sord_node_is_inline_object (const \fBSordNode\fP *node)" .PP Return 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\&. .SS "bool sord_node_equals (const \fBSordNode\fP *a, const \fBSordNode\fP *b)" .PP Return true iff \fCa\fP is equal to \fCb\fP\&. Note this is much faster than comparing the node's strings\&. .SS "const SerdNode* sord_node_to_serd_node (const \fBSordNode\fP *node)" .PP Return a SordNode as a SerdNode\&. The returned node is shared and must not be freed or modified\&. .SS "\fBSordNode\fP* sord_node_from_serd_node (\fBSordWorld\fP *world, SerdEnv *env, const SerdNode *node, const SerdNode *datatype, const SerdNode *lang)" .PP Create a new SordNode from a SerdNode\&. The returned node must be freed using sord_node_free\&. .SS "\fBSordModel\fP* sord_new (\fBSordWorld\fP *world, unsignedindices, boolgraphs)" .PP Create a new model\&. .PP \fBParameters:\fP .RS 4 \fIworld\fP The world in which to make this model\&. .br \fIindices\fP 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)\&. .br \fIgraphs\fP If true, store (and index) graph contexts\&. .RE .PP .SS "void sord_free (\fBSordModel\fP *model)" .PP Close and free \fCmodel\fP\&. .SS "\fBSordWorld\fP* sord_get_world (\fBSordModel\fP *model)" .PP Get the world associated with \fCmodel\fP\&. .SS "size_t sord_num_nodes (const \fBSordWorld\fP *world)" .PP Return the number of nodes stored in \fCworld\fP\&. Nodes are included in this count iff they are a part of a quad in \fCworld\fP\&. .SS "size_t sord_num_quads (const \fBSordModel\fP *model)" .PP Return the number of quads stored in \fCmodel\fP\&. .SS "\fBSordIter\fP* sord_begin (const \fBSordModel\fP *model)" .PP Return an iterator to the start of \fCmodel\fP\&. .SS "\fBSordIter\fP* sord_find (\fBSordModel\fP *model, const \fBSordQuad\fPpat)" .PP Search for statements by a quad pattern\&. .PP \fBReturns:\fP .RS 4 an iterator to the first match, or NULL if no matches found\&. .RE .PP .SS "\fBSordIter\fP* sord_search (\fBSordModel\fP *model, const \fBSordNode\fP *s, const \fBSordNode\fP *p, const \fBSordNode\fP *o, const \fBSordNode\fP *g)" .PP Search for statements by nodes\&. .PP \fBReturns:\fP .RS 4 an iterator to the first match, or NULL if no matches found\&. .RE .PP .SS "\fBSordNode\fP* sord_get (\fBSordModel\fP *model, const \fBSordNode\fP *s, const \fBSordNode\fP *p, const \fBSordNode\fP *o, const \fBSordNode\fP *g)" .PP Search for a single node that matches a pattern\&. Exactly one of \fCs\fP, \fCp\fP, \fCo\fP 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\&. .PP \fBReturns:\fP .RS 4 the first matching node, or NULL if no matches are found\&. .RE .PP .SS "bool sord_ask (\fBSordModel\fP *model, const \fBSordNode\fP *s, const \fBSordNode\fP *p, const \fBSordNode\fP *o, const \fBSordNode\fP *g)" .PP Return true iff a statement exists\&. .SS "uint64_t sord_count (\fBSordModel\fP *model, const \fBSordNode\fP *s, const \fBSordNode\fP *p, const \fBSordNode\fP *o, const \fBSordNode\fP *g)" .PP Return the number of matching statements\&. .SS "bool sord_contains (\fBSordModel\fP *model, const \fBSordQuad\fPpat)" .PP Check if \fCmodel\fP contains a triple pattern\&. .SS "bool sord_add (\fBSordModel\fP *model, const \fBSordQuad\fPquad)" .PP Add a quad to a model\&. .SS "void sord_remove (\fBSordModel\fP *model, const \fBSordQuad\fPquad)" .PP Remove a quad from a model\&. Note that is it illegal to remove while iterating over \fCmodel\fP\&. .SS "\fBSordInserter\fP* sord_inserter_new (\fBSordModel\fP *model, SerdEnv *env)" .PP Create an inserter for writing statements to a model\&. .SS "void sord_inserter_free (\fBSordInserter\fP *inserter)" .PP Free an inserter\&. .SS "SerdStatus sord_inserter_set_base_uri (\fBSordInserter\fP *inserter, const SerdNode *uri)" .PP Set the current base URI for writing to the model\&. Note this function can be safely casted to SerdBaseSink\&. .SS "SerdStatus sord_inserter_set_prefix (\fBSordInserter\fP *inserter, const SerdNode *name, const SerdNode *uri)" .PP Set a namespace prefix for writing to the model\&. Note this function can be safely casted to SerdPrefixSink\&. .SS "SerdStatus sord_inserter_write_statement (\fBSordInserter\fP *inserter, SerdStatementFlagsflags, const SerdNode *graph, const SerdNode *subject, const SerdNode *predicate, const SerdNode *object, const SerdNode *object_datatype, const SerdNode *object_lang)" .PP Write a statement to the model\&. Note this function can be safely casted to SerdStatementSink\&. .SS "void sord_iter_get (const \fBSordIter\fP *iter, \fBSordQuad\fPquad)" .PP Set \fCquad\fP to the quad pointed to by \fCiter\fP\&. .SS "const \fBSordNode\fP* sord_iter_get_node (const \fBSordIter\fP *iter, \fBSordQuadIndex\fPindex)" .PP Return a field of the quad pointed to by \fCiter\fP\&. .SS "const \fBSordModel\fP* sord_iter_get_model (\fBSordIter\fP *iter)" .PP Return the store pointed to by \fCiter\fP\&. .SS "bool sord_iter_next (\fBSordIter\fP *iter)" .PP Increment \fCiter\fP to point to the next statement\&. .SS "bool sord_iter_end (const \fBSordIter\fP *iter)" .PP Return true iff \fCiter\fP is at the end of its range\&. .SS "void sord_iter_free (\fBSordIter\fP *iter)" .PP Free \fCiter\fP\&. .SS "bool sord_quad_match (const \fBSordQuad\fPx, const \fBSordQuad\fPy)" .PP Match 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\&. .PP \fBReturns:\fP .RS 4 true iff \fCx\fP and \fCy\fP match\&. .RE .PP .SS "SerdReader* sord_new_reader (\fBSordModel\fP *model, SerdEnv *env, SerdSyntaxsyntax, \fBSordNode\fP *graph)" .PP Return a reader that will read into \fCmodel\fP\&. .SS "bool sord_write (\fBSordModel\fP *model, SerdWriter *writer, \fBSordNode\fP *graph)" .PP Write a model to a writer\&. .SS "bool sord_write_iter (\fBSordIter\fP *iter, SerdWriter *writer)" .PP Write a range to a writer\&. This increments \fCiter\fP to its end, then frees it\&. .SH "Author" .PP Generated automatically by Doxygen for Sord from the source code\&.