Redland RDF Library Manual | ||||
---|---|---|---|---|
Top | Description |
typedef librdf_statement; enum librdf_statement_part; librdf_statement * librdf_new_statement (librdf_world *world
); librdf_statement * librdf_new_statement_from_statement (librdf_statement *statement
); librdf_statement * librdf_new_statement_from_statement2 (librdf_statement *statement
); librdf_statement * librdf_new_statement_from_nodes (librdf_world *world
,librdf_node *subject
,librdf_node *predicate
,librdf_node *object
); void librdf_statement_init (librdf_world *world
,librdf_statement *statement
); void librdf_statement_clear (librdf_statement *statement
); void librdf_free_statement (librdf_statement *statement
); librdf_node * librdf_statement_get_subject (librdf_statement *statement
); void librdf_statement_set_subject (librdf_statement *statement
,librdf_node *node
); librdf_node * librdf_statement_get_predicate (librdf_statement *statement
); void librdf_statement_set_predicate (librdf_statement *statement
,librdf_node *node
); librdf_node * librdf_statement_get_object (librdf_statement *statement
); void librdf_statement_set_object (librdf_statement *statement
,librdf_node *node
); int librdf_statement_is_complete (librdf_statement *statement
); unsigned char * librdf_statement_to_string (librdf_statement *statement
); void librdf_statement_print (librdf_statement *statement
,FILE *fh
); int librdf_statement_equals (librdf_statement *statement1
,librdf_statement *statement2
); int librdf_statement_match (librdf_statement *statement
,librdf_statement *partial_statement
); size_t librdf_statement_encode (librdf_statement *statement
,unsigned char *buffer
,size_t length
); size_t librdf_statement_encode2 (librdf_world *world
,librdf_statement *statement
,unsigned char *buffer
,size_t length
); size_t librdf_statement_encode_parts (librdf_statement *statement
,librdf_node *context_node
,unsigned char *buffer
,size_t length
,librdf_statement_part fields
); size_t librdf_statement_encode_parts2 (librdf_world *world
,librdf_statement *statement
,librdf_node *context_node
,unsigned char *buffer
,size_t length
,librdf_statement_part fields
); size_t librdf_statement_decode (librdf_statement *statement
,unsigned char *buffer
,size_t length
); size_t librdf_statement_decode2 (librdf_world *world
,librdf_statement *statement
,librdf_node **context_node
,unsigned char *buffer
,size_t length
); size_t librdf_statement_decode_parts (librdf_statement *statement
,librdf_node **context_node
,unsigned char *buffer
,size_t length
); int librdf_statement_write (librdf_statement *statement
,raptor_iostream *iostr
);
An object representing an RDF Triple of three RDF terms (librdf_node). Triples can be created, accessed, destroyed and en/decoded into a binary form for use in storage.
typedef enum { LIBRDF_STATEMENT_SUBJECT = 1 << 0, LIBRDF_STATEMENT_PREDICATE = 1 << 1, LIBRDF_STATEMENT_OBJECT = 1 << 2, /* must be a combination of all of the above */ LIBRDF_STATEMENT_ALL = (LIBRDF_STATEMENT_SUBJECT| LIBRDF_STATEMENT_PREDICATE| LIBRDF_STATEMENT_OBJECT) } librdf_statement_part;
Flags that are or-ed to indicate statement parts.
Used in fields arguments to methods such as the public
librdf_statement_encode_parts()
librdf_statement_decode_parts()
librdf_new_stream_from_node_iterator()
.
librdf_statement * librdf_new_statement (librdf_world *world
);
Constructor - create a new empty librdf_statement.
|
redland world object |
Returns : |
a new librdf_statement or NULL on failure |
librdf_statement * librdf_new_statement_from_statement (librdf_statement *statement
);
Copy constructor - create a new librdf_statement from an existing librdf_statement. Creates a deep copy - changes to original statement nodes are not reflected in the copy.
|
librdf_statement to copy |
Returns : |
a new librdf_statement with copy or NULL on failure |
librdf_statement * librdf_new_statement_from_statement2
(librdf_statement *statement
);
Copy constructor - create a new librdf_statement from an existing librdf_statement. Creates a shallow copy - changes to original statement nodes are reflected in the copy.
|
librdf_statement to copy |
Returns : |
a new librdf_statement with copy or NULL on failure |
librdf_statement * librdf_new_statement_from_nodes (librdf_world *world
,librdf_node *subject
,librdf_node *predicate
,librdf_node *object
);
Constructor - create a new librdf_statement from existing librdf_node objects.
The node objects become owned by the new statement (or freed on error).
|
redland world object |
|
librdf_node |
|
librdf_node |
|
librdf_node |
Returns : |
a new librdf_statement with copy or NULL on failure |
void librdf_statement_init (librdf_world *world
,librdf_statement *statement
);
Initialise a statically declared librdf_statement.
This MUST be called on a statically declared librdf_statement to initialise it properly. It is the responsibility of the user of the statically allocated librdf_statement to deal with deallocation of any statement parts (subject, predicate, object).
|
redland world object |
|
librdf_statement object |
void librdf_statement_clear (librdf_statement *statement
);
Empty a librdf_statement of nodes.
|
librdf_statement object |
void librdf_free_statement (librdf_statement *statement
);
Destructor - destroy a librdf_statement.
|
librdf_statement object |
librdf_node * librdf_statement_get_subject (librdf_statement *statement
);
Get the statement subject.
This method returns a SHARED pointer to the subject which must be copied by the caller if needed.
|
librdf_statement object |
Returns : |
a pointer to the librdf_node of the statement subject - |
void librdf_statement_set_subject (librdf_statement *statement
,librdf_node *node
);
Set the statement subject.
The subject passed in becomes owned by the statement object and must not be used by the caller after this call.
|
librdf_statement object |
|
librdf_node of subject |
librdf_node * librdf_statement_get_predicate (librdf_statement *statement
);
Get the statement predicate.
This method returns a SHARED pointer to the predicate which must be copied by the caller if needed.
|
librdf_statement object |
Returns : |
a pointer to the librdf_node of the statement predicate - |
void librdf_statement_set_predicate (librdf_statement *statement
,librdf_node *node
);
Set the statement predicate.
The predicate passed in becomes owned by the statement object and must not be used by the caller after this call.
|
librdf_statement object |
|
librdf_node of predicate |
librdf_node * librdf_statement_get_object (librdf_statement *statement
);
Get the statement object.
This method returns a SHARED pointer to the object which must be copied by the caller if needed.
|
librdf_statement object |
Returns : |
a pointer to the librdf_node of the statement object - |
void librdf_statement_set_object (librdf_statement *statement
,librdf_node *node
);
Set the statement object.
The object passed in becomes owned by the statement object and must not be used by the caller after this call.
|
librdf_statement object |
|
librdf_node of object |
int librdf_statement_is_complete (librdf_statement *statement
);
Check if statement is a complete and legal RDF triple.
Checks that all subject, predicate, object fields are present and they have the allowed node types.
|
librdf_statement object |
Returns : |
non 0 if the statement is complete and legal |
unsigned char * librdf_statement_to_string (librdf_statement *statement
);
Format the librdf_statement as a string.
Formats the statement as a newly allocate string that must be freed by the caller.
Deprecated
: Use librdf_statement_write()
to write to
raptor_iostream which can be made to write to a string. Use a
librdf_serializer to write proper syntax formats.
|
the statement |
Returns : |
the string or NULL on failure. |
void librdf_statement_print (librdf_statement *statement
,FILE *fh
);
Pretty print the statement to a file descriptor.
This method is for debugging and the format of the output should not be relied on.
|
the statement |
|
file handle |
int librdf_statement_equals (librdf_statement *statement1
,librdf_statement *statement2
);
Check if two statements are equal.
|
first librdf_statement |
|
second librdf_statement |
Returns : |
non 0 if statements are equal |
int librdf_statement_match (librdf_statement *statement
,librdf_statement *partial_statement
);
Match a statement against a 'partial' statement.
A partial statement is where some parts of the statement -
subject, predicate or object can be empty (NULL).
Empty parts match against any value, parts with values
must match exactly. Node matching is done via librdf_node_equals()
|
statement |
|
statement with possible empty parts |
Returns : |
non 0 on match |
size_t librdf_statement_encode (librdf_statement *statement
,unsigned char *buffer
,size_t length
);
Serialise a statement into a buffer.
Encodes the given statement in the buffer, which must be of sufficient size. If buffer is NULL, no work is done but the size of buffer required is returned.
Deprecated
: Use librdf_statement_encode2()
|
the statement to serialise |
|
the buffer to use |
|
buffer size |
Returns : |
the number of bytes written or 0 on failure. |
size_t librdf_statement_encode2 (librdf_world *world
,librdf_statement *statement
,unsigned char *buffer
,size_t length
);
Serialise a statement into a buffer.
Encodes the given statement in the buffer, which must be of sufficient size. If buffer is NULL, no work is done but the size of buffer required is returned.
|
redland world |
|
the statement to serialise |
|
the buffer to use |
|
buffer size |
Returns : |
the number of bytes written or 0 on failure. |
size_t librdf_statement_encode_parts (librdf_statement *statement
,librdf_node *context_node
,unsigned char *buffer
,size_t length
,librdf_statement_part fields
);
Serialise parts of a statement into a buffer.
Encodes the given statement in the buffer, which must be of sufficient size. If buffer is NULL, no work is done but the size of buffer required is returned.
The fields values are or-ed combinations of: LIBRDF_STATEMENT_SUBJECT LIBRDF_STATEMENT_PREDICATE LIBRDF_STATEMENT_OBJECT or LIBRDF_STATEMENT_ALL for subject,prdicate,object fields
If context_node is given, it is encoded also
Deprecated
: This will no longer be a public API
|
statement to serialise |
|
librdf_node context node (can be NULL) |
|
the buffer to use |
|
buffer size |
|
fields to encode |
Returns : |
the number of bytes written or 0 on failure. |
size_t librdf_statement_encode_parts2 (librdf_world *world
,librdf_statement *statement
,librdf_node *context_node
,unsigned char *buffer
,size_t length
,librdf_statement_part fields
);
Serialise parts of a statement into a buffer.
Encodes the given statement in the buffer, which must be of sufficient size. If buffer is NULL, no work is done but the size of buffer required is returned.
The fields values are or-ed combinations of: LIBRDF_STATEMENT_SUBJECT LIBRDF_STATEMENT_PREDICATE LIBRDF_STATEMENT_OBJECT or LIBRDF_STATEMENT_ALL for subject,prdicate,object fields
If context_node is given, it is encoded also
|
redland world object |
|
statement to serialise |
|
librdf_node context node (can be NULL) |
|
the buffer to use |
|
buffer size |
|
fields to encode |
Returns : |
the number of bytes written or 0 on failure. |
size_t librdf_statement_decode (librdf_statement *statement
,unsigned char *buffer
,size_t length
);
Decodes a statement from a buffer. (ALWAYS FAILS)
Used to decode the serialised statement as created by
librdf_statement_encode()
from the given buffer.
Deprecated
: Replaced by librdf_statement_decode2()
which works.
|
the statement to deserialise into |
|
the buffer to use |
|
buffer size |
Returns : |
0 signifying failure |
size_t librdf_statement_decode2 (librdf_world *world
,librdf_statement *statement
,librdf_node **context_node
,unsigned char *buffer
,size_t length
);
Decodes a statement + context node from a buffer.
Decodes the serialised statement (as created by librdf_statement_encode()
)
from the given buffer. If a context node is found and context_node is
not NULL, a pointer to the new librdf_node is stored in *context_node.
|
redland world |
|
the statement to deserialise into |
|
pointer to librdf_node context_node to deserialise into |
|
the buffer to use |
|
buffer size |
Returns : |
number of bytes used or 0 on failure (bad encoding, allocation failure) |
size_t librdf_statement_decode_parts (librdf_statement *statement
,librdf_node **context_node
,unsigned char *buffer
,size_t length
);
Decodes a statement + context node from a buffer. (ALWAYS FAILS)
Used to decode the serialised statement as created by
librdf_statement_encode()
from the given buffer.
Deprecated
: Replaced by librdf_statement_decode2()
which works.
|
the statement to deserialise into |
|
pointer to librdf_node context_node to deserialise into |
|
the buffer to use |
|
buffer size |
Returns : |
0 signifying failure |
int librdf_statement_write (librdf_statement *statement
,raptor_iostream *iostr
);
Write the statement to an iostream
This method is for debugging and the format of the output should not be relied on.
|
the statement |
|
raptor iostream to write to |
Returns : |
non-0 on failure |