Redland RDF Library Manual | ||||
---|---|---|---|---|
Top | Description |
Stream of triples (#librdf_statement).Stream of triples (#librdf_statement). — Sequence of RDF Triples. |
typedef librdf_stream; enum librdf_stream_get_method_flags; librdf_statement * (*librdf_stream_map_handler) (librdf_stream *stream
,void *map_context
,librdf_statement *item
); void (*librdf_stream_map_free_context_handler) (void *map_context
); librdf_stream * librdf_new_stream (librdf_world *world
,void *context
,int (*is_end_method) (void*)
,int (*next_method) (void*)
,void* (*get_method) (void*, int)
,void (*finished_method) (void*)
); librdf_stream * librdf_new_stream_from_node_iterator (librdf_iterator *iterator
,librdf_statement *statement
,librdf_statement_part field
); librdf_stream * librdf_new_empty_stream (librdf_world *world
); void librdf_free_stream (librdf_stream *stream
); int librdf_stream_end (librdf_stream *stream
); int librdf_stream_next (librdf_stream *stream
); librdf_statement * librdf_stream_get_object (librdf_stream *stream
); void * librdf_stream_get_context (librdf_stream *stream
); librdf_node * librdf_stream_get_context2 (librdf_stream *stream
); int librdf_stream_add_map (librdf_stream *stream
,librdf_stream_map_handler map_function
,librdf_stream_map_free_context_handler free_context
,void *map_context
); void librdf_stream_print (librdf_stream *stream
,FILE *fh
); int librdf_stream_write (librdf_stream *stream
,raptor_iostream *iostr
);
typedef enum { LIBRDF_STREAM_GET_METHOD_GET_OBJECT = LIBRDF_ITERATOR_GET_METHOD_GET_OBJECT, LIBRDF_STREAM_GET_METHOD_GET_CONTEXT = LIBRDF_ITERATOR_GET_METHOD_GET_CONTEXT } librdf_stream_get_method_flags;
Flags for librdf_new_stream()
get_method function pointer.
get object from iterator - implementing librdf_stream_get_object()
|
|
get context from iterator - implementing librdf_stream_get_context()
|
librdf_statement * (*librdf_stream_map_handler) (librdf_stream *stream
,void *map_context
,librdf_statement *item
);
Map function for a librdf_stream map operation.
|
Stream that this map is operating over. |
|
Map data context pointer. |
|
Pointer to the current item in the iteration. |
Returns : |
item in keep the iteration or NULL to remove it |
void (*librdf_stream_map_free_context_handler)
(void *map_context
);
Free handler function for a librdf_stream map operation.
|
Map data context pointer. |
librdf_stream * librdf_new_stream (librdf_world *world
,void *context
,int (*is_end_method) (void*)
,int (*next_method) (void*)
,void* (*get_method) (void*, int)
,void (*finished_method) (void*)
);
Constructor - create a new librdf_stream.
Creates a new stream with an implementation based on the passed in
functions. The functions next_statement and end_of_stream will be called
multiple times until either of them signify the end of stream by
returning NULL or non 0 respectively. The finished function is called
once only when the stream object is destroyed with librdf_free_stream()
A mapping function can be set for the stream using librdf_stream_add_map()
function which allows the statements generated by the stream to be
filtered and/or altered as they are generated before passing back
to the user.
|
redland world object |
|
context to pass to the stream implementing objects |
|
pointer to function to test for end of stream |
|
pointer to function to move to the next statement in stream |
|
pointer to function to get the current statement |
|
pointer to function to finish the stream. |
Returns : |
a new librdf_stream object or NULL on failure |
librdf_stream * librdf_new_stream_from_node_iterator (librdf_iterator *iterator
,librdf_statement *statement
,librdf_statement_part field
);
Constructor - create a new librdf_stream from an iterator of nodes.
Creates a new librdf_stream using the passed in librdf_iterator which generates a series of librdf_node objects. The resulting nodes are then inserted into the given statement and returned. The field attribute indicates which statement node is being generated.
|
librdf_iterator of librdf_node objects |
|
librdf_statement prototype with one NULL node space |
|
node part of statement |
Returns : |
a new librdf_stream object or NULL on failure |
librdf_stream * librdf_new_empty_stream (librdf_world *world
);
Constructor - create a new librdf_stream with no content.
|
redland world object |
Returns : |
a new librdf_stream object or NULL on failure |
void librdf_free_stream (librdf_stream *stream
);
Destructor - destroy an libdf_stream object.
|
librdf_stream object |
int librdf_stream_end (librdf_stream *stream
);
Test if the stream has ended.
|
librdf_stream object |
Returns : |
non 0 at end of stream. |
int librdf_stream_next (librdf_stream *stream
);
Move to the next librdf_statement in the stream.
|
librdf_stream object |
Returns : |
non 0 if the stream has finished |
librdf_statement * librdf_stream_get_object (librdf_stream *stream
);
Get the current librdf_statement in the stream.
This method returns a SHARED pointer to the current statement object
which should be copied by the caller to preserve it if the stream
is moved on librdf_stream_next()
or if it should last after the
stream is closed. librdf_new_statement_from_statement()
can be used
for copying the statement.
|
librdf_stream object |
Returns : |
the current librdf_statement object or NULL at end of stream. |
void * librdf_stream_get_context (librdf_stream *stream
);
Get the context of the current object on the stream.
This method returns a SHARED pointer to the current context node object which should be copied by the caller to preserve it if the stream is moved on librdf_stream_next or if it should last after the stream is closed.
Deprecated
: Use librdf_stream_get_context2()
which returns a librdf_node
|
the librdf_stream object |
Returns : |
The context node (can be NULL) or NULL if the stream has finished. |
librdf_node * librdf_stream_get_context2 (librdf_stream *stream
);
Get the context of the current object on the stream.
This method returns a SHARED pointer to the current context node object which should be copied by the caller to preserve it if the stream is moved on librdf_stream_next or if it should last after the stream is closed.
|
the librdf_stream object |
Returns : |
The context node (can be NULL) or NULL if the stream has finished. |
int librdf_stream_add_map (librdf_stream *stream
,librdf_stream_map_handler map_function
,librdf_stream_map_free_context_handler free_context
,void *map_context
);
Add a librdf_stream mapping function.
Adds an stream mapping function which operates over the stream to select which elements are returned; it will be applied as soon as this method is called.
Several mapping functions can be added and they are applied in the order given.
The mapping function should return the statement to return, or NULL to remove it from the stream.
|
the stream |
|
the function to perform the mapping |
|
the function to use to free the context (or NULL) |
|
the context to pass to the map function |
Returns : |
Non 0 on failure |
void librdf_stream_print (librdf_stream *stream
,FILE *fh
);
Print the stream.
This prints the remaining statements of the stream to the given
file handle. Note that after this method is called the stream
will be empty so that librdf_stream_end()
will always be true
and librdf_stream_next()
will always return NULL. The only
useful operation is to dispose of the stream with the
librdf_free_stream()
destructor.
This method is for debugging and the format of the output should not be relied on.
Deprecated
: Use librdf_stream_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 stream object |
|
the FILE stream to print to |
int librdf_stream_write (librdf_stream *stream
,raptor_iostream *iostr
);
Write a stream of triples to an iostream in a debug format.
This prints the remaining statements of the stream to the given raptor_iostream in a debug format.
Note that after this method is called the stream will be empty so
that librdf_stream_end()
will always be true and
librdf_stream_next()
will always return NULL. The only useful
operation is to dispose of the stream with the
librdf_free_stream()
destructor.
This method is for debugging and the format of the output should not be relied on. In particular, when contexts are used the result may be 4 nodes.
|
the stream object |
|
the iostream to write to |
Returns : |
non-0 on failure |
Provides a way to operate across a sequence of RDF Triples that are generated one-by-one on demand. The generated triples can be from some API call in the librdf_model class, from listing a graph content as individual triples, from parsing a syntax or returning an RDF graph result from a query. Streams can be passed into methods for the reverse operations such as adding to a graph, serializing a graph to a syntax. Streams pass individual triples (librdf_statement) between objects and are usually lazily generated and consumed.
Navigation: Redland Home Page