triple#
A subject-predicate-object triple type.
This library defines triples as subject-predicate-object tuplets with an id. This allow a allows the subject or object to refer to another triple via its id, as one would expect for RDF triples (see https://en.wikipedia.org/wiki/Semantic_triple).
Typedefs
Functions
-
void triple_set_default_namespace(const char *namespace)#
Sets default namespace to be prepended to triple id’s.
Use this function to convert the id’s to proper URI’s.
-
const char *triple_get_default_namespace(void)#
Returns default namespace.
-
int triple_set(Triple *t, const char *s, const char *p, const char *o, const char *d, const char *id)#
Convinient function to assign a triple. This allocates new memory for the internal s, p, o and id pointers. If
id
is NULL, a new id will be generated bases ons
,p
ando
. For literals, the datatype can be provided withd
.
-
int triple_reset(Triple *t, const char *s, const char *p, const char *o, const char *d, const char *id)#
Like triple_set(), but free’s allocated memory in
t
before re-assigning it. Don’t use this function ift
has not been initiated.
-
char *triple_get_id(const char *namespace, const char *s, const char *p, const char *o, const char *d)#
Returns an newly malloc’ed unique id calculated from triple.
If
namespace
is NULL, the default namespace set with triple_set_default_namespace() will be used.Returns NULL on error.
-
Triple *triple_copy(Triple *dest, const Triple *src)#
Copies triple
src
todest
and returns a pointer todest
.Existing memory hold by
dest
is not free’ed. So ifdest
may hold some memory, calltriple_clean()
before calling this function.
-
struct _Triple#
- #include <triple.h>
A subject-predicate-object triple used to represent a relation. The s-p-o-id strings should be allocated with malloc.