1 /*
2  * Copyright (C) 2010, Nokia <ivan.frade@nokia.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19 #ifndef __TRACKER_SPARQL_CURSOR_H__
20 #define __TRACKER_SPARQL_CURSOR_H__
21 
22 #if !defined (__LIBTRACKER_SPARQL_INSIDE__) && !defined (TRACKER_COMPILATION)
23 #error "only <libtracker-sparql/tracker-sparql.h> must be included directly."
24 #endif
25 
26 #include <gio/gio.h>
27 #include <libtracker-sparql/tracker-version.h>
28 
29 G_BEGIN_DECLS
30 
31 /**
32  * TrackerSparqlCursor:
33  *
34  * The <structname>TrackerSparqlCursor</structname> object represents an
35  * iterator of results.
36  */
37 #define TRACKER_TYPE_SPARQL_CURSOR tracker_sparql_cursor_get_type ()
38 #define TRACKER_SPARQL_TYPE_CURSOR TRACKER_TYPE_SPARQL_CURSOR
39 TRACKER_AVAILABLE_IN_ALL
40 G_DECLARE_DERIVABLE_TYPE (TrackerSparqlCursor, tracker_sparql_cursor,
41                           TRACKER, SPARQL_CURSOR, GObject)
42 
43 #include "tracker-connection.h"
44 
45 /**
46  * TrackerSparqlValueType:
47  * @TRACKER_SPARQL_VALUE_TYPE_UNBOUND: Unbound value type
48  * @TRACKER_SPARQL_VALUE_TYPE_URI: Uri value type, rdfs:Resource
49  * @TRACKER_SPARQL_VALUE_TYPE_STRING: String value type, xsd:string
50  * @TRACKER_SPARQL_VALUE_TYPE_INTEGER: Integer value type, xsd:integer
51  * @TRACKER_SPARQL_VALUE_TYPE_DOUBLE: Double value type, xsd:double
52  * @TRACKER_SPARQL_VALUE_TYPE_DATETIME: Datetime value type, xsd:dateTime
53  * @TRACKER_SPARQL_VALUE_TYPE_BLANK_NODE: Blank node value type
54  * @TRACKER_SPARQL_VALUE_TYPE_BOOLEAN: Boolean value type, xsd:boolean
55  *
56  * Enumeration with the possible types of the cursor's cells
57  */
58 typedef enum {
59 	TRACKER_SPARQL_VALUE_TYPE_UNBOUND,
60 	TRACKER_SPARQL_VALUE_TYPE_URI,
61 	TRACKER_SPARQL_VALUE_TYPE_STRING,
62 	TRACKER_SPARQL_VALUE_TYPE_INTEGER,
63 	TRACKER_SPARQL_VALUE_TYPE_DOUBLE,
64 	TRACKER_SPARQL_VALUE_TYPE_DATETIME,
65 	TRACKER_SPARQL_VALUE_TYPE_BLANK_NODE,
66 	TRACKER_SPARQL_VALUE_TYPE_BOOLEAN,
67 } TrackerSparqlValueType;
68 
69 TRACKER_AVAILABLE_IN_ALL
70 TrackerSparqlConnection * tracker_sparql_cursor_get_connection (TrackerSparqlCursor *cursor);
71 TRACKER_AVAILABLE_IN_ALL
72 gint tracker_sparql_cursor_get_n_columns (TrackerSparqlCursor *cursor);
73 
74 TRACKER_AVAILABLE_IN_ALL
75 const gchar * tracker_sparql_cursor_get_string (TrackerSparqlCursor *cursor,
76                                                 gint                 column,
77                                                 glong               *length);
78 TRACKER_AVAILABLE_IN_ALL
79 gboolean tracker_sparql_cursor_get_boolean (TrackerSparqlCursor *cursor,
80                                             gint                 column);
81 TRACKER_AVAILABLE_IN_ALL
82 gdouble tracker_sparql_cursor_get_double (TrackerSparqlCursor *cursor,
83                                           gint                 column);
84 TRACKER_AVAILABLE_IN_ALL
85 gint64 tracker_sparql_cursor_get_integer (TrackerSparqlCursor *cursor,
86                                           gint                 column);
87 TRACKER_AVAILABLE_IN_ALL
88 TrackerSparqlValueType tracker_sparql_cursor_get_value_type (TrackerSparqlCursor *cursor,
89                                                              gint                 column);
90 TRACKER_AVAILABLE_IN_ALL
91 const gchar * tracker_sparql_cursor_get_variable_name (TrackerSparqlCursor *cursor,
92                                                        gint                 column);
93 TRACKER_AVAILABLE_IN_ALL
94 void tracker_sparql_cursor_close (TrackerSparqlCursor *cursor);
95 
96 TRACKER_AVAILABLE_IN_ALL
97 gboolean tracker_sparql_cursor_is_bound (TrackerSparqlCursor *cursor,
98                                          gint                 column);
99 
100 TRACKER_AVAILABLE_IN_ALL
101 gboolean tracker_sparql_cursor_next (TrackerSparqlCursor  *cursor,
102                                      GCancellable         *cancellable,
103                                      GError              **error);
104 
105 TRACKER_AVAILABLE_IN_ALL
106 void tracker_sparql_cursor_next_async (TrackerSparqlCursor  *cursor,
107                                        GCancellable         *cancellable,
108                                        GAsyncReadyCallback   callback,
109                                        gpointer              user_data);
110 
111 TRACKER_AVAILABLE_IN_ALL
112 gboolean tracker_sparql_cursor_next_finish (TrackerSparqlCursor  *cursor,
113                                             GAsyncResult         *res,
114                                             GError              **error);
115 
116 TRACKER_AVAILABLE_IN_ALL
117 void tracker_sparql_cursor_rewind (TrackerSparqlCursor *cursor);
118 
119 G_END_DECLS
120 
121 #endif /* __TRACKER_SPARQL_CURSOR_H__ */
122