|  |  |  | Redland RDF Library Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
typedef librdf_iterator; enum librdf_iterator_get_method_flags; void * (*librdf_iterator_map_handler) (librdf_iterator *iterator,void *map_context,void *item); void (*librdf_iterator_map_free_context_handler) (void *map_context); librdf_iterator* librdf_new_iterator (librdf_world *world,void *context,int (is_end_methodvoid*) (),int (next_methodvoid*) (),void* (get_methodvoid*, int) (),void (finished_methodvoid*) ()); void librdf_free_iterator (librdf_iterator *iterator); int librdf_iterator_end (librdf_iterator *iterator); int librdf_iterator_have_elements (librdf_iterator *iterator); int librdf_iterator_next (librdf_iterator *iterator); void* librdf_iterator_get_object (librdf_iterator *iterator); void* librdf_iterator_get_context (librdf_iterator *iterator); void* librdf_iterator_get_key (librdf_iterator *iterator); void* librdf_iterator_get_value (librdf_iterator *iterator); int librdf_iterator_add_map (librdf_iterator *iterator,librdf_iterator_map_handler map_function,librdf_iterator_map_free_context_handler free_context,void *map_context); librdf_iterator* librdf_new_empty_iterator (librdf_world *world);
Provides a way to operate across a sequence of objects that are
generated one-by-one on demand.  The returned objects can be of any
type but the main public methods are on the librdf_model classs and
return sequence of librdf_node objects such as librdf_model_get_sources().
typedef enum {
  LIBRDF_ITERATOR_GET_METHOD_GET_OBJECT  = 0,
  LIBRDF_ITERATOR_GET_METHOD_GET_CONTEXT = 1,
  LIBRDF_ITERATOR_GET_METHOD_GET_KEY     = 2,
  LIBRDF_ITERATOR_GET_METHOD_GET_VALUE   = 3
} librdf_iterator_get_method_flags;
Flags for librdf_new_iterator() get_method function pointer.
| get object from iterator - implementing librdf_iterator_get_context() | |
| get context from iterator - implementing librdf_iterator_get_object() | |
| get iterator key object from iterator - implementing librdf_iterator_get_key() | |
| get iterator value from iterator - implementing librdf_iterator_get_value() | 
void * (*librdf_iterator_map_handler) (librdf_iterator *iterator,void *map_context,void *item);
Map function for a librdf_iterator map operation.
See librdf_iterator_add_map().
| 
 | Iterator 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_iterator_map_free_context_handler)
                                                        (void *map_context);
Free handler function for a librdf_iterator map operation.
See librdf_iterator_add_map().
| 
 | Map data context pointer. | 
librdf_iterator* librdf_new_iterator (librdf_world *world,void *context,int (is_end_methodvoid*) (),int (next_methodvoid*) (),void* (get_methodvoid*, int) (),void (finished_methodvoid*) ());
Constructor - create a new librdf_iterator object.
The iterator object takes ownership of context and frees it with finished_method.
The finished method is not called if librdf_new_iterator fails and returns NULL.
| 
 | redland world object | 
| 
 | context to pass to the iterator functions | 
| Returns : | a new librdf_iterator object or NULL on failure | 
void                librdf_free_iterator                (librdf_iterator *iterator);
Destructor - destroy a librdf_iterator object.
| 
 | the librdf_iterator object | 
int                 librdf_iterator_end                 (librdf_iterator *iterator);
Test if the iterator has finished.
| 
 | the librdf_iterator object | 
| Returns : | non 0 if the iterator has finished | 
int                 librdf_iterator_have_elements       (librdf_iterator *iterator);
Test if the iterator has finished.
DEPRECATED - use !librdf_iterator_end(iterator)
| 
 | the librdf_iterator object | 
| Returns : | 0 if the iterator has finished | 
int                 librdf_iterator_next                (librdf_iterator *iterator);
Move to the next iterator element.
| 
 | the librdf_iterator object | 
| Returns : | non 0 if the iterator has finished | 
void*               librdf_iterator_get_object          (librdf_iterator *iterator);
Get the current object from the iterator.
This method returns a SHARED pointer to the current iterator object which should be copied by the caller to preserve it if the iterator is moved on librdf_iterator_next or if it should last after the iterator is closed.
| 
 | the librdf_iterator object | 
| Returns : | The next element or NULL if the iterator has finished. | 
void*               librdf_iterator_get_context         (librdf_iterator *iterator);
Get the context of the current object on the iterator.
This method returns a SHARED pointer to the current context node object which should be copied by the caller to preserve it if the iterator is moved on librdf_iterator_next or if it should last after the iterator is closed.
| 
 | the librdf_iterator object | 
| Returns : | The context (can be NULL) or NULL if the iterator has finished. | 
void*               librdf_iterator_get_key             (librdf_iterator *iterator);
Get the key of the current object on the iterator.
| 
 | the librdf_iterator object | 
| Returns : | The context or NULL if the iterator has finished. | 
void*               librdf_iterator_get_value           (librdf_iterator *iterator);
Get the value of the current object on the iterator.
| 
 | the librdf_iterator object | 
| Returns : | The context or NULL if the iterator has finished. | 
int librdf_iterator_add_map (librdf_iterator *iterator,librdf_iterator_map_handler map_function,librdf_iterator_map_free_context_handler free_context,void *map_context);
Add a librdf_iterator mapping function.
Adds an iterator mapping function which operates over the iterator 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 non 0 to allow the element to be returned.
| 
 | the iterator | 
| 
 | the function to operate | 
| 
 | the function to use to free the context (or NULL) | 
| 
 | the context to pass to the map function | 
| Returns : | Non 0 on failure | 
librdf_iterator*    librdf_new_empty_iterator           (librdf_world *world);
Constructor - create a new librdf_iterator with no content.
| 
 | redland world object | 
| Returns : | a new librdf_iterator object or NULL on failure |