1 | /* -*- Mode: c; c-basic-offset: 2 -*- |
2 | * |
3 | * rdf_statement.h - RDF Statement definition |
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 | |
27 | #ifndef LIBRDF_STATEMENT_H |
28 | #define LIBRDF_STATEMENT_H |
29 | |
30 | #ifdef LIBRDF_INTERNAL |
31 | #include <rdf_statement_internal.h> |
32 | #endif |
33 | |
34 | #ifdef __cplusplus |
35 | extern "C" { |
36 | #endif |
37 | |
38 | /** |
39 | * librdf_statement_part: |
40 | * @LIBRDF_STATEMENT_SUBJECT: Subject of a statement. |
41 | * @LIBRDF_STATEMENT_PREDICATE: Predicate of a statement. |
42 | * @LIBRDF_STATEMENT_OBJECT: Object of a statement. |
43 | * @LIBRDF_STATEMENT_ALL: All parts of a statement. |
44 | * |
45 | * Flags that are or-ed to indicate statement parts. |
46 | * |
47 | * Used in fields arguments to methods such as the public |
48 | * librdf_statement_encode_parts() librdf_statement_decode_parts() |
49 | * librdf_new_stream_from_node_iterator(). |
50 | */ |
51 | typedef enum { |
52 | LIBRDF_STATEMENT_SUBJECT = 1 << 0, |
53 | LIBRDF_STATEMENT_PREDICATE = 1 << 1, |
54 | LIBRDF_STATEMENT_OBJECT = 1 << 2, |
55 | |
56 | /* must be a combination of all of the above */ |
57 | LIBRDF_STATEMENT_ALL = (LIBRDF_STATEMENT_SUBJECT| |
58 | LIBRDF_STATEMENT_PREDICATE| |
59 | LIBRDF_STATEMENT_OBJECT) |
60 | } librdf_statement_part; |
61 | |
62 | |
63 | /* initialising functions / constructors */ |
64 | |
65 | /* Create a new Statement. */ |
66 | REDLAND_API |
67 | librdf_statement* librdf_new_statement(librdf_world* world); |
68 | |
69 | /* Create a new Statement from an existing Statement - DEEP CLONE */ |
70 | REDLAND_API |
71 | librdf_statement* librdf_new_statement_from_statement(librdf_statement* statement); |
72 | /* Create a new Statement from an existing Statement - SHALLOW CLONE */ |
73 | REDLAND_API |
74 | librdf_statement* librdf_new_statement_from_statement2(librdf_statement* statement); |
75 | /* Create a new Statement from existing Nodes */ |
76 | REDLAND_API |
77 | librdf_statement* librdf_new_statement_from_nodes(librdf_world *world, librdf_node* subject, librdf_node* predicate, librdf_node* object); |
78 | |
79 | /* Init a statically allocated statement */ |
80 | REDLAND_API |
81 | void librdf_statement_init(librdf_world *world, librdf_statement *statement); |
82 | |
83 | /* Clear a statically allocated statement */ |
84 | REDLAND_API |
85 | void librdf_statement_clear(librdf_statement *statement); |
86 | |
87 | /* destructor */ |
88 | REDLAND_API |
89 | void librdf_free_statement(librdf_statement* statement); |
90 | |
91 | |
92 | /* functions / methods */ |
93 | |
94 | REDLAND_API |
95 | librdf_node* librdf_statement_get_subject(librdf_statement *statement); |
96 | REDLAND_API |
97 | void librdf_statement_set_subject(librdf_statement *statement, librdf_node *node); |
98 | |
99 | REDLAND_API |
100 | librdf_node* librdf_statement_get_predicate(librdf_statement *statement); |
101 | REDLAND_API |
102 | void librdf_statement_set_predicate(librdf_statement *statement, librdf_node *node); |
103 | |
104 | REDLAND_API |
105 | librdf_node* librdf_statement_get_object(librdf_statement *statement); |
106 | REDLAND_API |
107 | void librdf_statement_set_object(librdf_statement *statement, librdf_node *node); |
108 | |
109 | /* if statement has all fields */ |
110 | REDLAND_API |
111 | int librdf_statement_is_complete(librdf_statement *statement); |
112 | |
113 | /* convert to a string */ |
114 | REDLAND_API REDLAND_DEPRECATED |
115 | unsigned char *librdf_statement_to_string(librdf_statement *statement); |
116 | /* print it prettily */ |
117 | REDLAND_API |
118 | int librdf_statement_write(librdf_statement *statement, raptor_iostream *iostr); |
119 | REDLAND_API |
120 | void librdf_statement_print(librdf_statement *statement, FILE *fh); |
121 | |
122 | /* compare two statements */ |
123 | REDLAND_API |
124 | int librdf_statement_equals(librdf_statement* statement1, librdf_statement* statement2); |
125 | /* match statement against one with partial content */ |
126 | REDLAND_API |
127 | int librdf_statement_match(librdf_statement* statement, librdf_statement* partial_statement); |
128 | |
129 | /* serialising/deserialising */ |
130 | REDLAND_API REDLAND_DEPRECATED |
131 | size_t librdf_statement_encode(librdf_statement* statement, unsigned char *buffer, size_t length); |
132 | REDLAND_API |
133 | size_t librdf_statement_encode2(librdf_world* world, librdf_statement* statement, unsigned char *buffer, size_t length); |
134 | REDLAND_API REDLAND_DEPRECATED |
135 | size_t librdf_statement_encode_parts(librdf_statement* statement, librdf_node* context_node, unsigned char *buffer, size_t length, librdf_statement_part fields); |
136 | REDLAND_API |
137 | size_t librdf_statement_encode_parts2(librdf_world* world, librdf_statement* statement, librdf_node* context_node, unsigned char *buffer, size_t length, librdf_statement_part fields); |
138 | REDLAND_API REDLAND_DEPRECATED |
139 | size_t librdf_statement_decode(librdf_statement* statement, unsigned char *buffer, size_t length); |
140 | REDLAND_API |
141 | size_t librdf_statement_decode2(librdf_world* world, librdf_statement* statement, librdf_node** context_node, unsigned char *buffer, size_t length); |
142 | REDLAND_API REDLAND_DEPRECATED |
143 | size_t librdf_statement_decode_parts(librdf_statement* statement, librdf_node** context_node, unsigned char *buffer, size_t length); |
144 | |
145 | |
146 | #ifdef __cplusplus |
147 | } |
148 | #endif |
149 | |
150 | #endif |
151 | |