1 | /* -*- Mode: c; c-basic-offset: 2 -*- |
2 | * |
3 | * rdf_stream.h - RDF Stream interface and definitions |
4 | * |
5 | * Copyright (C) 2000-2008, David Beckett http://www.dajobe.org/ |
6 | * Copyright (C) 2000-2004, 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 | #ifndef LIBRDF_STREAM_H |
27 | #define LIBRDF_STREAM_H |
28 | |
29 | #ifdef __cplusplus |
30 | extern "C" { |
31 | #endif |
32 | |
33 | /** |
34 | * librdf_stream_map_handler: |
35 | * @stream: Stream that this map is operating over. |
36 | * @map_context: Map data context pointer. |
37 | * @item: Pointer to the current item in the iteration. |
38 | * |
39 | * Map function for a #librdf_stream map operation. |
40 | * |
41 | * See librdf_stream_add_map(). |
42 | * |
43 | * Returns: item in keep the iteration or NULL to remove it |
44 | */ |
45 | typedef librdf_statement* (*librdf_stream_map_handler)(librdf_stream *stream, void *map_context, librdf_statement *item); |
46 | |
47 | /** |
48 | * librdf_stream_map_free_context_handler: |
49 | * @map_context: Map data context pointer. |
50 | * |
51 | * Free handler function for a #librdf_stream map operation. |
52 | * |
53 | * See librdf_stream_add_map(). |
54 | */ |
55 | typedef void (*librdf_stream_map_free_context_handler)(void *map_context); |
56 | |
57 | #ifdef LIBRDF_INTERNAL |
58 | #include <rdf_stream_internal.h> |
59 | #endif |
60 | |
61 | |
62 | /** |
63 | * librdf_stream_get_method_flags: |
64 | * @LIBRDF_STREAM_GET_METHOD_GET_OBJECT: get object from iterator - implementing librdf_stream_get_object() |
65 | * @LIBRDF_STREAM_GET_METHOD_GET_CONTEXT: get context from iterator - implementing librdf_stream_get_context() |
66 | * |
67 | * Flags for librdf_new_stream() get_method function pointer. |
68 | */ |
69 | typedef enum { |
70 | LIBRDF_STREAM_GET_METHOD_GET_OBJECT = LIBRDF_ITERATOR_GET_METHOD_GET_OBJECT, |
71 | LIBRDF_STREAM_GET_METHOD_GET_CONTEXT = LIBRDF_ITERATOR_GET_METHOD_GET_CONTEXT |
72 | } librdf_stream_get_method_flags; |
73 | |
74 | |
75 | /* constructor */ |
76 | |
77 | REDLAND_API |
78 | 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*)); |
79 | REDLAND_API |
80 | librdf_stream* librdf_new_stream_from_node_iterator(librdf_iterator* iterator, librdf_statement* statement, librdf_statement_part field); |
81 | |
82 | /* destructor */ |
83 | |
84 | REDLAND_API |
85 | void librdf_free_stream(librdf_stream* stream); |
86 | |
87 | /* methods */ |
88 | REDLAND_API |
89 | int librdf_stream_end(librdf_stream* stream); |
90 | |
91 | REDLAND_API |
92 | int librdf_stream_next(librdf_stream* stream); |
93 | REDLAND_API |
94 | librdf_statement* librdf_stream_get_object(librdf_stream* stream); |
95 | REDLAND_API |
96 | librdf_node* librdf_stream_get_context2(librdf_stream* stream); |
97 | REDLAND_API REDLAND_DEPRECATED |
98 | void* librdf_stream_get_context(librdf_stream* stream); |
99 | |
100 | REDLAND_API |
101 | 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); |
102 | |
103 | REDLAND_API REDLAND_DEPRECATED |
104 | void librdf_stream_print(librdf_stream *stream, FILE *fh); |
105 | REDLAND_API |
106 | int librdf_stream_write(librdf_stream *stream, raptor_iostream *iostr); |
107 | |
108 | REDLAND_API |
109 | librdf_stream* librdf_new_empty_stream(librdf_world *world); |
110 | |
111 | #ifdef __cplusplus |
112 | } |
113 | #endif |
114 | |
115 | #endif |
116 | |