stream

stream

Functions

Types and Values

Description

Functions

librdf_stream_map_handler ()

librdf_statement *
(*librdf_stream_map_handler) (librdf_stream *stream,
                              void *map_context,
                              librdf_statement *item);

Map function for a librdf_stream map operation.

See librdf_stream_add_map().

Parameters

stream

Stream that this map is operating over.

 

map_context

Map data context pointer.

 

item

Pointer to the current item in the iteration.

 

Returns

item in keep the iteration or NULL to remove it


librdf_stream_map_free_context_handler ()

void
(*librdf_stream_map_free_context_handler)
                               (void *map_context);

Free handler function for a librdf_stream map operation.

See librdf_stream_add_map().

Parameters

map_context

Map data context pointer.

 

librdf_new_stream ()

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.

Parameters

world

redland world object

 

context

context to pass to the stream implementing objects

 

is_end_method

pointer to function to test for end of stream

 

next_method

pointer to function to move to the next statement in stream

 

get_method

pointer to function to get the current statement

 

finished_method

pointer to function to finish the stream.

 

Returns

a new librdf_stream object or NULL on failure


librdf_new_stream_from_node_iterator ()

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.

Parameters

iterator

librdf_iterator of librdf_node objects

 

statement

librdf_statement prototype with one NULL node space

 

field

node part of statement

 

Returns

a new librdf_stream object or NULL on failure


librdf_new_empty_stream ()

librdf_stream *
librdf_new_empty_stream (librdf_world *world);

Constructor - create a new librdf_stream with no content.

Parameters

world

redland world object

 

Returns

a new librdf_stream object or NULL on failure


librdf_free_stream ()

void
librdf_free_stream (librdf_stream *stream);

Destructor - destroy an libdf_stream object.

Parameters

stream

librdf_stream object

 

librdf_stream_end ()

int
librdf_stream_end (librdf_stream *stream);

Test if the stream has ended.

Parameters

stream

librdf_stream object

 

Returns

non 0 at end of stream.


librdf_stream_next ()

int
librdf_stream_next (librdf_stream *stream);

Move to the next librdf_statement in the stream.

Parameters

stream

librdf_stream object

 

Returns

non 0 if the stream has finished


librdf_stream_get_object ()

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.

Parameters

stream

librdf_stream object

 

Returns

the current librdf_statement object or NULL at end of stream.


librdf_stream_get_context ()

void *
librdf_stream_get_context (librdf_stream *stream);

librdf_stream_get_context is deprecated and should not be used in newly-written code.

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

Parameters

stream

the librdf_stream object

 

Returns

The context node (can be NULL) or NULL if the stream has finished.


librdf_stream_get_context2 ()

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.

Parameters

stream

the librdf_stream object

 

Returns

The context node (can be NULL) or NULL if the stream has finished.


librdf_stream_add_map ()

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.

Parameters

stream

the stream

 

map_function

the function to perform the mapping

 

free_context

the function to use to free the context (or NULL)

 

map_context

the context to pass to the map function

 

Returns

Non 0 on failure


librdf_stream_print ()

void
librdf_stream_print (librdf_stream *stream,
                     FILE *fh);

librdf_stream_print is deprecated and should not be used in newly-written code.

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.

Parameters

stream

the stream object

 

fh

the FILE stream to print to

 

librdf_stream_write ()

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.

Parameters

stream

the stream object

 

iostr

the iostream to write to

 

Returns

non-0 on failure

Types and Values

librdf_stream

typedef struct librdf_stream_s librdf_stream;

Redland stream class.


enum librdf_stream_get_method_flags

Flags for librdf_new_stream() get_method function pointer.

Members

LIBRDF_STREAM_GET_METHOD_GET_OBJECT

get object from iterator - implementing librdf_stream_get_object()

 

LIBRDF_STREAM_GET_METHOD_GET_CONTEXT

get context from iterator - implementing librdf_stream_get_context()