1 /* -*- Mode: c; c-basic-offset: 2 -*-
2  *
3  * rdf_iterator.h - RDF Iterator definition
4  *
5  * Copyright (C) 2000-2008, David Beckett http://www.dajobe.org/
6  * Copyright (C) 2000-2005, University of Bristol, UK http://www.bristol.ac.uk/
7  *
8  * This package is Free Software and part of Redland http://librdf.org/
9  *
10  * It is licensed under the following three licenses as alternatives:
11  *   1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
12  *   2. GNU General Public License (GPL) V2 or any newer version
13  *   3. Apache License, V2.0 or any newer version
14  *
15  * You may not use this file except in compliance with at least one of
16  * the above three licenses.
17  *
18  * See LICENSE.html or LICENSE.txt at the top of this package for the
19  * complete terms and further detail along with the license texts for
20  * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
21  *
22  *
23  */
24 
25 
26 
27 #ifndef LIBRDF_ITERATOR_H
28 #define LIBRDF_ITERATOR_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /**
35  * librdf_iterator_map_handler:
36  * @iterator: Iterator that this map is operating over.
37  * @map_context: Map data context pointer.
38  * @item: Pointer to the current item in the iteration.
39  *
40  * Map function for a #librdf_iterator map operation.
41  *
42  * See librdf_iterator_add_map().
43  *
44  * Returns: item in keep the iteration or NULL to remove it
45  */
46 typedef void* (*librdf_iterator_map_handler)(librdf_iterator *iterator, void *map_context, void *item);
47 
48 
49 /**
50  * librdf_iterator_map_free_context_handler:
51  * @map_context: Map data context pointer.
52  *
53  * Free handler function for a #librdf_iterator map operation.
54  *
55  * See librdf_iterator_add_map().
56  */
57 typedef void (*librdf_iterator_map_free_context_handler)(void *map_context);
58 
59 #ifdef LIBRDF_INTERNAL
60 #include <rdf_iterator_internal.h>
61 #endif
62 
63 
64 /**
65  * librdf_iterator_get_method_flags:
66  * @LIBRDF_ITERATOR_GET_METHOD_GET_CONTEXT: get context from iterator - implementing librdf_iterator_get_object()
67  * @LIBRDF_ITERATOR_GET_METHOD_GET_OBJECT: get object from iterator - implementing librdf_iterator_get_context()
68  * @LIBRDF_ITERATOR_GET_METHOD_GET_KEY: get iterator key object from iterator - implementing librdf_iterator_get_key()
69  * @LIBRDF_ITERATOR_GET_METHOD_GET_VALUE: get iterator value from iterator - implementing librdf_iterator_get_value()
70  *
71  * Flags for librdf_new_iterator() get_method function pointer.
72 */
73 /* iterator get_method flags */
74 typedef enum {
75   LIBRDF_ITERATOR_GET_METHOD_GET_OBJECT  = 0,
76   LIBRDF_ITERATOR_GET_METHOD_GET_CONTEXT = 1,
77   LIBRDF_ITERATOR_GET_METHOD_GET_KEY     = 2,
78   LIBRDF_ITERATOR_GET_METHOD_GET_VALUE   = 3
79 } librdf_iterator_get_method_flags;
80 
81 
82 REDLAND_API
83 librdf_iterator* librdf_new_iterator(librdf_world *world, void *context, int (*is_end_method)(void*), int (*next_method)(void*), void* (*get_method)(void*, int), void (*finished_method)(void*));
84 
85 REDLAND_API
86 void librdf_free_iterator(librdf_iterator* iterator);
87 
88 REDLAND_API
89 int librdf_iterator_end(librdf_iterator* iterator);
90 REDLAND_API REDLAND_DEPRECATED
91 int librdf_iterator_have_elements(librdf_iterator* iterator);
92 
93 REDLAND_API
94 int librdf_iterator_next(librdf_iterator* iterator);
95 REDLAND_API
96 void* librdf_iterator_get_object(librdf_iterator* iterator);
97 REDLAND_API
98 void* librdf_iterator_get_context(librdf_iterator* iterator);
99 REDLAND_API
100 void* librdf_iterator_get_key(librdf_iterator* iterator);
101 REDLAND_API
102 void* librdf_iterator_get_value(librdf_iterator* iterator);
103 
104 REDLAND_API
105 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);
106 
107 REDLAND_API
108 librdf_iterator* librdf_new_empty_iterator(librdf_world *world);
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif
115