1/* -*- Mode: c; c-basic-offset: 2 -*-
2 *
3 * rdf_query.h - RDF Query Adaptor Factory and Query interfaces and definitions
4 *
5 * Copyright (C) 2002-2008, David Beckett http://www.dajobe.org/
6 * Copyright (C) 2002-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#ifndef LIBRDF_QUERY_H
27#define LIBRDF_QUERY_H
28
29#ifdef LIBRDF_INTERNAL
30#include <rdf_query_internal.h>
31#endif
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/* class methods */
38REDLAND_API
39void librdf_query_register_factory(librdf_world *world, const char *name, const unsigned char *uri_string, void (*factory) (librdf_query_factory*));
40REDLAND_API REDLAND_DEPRECATED
41int librdf_query_languages_enumerate(librdf_world* world, const unsigned int counter, const char **name, const unsigned char **uri_string);
42REDLAND_API
43const raptor_syntax_description* librdf_query_language_get_description(librdf_world* world, unsigned int counter);
44
45/* constructor */
46REDLAND_API
47librdf_query* librdf_new_query(librdf_world* world, const char *name, librdf_uri* uri, const unsigned char *query_string, librdf_uri* base_uri);
48REDLAND_API
49librdf_query* librdf_new_query_from_query (librdf_query* old_query);
50REDLAND_API
51librdf_query* librdf_new_query_from_factory(librdf_world* world, librdf_query_factory* factory, const char *name, librdf_uri* uri, const unsigned char* query_string, librdf_uri* base_uri);
52
53/* destructor */
54REDLAND_API
55void librdf_free_query(librdf_query *query);
56
57
58/* methods */
59REDLAND_API
60librdf_query_results* librdf_query_execute(librdf_query* query, librdf_model *model);
61REDLAND_API
62int librdf_query_get_limit(librdf_query *query);
63REDLAND_API
64int librdf_query_set_limit(librdf_query *query, int limit);
65REDLAND_API
66int librdf_query_get_offset(librdf_query *query);
67REDLAND_API
68int librdf_query_set_offset(librdf_query *query, int offset);
69
70REDLAND_API
71librdf_stream* librdf_query_results_as_stream(librdf_query_results* query_results);
72
73REDLAND_API
74int librdf_query_results_get_count(librdf_query_results* query_results);
75REDLAND_API
76int librdf_query_results_next(librdf_query_results* query_results);
77REDLAND_API
78int librdf_query_results_finished(librdf_query_results* query_results);
79
80REDLAND_API
81int librdf_query_results_get_bindings(librdf_query_results* query_results, const char ***names, librdf_node **values);
82REDLAND_API
83librdf_node* librdf_query_results_get_binding_value(librdf_query_results* query_results, int offset);
84REDLAND_API
85const char* librdf_query_results_get_binding_name(librdf_query_results* query_results, int offset);
86REDLAND_API
87librdf_node* librdf_query_results_get_binding_value_by_name(librdf_query_results* query_results, const char *name);
88REDLAND_API
89int librdf_query_results_get_bindings_count(librdf_query_results* query_results);
90REDLAND_API REDLAND_DEPRECATED
91unsigned char* librdf_query_results_to_counted_string(librdf_query_results *query_results, librdf_uri *format_uri, librdf_uri *base_uri, size_t *length_p);
92REDLAND_API
93unsigned char* librdf_query_results_to_counted_string2(librdf_query_results *query_results, const char *name, const char *mime_type, librdf_uri *format_uri, librdf_uri *base_uri, size_t *length_p);
94REDLAND_API REDLAND_DEPRECATED
95unsigned char* librdf_query_results_to_string(librdf_query_results *query_results, librdf_uri *format_uri, librdf_uri *base_uri);
96REDLAND_API
97unsigned char* librdf_query_results_to_string2(librdf_query_results *query_results, const char *name, const char *mime_type, librdf_uri *format_uri, librdf_uri *base_uri);
98REDLAND_API REDLAND_DEPRECATED
99int librdf_query_results_to_file_handle(librdf_query_results *query_results, FILE *handle, librdf_uri *format_uri, librdf_uri *base_uri);
100REDLAND_API
101int librdf_query_results_to_file_handle2(librdf_query_results *query_results, FILE *handle, const char *name, const char *mime_type, librdf_uri *format_uri, librdf_uri *base_uri);
102REDLAND_API REDLAND_DEPRECATED
103int librdf_query_results_to_file(librdf_query_results *query_results, const char *name, librdf_uri *format_uri, librdf_uri *base_uri);
104REDLAND_API
105int librdf_query_results_to_file2(librdf_query_results *query_results, const char *name, const char *mime_type, librdf_uri *format_uri, librdf_uri *base_uri);
106
107REDLAND_API
108void librdf_free_query_results(librdf_query_results* query_results);
109
110REDLAND_API
111int librdf_query_results_is_bindings(librdf_query_results *query_results);
112REDLAND_API
113int librdf_query_results_is_boolean(librdf_query_results *query_results);
114REDLAND_API
115int librdf_query_results_is_graph(librdf_query_results *query_results);
116REDLAND_API
117int librdf_query_results_is_syntax(librdf_query_results* query_results);
118
119REDLAND_API
120int librdf_query_results_get_boolean(librdf_query_results *query_results);
121
122/* query results formatter class */
123REDLAND_API
124librdf_query_results_formatter* librdf_new_query_results_formatter2(librdf_query_results* query_results, const char *name, const char* mime_type, librdf_uri* uri);
125REDLAND_API REDLAND_DEPRECATED
126librdf_query_results_formatter* librdf_new_query_results_formatter(librdf_query_results* query_results, const char *name, librdf_uri* uri);
127REDLAND_API REDLAND_DEPRECATED
128librdf_query_results_formatter* librdf_new_query_results_formatter_by_mime_type(librdf_query_results* query_results, const char *mime_type);
129REDLAND_API
130void librdf_free_query_results_formatter(librdf_query_results_formatter* formatter);
131REDLAND_API
132int librdf_query_results_formatter_write(raptor_iostream *iostr, librdf_query_results_formatter* formatter, librdf_query_results* query_results, librdf_uri *base_uri);
133
134REDLAND_API
135int librdf_query_results_formats_check(librdf_world* world, const char *name, librdf_uri* uri, const char *mime_type);
136REDLAND_API REDLAND_DEPRECATED
137int librdf_query_results_formats_enumerate(librdf_world* world, const unsigned int counter, const char **name, const char **label, const unsigned char **uri_string, const char **mime_type);
138REDLAND_API
139const raptor_syntax_description* librdf_query_results_formats_get_description(librdf_world* world, unsigned int counter);
140
141#ifdef __cplusplus
142}
143#endif
144
145#endif
146