1 | /* -*- Mode: c; c-basic-offset: 2 -*- |
2 | * |
3 | * rdf_model.h - RDF Model 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_MODEL_H |
28 | #define LIBRDF_MODEL_H |
29 | |
30 | #ifndef LIBRDF_OBJC_FRAMEWORK |
31 | #include <rdf_uri.h> |
32 | #else |
33 | #include <Redland/rdf_uri.h> |
34 | #endif |
35 | |
36 | #ifdef LIBRDF_INTERNAL |
37 | #include <rdf_model_internal.h> |
38 | #endif |
39 | |
40 | #ifdef __cplusplus |
41 | extern "C" { |
42 | #endif |
43 | |
44 | /* class methods */ |
45 | |
46 | REDLAND_API |
47 | int librdf_model_enumerate(librdf_world* world, const unsigned int counter, const char **name, const char **label); |
48 | |
49 | /* constructors */ |
50 | |
51 | /* Create a new Model */ |
52 | REDLAND_API |
53 | librdf_model* librdf_new_model(librdf_world *world, librdf_storage *storage, const char* options_string); |
54 | REDLAND_API |
55 | librdf_model* librdf_new_model_with_options(librdf_world *world, librdf_storage *storage, librdf_hash* options); |
56 | |
57 | /* Create a new Model from an existing Model - CLONE */ |
58 | REDLAND_API |
59 | librdf_model* librdf_new_model_from_model(librdf_model* model); |
60 | |
61 | /* destructor */ |
62 | REDLAND_API |
63 | void librdf_free_model(librdf_model *model); |
64 | |
65 | |
66 | /* functions / methods */ |
67 | REDLAND_API |
68 | int librdf_model_size(librdf_model* model); |
69 | |
70 | /* add statements */ |
71 | REDLAND_API |
72 | int librdf_model_add(librdf_model* model, librdf_node* subject, librdf_node* predicate, librdf_node* object); |
73 | REDLAND_API |
74 | int librdf_model_add_string_literal_statement(librdf_model* model, librdf_node* subject, librdf_node* predicate, const unsigned char* literal, const char *xml_language, int is_wf_xml); |
75 | REDLAND_API |
76 | int librdf_model_add_typed_literal_statement(librdf_model* model, librdf_node* subject, librdf_node* predicate, const unsigned char* literal, const char *xml_language, librdf_uri *datatype_uri); |
77 | REDLAND_API |
78 | int librdf_model_add_statement(librdf_model* model, librdf_statement* statement); |
79 | REDLAND_API |
80 | int librdf_model_add_statements(librdf_model* model, librdf_stream* statement_stream); |
81 | |
82 | /* remove statements */ |
83 | REDLAND_API |
84 | int librdf_model_remove_statement(librdf_model* model, librdf_statement* statement); |
85 | |
86 | /* containment */ |
87 | /* check for exact statement match */ |
88 | REDLAND_API |
89 | int librdf_model_contains_statement(librdf_model* model, librdf_statement* statement); |
90 | /* check for [node, property, ?] */ |
91 | REDLAND_API |
92 | int librdf_model_has_arc_in(librdf_model *model, librdf_node *node, librdf_node *property); |
93 | /* check for [?, property, node] */ |
94 | REDLAND_API |
95 | int librdf_model_has_arc_out(librdf_model *model, librdf_node *node, librdf_node *property); |
96 | |
97 | |
98 | /* list the entire model as a stream of statements */ |
99 | REDLAND_API |
100 | librdf_stream* librdf_model_as_stream(librdf_model* model); |
101 | /* DEPRECATED serialise the entire model */ |
102 | REDLAND_API REDLAND_DEPRECATED |
103 | librdf_stream* librdf_model_serialise(librdf_model* model); |
104 | |
105 | /* queries */ |
106 | |
107 | REDLAND_API |
108 | librdf_stream* librdf_model_find_statements(librdf_model* model, librdf_statement* statement); |
109 | |
110 | /** |
111 | * LIBRDF_MODEL_FIND_OPTION_MATCH_SUBSTRING_LITERAL: |
112 | * |
113 | * Model find statement option. |
114 | * |
115 | * If set, the find statement uses substring matching. |
116 | */ |
117 | #define LIBRDF_MODEL_FIND_OPTION_MATCH_SUBSTRING_LITERAL "http://feature.librdf.org/model-find-match-substring-literal" |
118 | |
119 | REDLAND_API |
120 | librdf_stream* librdf_model_find_statements_with_options(librdf_model* model, librdf_statement* statement, librdf_node* context_node, librdf_hash* options); |
121 | REDLAND_API |
122 | librdf_iterator* librdf_model_get_sources(librdf_model *model, librdf_node *arc, librdf_node *target); |
123 | REDLAND_API |
124 | librdf_iterator* librdf_model_get_arcs(librdf_model *model, librdf_node *source, librdf_node *target); |
125 | REDLAND_API |
126 | librdf_iterator* librdf_model_get_targets(librdf_model *model, librdf_node *source, librdf_node *arc); |
127 | REDLAND_API |
128 | librdf_node* librdf_model_get_source(librdf_model *model, librdf_node *arc, librdf_node *target); |
129 | REDLAND_API |
130 | librdf_node* librdf_model_get_arc(librdf_model *model, librdf_node *source, librdf_node *target); |
131 | REDLAND_API |
132 | librdf_node* librdf_model_get_target(librdf_model *model, librdf_node *source, librdf_node *arc); |
133 | |
134 | /* return list of properties to/from a node */ |
135 | REDLAND_API |
136 | librdf_iterator* librdf_model_get_arcs_in(librdf_model *model, librdf_node *node); |
137 | REDLAND_API |
138 | librdf_iterator* librdf_model_get_arcs_out(librdf_model *model, librdf_node *node); |
139 | |
140 | |
141 | |
142 | /* submodels */ |
143 | REDLAND_API |
144 | int librdf_model_add_submodel(librdf_model* model, librdf_model* sub_model); |
145 | REDLAND_API |
146 | int librdf_model_remove_submodel(librdf_model* model, librdf_model* sub_model); |
147 | |
148 | |
149 | REDLAND_API REDLAND_DEPRECATED |
150 | void librdf_model_print(librdf_model *model, FILE *fh); |
151 | REDLAND_API |
152 | int librdf_model_write(librdf_model *model, raptor_iostream* iostr); |
153 | |
154 | /* statement contexts */ |
155 | REDLAND_API |
156 | int librdf_model_context_add_statement(librdf_model* model, librdf_node* context, librdf_statement* statement); |
157 | REDLAND_API |
158 | int librdf_model_context_add_statements(librdf_model* model, librdf_node* context, librdf_stream* stream); |
159 | REDLAND_API |
160 | int librdf_model_context_remove_statement(librdf_model* model, librdf_node* context, librdf_statement* statement); |
161 | REDLAND_API |
162 | int librdf_model_context_remove_statements(librdf_model* model, librdf_node* context); |
163 | REDLAND_API |
164 | librdf_stream* librdf_model_context_as_stream(librdf_model* model, librdf_node* context); |
165 | REDLAND_API REDLAND_DEPRECATED |
166 | librdf_stream* librdf_model_context_serialize(librdf_model* model, librdf_node* context); |
167 | REDLAND_API |
168 | int librdf_model_contains_context(librdf_model* model, librdf_node* context); |
169 | REDLAND_API |
170 | int librdf_model_supports_contexts(librdf_model* model); |
171 | |
172 | /* query language */ |
173 | REDLAND_API |
174 | librdf_query_results* librdf_model_query_execute(librdf_model* model, librdf_query* query); |
175 | |
176 | REDLAND_API |
177 | int librdf_model_sync(librdf_model* model); |
178 | |
179 | REDLAND_API |
180 | librdf_storage* librdf_model_get_storage(librdf_model *model); |
181 | |
182 | REDLAND_API |
183 | int librdf_model_load(librdf_model* model, librdf_uri *uri, const char *name, const char *mime_type, librdf_uri *type_uri); |
184 | REDLAND_API |
185 | unsigned char* librdf_model_to_counted_string(librdf_model* model, librdf_uri *uri, const char *name, const char *mime_type, librdf_uri *type_uri, size_t* string_length_p); |
186 | REDLAND_API |
187 | unsigned char* librdf_model_to_string(librdf_model* model, librdf_uri *uri, const char *name, const char *mime_type, librdf_uri *type_uri); |
188 | |
189 | /* find statements in a given context */ |
190 | REDLAND_API |
191 | librdf_stream* librdf_model_find_statements_in_context(librdf_model* model, librdf_statement* statement, librdf_node* context_node); |
192 | |
193 | REDLAND_API |
194 | librdf_iterator* librdf_model_get_contexts(librdf_model* model); |
195 | |
196 | REDLAND_API |
197 | int librdf_model_transaction_start(librdf_model* model); |
198 | REDLAND_API |
199 | int librdf_model_transaction_start_with_handle(librdf_model* model, void* handle); |
200 | REDLAND_API |
201 | int librdf_model_transaction_commit(librdf_model* model); |
202 | REDLAND_API |
203 | int librdf_model_transaction_rollback(librdf_model* model); |
204 | REDLAND_API |
205 | void* librdf_model_transaction_get_handle(librdf_model* model); |
206 | |
207 | |
208 | /** |
209 | * LIBRDF_MODEL_FEATURE_CONTEXTS: |
210 | * |
211 | * Model feature contexts. |
212 | * |
213 | * If set, the model has redland contexts. |
214 | */ |
215 | #define LIBRDF_MODEL_FEATURE_CONTEXTS "http://feature.librdf.org/model-contexts" |
216 | |
217 | /* features */ |
218 | REDLAND_API |
219 | librdf_node* librdf_model_get_feature(librdf_model* model, librdf_uri* feature); |
220 | REDLAND_API |
221 | int librdf_model_set_feature(librdf_model* model, librdf_uri* feature, librdf_node* value); |
222 | |
223 | #ifdef __cplusplus |
224 | } |
225 | #endif |
226 | |
227 | #endif |
228 | |