1 /* -*- Mode: c; c-basic-offset: 2 -*-
2  *
3  * rasqal.h - Rasqal RDF Query library interfaces and definition
4  *
5  * Copyright (C) 2003-2010, David Beckett http://www.dajobe.org/
6  * Copyright (C) 2003-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 RASQAL_H
27 #define RASQAL_H
28 
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 /**
36  * RASQAL_VERSION:
37  *
38  * Rasqal library version number
39  *
40  * Format: major * 10000 + minor * 100 + release
41  */
42 #define RASQAL_VERSION 933
43 
44 /**
45  * RASQAL_VERSION_STRING:
46  *
47  * Rasqal library version string
48  */
49 #define RASQAL_VERSION_STRING "0.9.33"
50 
51 /**
52  * RASQAL_VERSION_MAJOR:
53  *
54  * Rasqal library major version
55  */
56 #define RASQAL_VERSION_MAJOR 0
57 
58 /**
59  * RASQAL_VERSION_MINOR:
60  *
61  * Rasqal library minor version
62  */
63 #define RASQAL_VERSION_MINOR 9
64 
65 /**
66  * RASQAL_VERSION_RELEASE:
67  *
68  * Rasqal library release
69  */
70 #define RASQAL_VERSION_RELEASE 33
71 
72 
73 /**
74  * RASQAL_API:
75  *
76  * Macro for wrapping API function call declarations.
77  *
78  */
79 #ifndef RASQAL_API
80 #  ifdef _WIN32
81 #    ifdef __GNUC__
82 #      undef _declspec
83 #      define _declspec(x) __declspec(x)
84 #    endif
85 #    ifdef RASQAL_STATIC
86 #      define RASQAL_API
87 #    else
88 #      ifdef RASQAL_INTERNAL
89 #        define RASQAL_API _declspec(dllexport)
90 #      else
91 #        define RASQAL_API _declspec(dllimport)
92 #      endif
93 #    endif
94 #  else
95 #    define RASQAL_API
96 #  endif
97 #endif
98 
99 /* Use gcc 3.1+ feature to allow marking of deprecated API calls.
100  * This gives a warning during compiling.
101  */
102 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
103 #define RASQAL_DEPRECATED __attribute__((deprecated))
104 #else
105 #define RASQAL_DEPRECATED
106 #endif
107 
108 
109 #ifndef LIBRDF_OBJC_FRAMEWORK
110 #include <raptor.h>
111 #else
112 #include <Redland/raptor.h>
113 #endif
114 
115 #if 0
116 #include <sys/time.h>
117 #endif
118 #if 1
119 #include <time.h>
120 #endif
121 
122 /* Public statics */
123 
124 /**
125  * rasqal_short_copyright_string:
126  *
127  * Short copyright string (one line).
128  */
129 RASQAL_API
130 extern const char * const rasqal_short_copyright_string;
131 
132 /**
133  * rasqal_copyright_string:
134  *
135  * Copyright string (multiple lines).
136  */
137 RASQAL_API
138 extern const char * const rasqal_copyright_string;
139 
140 /**
141  * rasqal_version_string:
142  *
143  * Rasqal version as a string.
144  */
145 RASQAL_API
146 extern const char * const rasqal_version_string;
147 
148 /**
149  * rasqal_version_major:
150  *
151  * Rasqal major version number.
152  */
153 RASQAL_API
154 extern const unsigned int rasqal_version_major;
155 
156 /**
157  * rasqal_version_minor:
158  *
159  * Rasqal minor version number.
160  */
161 RASQAL_API
162 extern const unsigned int rasqal_version_minor;
163 
164 /**
165  * rasqal_version_release:
166  *
167  * Rasqal release version number.
168  */
169 RASQAL_API
170 extern const unsigned int rasqal_version_release;
171 
172 /**
173  * rasqal_version_decimal:
174  *
175  * Rasqal version as a decimal number.
176  *
177  * Format: major * 10000 + minor * 100 + release
178  */
179 RASQAL_API
180 extern const unsigned int rasqal_version_decimal;
181 
182 /**
183  * rasqal_license_string:
184  *
185  * Rasqal license string.
186  */
187 RASQAL_API
188 extern const char * const rasqal_license_string;
189 
190 /**
191  * rasqal_home_url_string:
192  *
193  * Rasqal home page URL.
194  */
195 RASQAL_API
196 extern const char * const rasqal_home_url_string;
197 
198 
199 
200 /**
201  * RASQAL_RAPTOR_VERSION:
202  *
203  * Version of Raptor that Rasqal was configured against.
204  */
205 #define RASQAL_RAPTOR_VERSION 20015
206 
207 
208 /* Public structures */
209 
210 #ifndef RASQAL_WORLD_DECLARED
211 #define RASQAL_WORLD_DECLARED 1
212 /**
213  * rasqal_world:
214  *
215  * Rasqal world class.
216  */
217 typedef struct rasqal_world_s rasqal_world;
218 #endif
219 
220 /**
221  * rasqal_query:
222  *
223  * Rasqal query class.
224  */
225 typedef struct rasqal_query_s rasqal_query;
226 
227 /**
228  * rasqal_query_results:
229  *
230  * Rasqal query results class.
231  */
232 typedef struct rasqal_query_results_s rasqal_query_results;
233 
234 
235 #ifndef RASQAL_QUERY_RESULTS_FORMATTER_DECLARED
236 #define RASQAL_QUERY_RESULTS_FORMATTER_DECLARED 1
237 /**
238  * rasqal_query_results_formatter:
239  *
240  * Rasqal query results formatter class.
241  */
242 typedef struct rasqal_query_results_formatter_s rasqal_query_results_formatter;
243 #endif
244 
245 
246 typedef struct rasqal_literal_s rasqal_literal;
247 
248 /**
249  * rasqal_graph_pattern:
250  *
251  * Rasqal graph pattern class.
252  */
253 typedef struct rasqal_graph_pattern_s rasqal_graph_pattern;
254 
255 
256 /**
257  * rasqal_variables_table:
258  *
259  * Rasqal variables table class.
260  */
261 typedef struct rasqal_variables_table_s rasqal_variables_table;
262 
263 
264 /**
265  * rasqal_feature:
266  * @RASQAL_FEATURE_NO_NET: Deny network requests.
267  * @RASQAL_FEATURE_RAND_SEED: Set rand() / rand_r() seed
268  * @RASQAL_FEATURE_LAST: Internal.
269  *
270  * Query features.
271  *
272  * None currently defined.
273  */
274 typedef enum {
275   RASQAL_FEATURE_NO_NET,
276   RASQAL_FEATURE_RAND_SEED,
277   RASQAL_FEATURE_LAST = RASQAL_FEATURE_RAND_SEED
278 } rasqal_feature;
279 
280 
281 /**
282  * rasqal_prefix:
283  * @world: rasqal_world object
284  * @prefix: short prefix string
285  * @uri: URI associated with the prefix.
286  * @declared: Internal flag.
287  * @depth: Internal flag.
288  *
289  * Namespace (prefix, uri) pair.
290  *
291  * Includes internal flags used for marking when prefixes are
292  * declared and at what XML element depth when used in XML formats.
293  */
294 typedef struct {
295   rasqal_world* world;
296   const unsigned char *prefix;
297   raptor_uri* uri;
298   int declared;
299   int depth;
300 } rasqal_prefix;
301 
302 
303 /**
304  * rasqal_variable_type:
305  * @RASQAL_VARIABLE_TYPE_NORMAL: The regular variable type.
306  * @RASQAL_VARIABLE_TYPE_ANONYMOUS: Anonymous variable type.
307  * @RASQAL_VARIABLE_TYPE_UNKNOWN: Internal.
308  *
309  * Rasqal variable types.
310  *
311  * ANONYMOUS can be used in queries but cannot be returned in a
312  * result.
313  */
314 typedef enum {
315   RASQAL_VARIABLE_TYPE_UNKNOWN   = 0,
316   RASQAL_VARIABLE_TYPE_NORMAL    = 1,
317   RASQAL_VARIABLE_TYPE_ANONYMOUS = 2
318 } rasqal_variable_type;
319 
320 
321 /* forward reference */
322 struct rasqal_expression_s;
323 
324 /**
325  * rasqal_variable:
326  * @vars_table: variables table that owns this variable
327  * @name: Variable name.
328  * @value: Variable value or NULL if unbound.
329  * @offset: Internal.
330  * @type: Variable type.
331  * @expression: Expression when the variable is a computed SELECT expression
332  * @user_data: Pointer to user data associated with a variable.  This is not used by rasqal.
333  * @usage: reference count
334  *
335  * Binding between a variable name and a value.
336  *
337  * Includes internal field @offset for recording the offset into the
338  * (internal) rasqal_query variables array.
339  */
340 typedef struct {
341   rasqal_variables_table* vars_table;
342   const unsigned char *name;
343   rasqal_literal* value;
344   int offset;
345   rasqal_variable_type type;
346   struct rasqal_expression_s* expression;
347   void *user_data;
348   int usage;
349 } rasqal_variable;
350 
351 
352 /**
353  * rasqal_data_graph_flags:
354  * @RASQAL_DATA_GRAPH_NONE: Internal.
355  * @RASQAL_DATA_GRAPH_NAMED: Graphs with a source and name.
356  * @RASQAL_DATA_GRAPH_BACKGROUND: Graphs with a source only.
357  *
358  * Flags for the type of #rasqal_data_graph.
359  *
360  * These are used by rasqal_new_data_graph_from_uri() and
361  * rasqal_new_data_graph_from_iostream().  See #rasqal_data_graph.
362  */
363 typedef enum {
364   RASQAL_DATA_GRAPH_NONE  = 0,
365   RASQAL_DATA_GRAPH_NAMED = 1,
366   RASQAL_DATA_GRAPH_BACKGROUND = 2
367 } rasqal_data_graph_flags;
368 
369 
370 /**
371  * rasqal_data_graph:
372  * @world: rasqal_world object
373  * @uri: source URI
374  * @name_uri: name of graph for %RASQAL_DATA_GRAPH_NAMED
375  * @flags: %RASQAL_DATA_GRAPH_NAMED or %RASQAL_DATA_GRAPH_BACKGROUND
376  * @format_type: MIME Type of data format at @uri (or NULL)
377  * @format_name: Raptor parser Name of data format at @uri (or NULL)
378  * @format_uri: URI of data format at @uri (or NULL)
379  * @iostr: Raptor iostream for content, overriding @uri if present (or NULL)
380  * @base_uri: base URI for reading from iostream
381  * @usage: usage count of this object
382  *
383  * A source of RDF data for querying.
384  *
385  * If @iostr is present, the graph can be constructed by parsing the
386  * iostream and using @base_uri as a base uri. Otherwise the graph
387  * can be constructed from the graph at URI @uri.
388  *
389  * In either case the @name_uri is the graph name as long as @flags
390  * is %RASQAL_DATA_GRAPH_NAMED
391  */
392 typedef struct {
393   rasqal_world* world;
394   raptor_uri* uri;
395   raptor_uri* name_uri;
396   unsigned int flags;
397   char* format_type;
398   char* format_name;
399   raptor_uri* format_uri;
400   raptor_iostream* iostr;
401   raptor_uri* base_uri;
402   int usage;
403 } rasqal_data_graph;
404 
405 
406 /**
407  * rasqal_literal_type:
408  * @RASQAL_LITERAL_BLANK: RDF blank node literal (SPARQL r:bNode)
409  * @RASQAL_LITERAL_URI: RDF URI Literal (SPARQL r:URI)
410  * @RASQAL_LITERAL_STRING: RDF Plain Literal - no datatype (SPARQL r:Literal)
411  * @RASQAL_LITERAL_XSD_STRING: String xsd:string
412  * @RASQAL_LITERAL_BOOLEAN: Boolean literal xsd:boolean.
413  * @RASQAL_LITERAL_INTEGER: Integer literal xsd:integer.
414  * @RASQAL_LITERAL_DOUBLE: Double floating point literal xsd:double.
415  * @RASQAL_LITERAL_FLOAT: Floating point literal xsd:float.
416  * @RASQAL_LITERAL_DECIMAL: Decimal integer xsd:decimal.
417  * @RASQAL_LITERAL_DATETIME: Date/Time literal xsd:dateTime.
418  * @RASQAL_LITERAL_UDT: User defined typed literal with unknown datatype URI
419  * @RASQAL_LITERAL_PATTERN: Pattern literal for a regex.
420  * @RASQAL_LITERAL_QNAME: XML Qname literal.
421  * @RASQAL_LITERAL_VARIABLE: Variable literal.
422  * @RASQAL_LITERAL_DATE: Date literal xsd:date.
423  * @RASQAL_LITERAL_INTEGER_SUBTYPE: Internal.
424  * @RASQAL_LITERAL_UNKNOWN: Internal.
425  * @RASQAL_LITERAL_FIRST_XSD: Internal.
426  * @RASQAL_LITERAL_LAST_XSD: Internal.
427  * @RASQAL_LITERAL_LAST: Internal.
428  *
429  * Types of literal.
430  *
431  * The order in the enumeration is significant as it encodes
432  * the SPARQL term ordering conditions:
433  *
434  *   Blank Nodes << IRIs << RDF literals << typed literals
435  *
436  * which coresponds to in enum values
437  *
438  *   BLANK << URI << STRING <<
439  *     (BOOLEAN | INTEGER | DOUBLE | FLOAT | DECIMAL | DATETIME | XSD_STRING)
440  *
441  *     (RASQAL_LITERAL_FIRST_XSD ... RASQAL_LITERAL_LAST_XSD)
442  *
443  * Not used (internal): PATTERN, QNAME, VARIABLE
444  *
445  * See rasqal_literal_compare() when used with flags
446  * %RASQAL_COMPARE_XQUERY
447  */
448 typedef enum {
449   /* internal */
450   RASQAL_LITERAL_UNKNOWN,
451   RASQAL_LITERAL_BLANK,
452   RASQAL_LITERAL_URI,
453   RASQAL_LITERAL_STRING,
454   RASQAL_LITERAL_XSD_STRING,
455   RASQAL_LITERAL_BOOLEAN,
456   RASQAL_LITERAL_INTEGER,
457   RASQAL_LITERAL_FLOAT,
458   RASQAL_LITERAL_DOUBLE,
459   RASQAL_LITERAL_DECIMAL,
460   RASQAL_LITERAL_DATETIME,
461   /* internal */
462   RASQAL_LITERAL_FIRST_XSD = RASQAL_LITERAL_XSD_STRING,
463   /* internal */
464   RASQAL_LITERAL_LAST_XSD = RASQAL_LITERAL_DATETIME,
465   RASQAL_LITERAL_UDT,
466   RASQAL_LITERAL_PATTERN,
467   RASQAL_LITERAL_QNAME,
468   RASQAL_LITERAL_VARIABLE,
469   /* internal */
470   RASQAL_LITERAL_INTEGER_SUBTYPE,
471   RASQAL_LITERAL_DATE,
472   /* internal */
473   RASQAL_LITERAL_LAST = RASQAL_LITERAL_DATE
474 } rasqal_literal_type;
475 
476 #define RASQAL_LITERAL_UDT_DEFINED 1
477 
478 
479 /**
480  * rasqal_row:
481  *
482  * Rasqal Result Row class.
483  */
484 typedef struct rasqal_row_s rasqal_row;
485 
486 
487 /**
488  * rasqal_xsd_decimal:
489  *
490  * Rasqal XSD Decimal class.
491  */
492 typedef struct rasqal_xsd_decimal_s rasqal_xsd_decimal;
493 
494 
495 /**
496  * RASQAL_XSD_DATETIME_NO_TZ:
497  *
498  * Sentinel XSD Decimal timezone value indicating no timezone is present.
499  */
500 #define RASQAL_XSD_DATETIME_NO_TZ (9999)
501 
502 /**
503  * rasqal_xsd_date:
504  * @year: year
505  * @month: month 1-12
506  * @day: 1-31
507  * @timezone_minutes: minutes +/- against UTC or RASQAL_XSD_DATETIME_NO_TZ if there is no timezone in the dateTime.
508  * @time_on_timeline: time on timeline of first instant of date in timezone
509  * @have_tz: timezone flag: 'Z' if Zulu, 'Y' if has other timezone offset in @timezone_minutes, 'N' if there is no timezone
510  *
511  * XML schema date datatype (xsd:date)
512  *
513  * Examples of timezone fields:
514  *  "2010-01-02" : timezone_minutes RASQAL_XSD_DATETIME_NO_TZ, have_tz 'N'
515  *  "2010-01-02Z" : timezone_minutes 0, have_tz 'Z'
516  *  "2010-01-02+00:00" : timezone_minutes 0, have_tz 'Y'
517  *  "2010-01-02-01:00" : timezone_minutes -60, have_tz 'Y'
518  */
519 typedef struct {
520   signed int year;
521   /* the following fields are integer values not characters */
522   unsigned char month;
523   unsigned char day;
524   signed short timezone_minutes;
525   time_t time_on_timeline;
526   char have_tz;
527 } rasqal_xsd_date;
528 
529 
530 /**
531  * rasqal_xsd_datetime:
532  * @year: year
533  * @month: month 1-12
534  * @day: 1-31
535  * @hour: hour 0-23
536  * @minute: minute 0-59
537  * @second: second 0-60 (yes 60 is allowed for leap seconds)
538  * @microseconds: microseconds
539  * @timezone_minutes: minutes +/- against UTC or RASQAL_XSD_DATETIME_NO_TZ if there is no timezone in the dateTime.
540  * @time_on_timeline: time on timeline
541  * @have_tz: timezone flag: 'Z' if Zulu, 'Y' if has other timezone offset in @timezone_minutes, 'N' if there is no timezone
542  *
543  * XML Schema dateTime datatype (xsd:dateTime)
544  *
545  * Signed types are required for normalization process where a value
546  * can be negative temporarily.
547  *
548  * Examples of timezone fields:
549  *  "2010-01-02T01:02:03" : timezone_minutes RASQAL_XSD_DATETIME_NO_TZ, have_tz 'N'
550  *  "2010-01-02T01:02:03Z" : timezone_minutes 0, have_tz 'Z'
551  *  "2010-01-02T01:02:03+00:00" : timezone_minutes 0, have_tz 'Y'
552  *  "2010-01-02T01:02:03-01:00" : timezone_minutes -60, have_tz 'Y'
553  */
554 typedef struct {
555   signed int year;
556   unsigned char month;
557   unsigned char day;
558   /* the following fields are integer values not characters */
559   signed char hour;
560   signed char minute;
561   signed char second;
562   signed int microseconds;
563   signed short timezone_minutes;
564   time_t time_on_timeline;
565   char have_tz;
566 } rasqal_xsd_datetime;
567 
568 
569 /**
570  * rasqal_literal:
571  * @world: world object pointer
572  * @usage: Usage count.
573  * @type: Type of literal.
574  * @string: String form of literal for literal types UTF-8 string, pattern, qname, blank, double, float, decimal, datetime.
575  * @string_len: Length of @string.
576  * @value: Alternate value content.
577  * @language: Language for string literal type.
578  * @datatype: Datatype for string literal type.
579  * @flags: Flags for literal types
580  * @parent_type: parent XSD type if any or RASQAL_LITERAL_UNKNOWN
581  * @valid: >0 if literal format is a valid lexical form for this datatype. 0 if not valid. <0 if this has not been checked yet
582  *
583  * Rasqal literal class.
584  *
585  */
586 struct rasqal_literal_s {
587   rasqal_world *world;
588 
589   int usage;
590 
591   rasqal_literal_type type;
592 
593   /* UTF-8 string, pattern, qname, blank, double, float, decimal, datetime */
594   const unsigned char *string;
595   unsigned int string_len;
596 
597   union {
598     /* integer and boolean types */
599     int integer;
600     /* double and float */
601     double floating;
602     /* uri (can be temporarily NULL if a qname, see flags below) */
603     raptor_uri* uri;
604     /* variable */
605     rasqal_variable* variable;
606     /* decimal */
607     rasqal_xsd_decimal* decimal;
608     /* datetime  */
609     rasqal_xsd_datetime* datetime;
610     /* date  */
611     rasqal_xsd_date* date;
612   } value;
613 
614   /* for string */
615   char *language;
616   raptor_uri *datatype;
617 
618   /* various flags for literal types:
619    *  pattern  regex flags
620    *  string   datatype of qname
621    *  uri      qname of URI not yet expanded (temporary)
622    */
623   const unsigned char *flags;
624 
625   rasqal_literal_type parent_type;
626 
627   int valid;
628 };
629 
630 
631 /**
632  * rasqal_op:
633  * @RASQAL_EXPR_AND: Expression for AND(A, B)
634  * @RASQAL_EXPR_OR: Expression for OR(A, B)
635  * @RASQAL_EXPR_EQ: Expression for A equals B
636  * @RASQAL_EXPR_NEQ: Expression for A not equals B.
637  * @RASQAL_EXPR_LT: Expression for A less than B.
638  * @RASQAL_EXPR_GT: Expression for A greather than B.
639  * @RASQAL_EXPR_LE: Expression for A less than or equal to B.
640  * @RASQAL_EXPR_GE: Expression for A greater than or equal to B.
641  * @RASQAL_EXPR_UMINUS: Expression for -A.
642  * @RASQAL_EXPR_PLUS: Expression for +A.
643  * @RASQAL_EXPR_MINUS: Expression for A-B.
644  * @RASQAL_EXPR_STAR: Expression for A*B.
645  * @RASQAL_EXPR_SLASH: Expression for A/B.
646  * @RASQAL_EXPR_REM: Expression for A/B remainder.
647  * @RASQAL_EXPR_STR_EQ: Expression for A string equals B.
648  * @RASQAL_EXPR_STR_NEQ: Expression for A string not-equals B.
649  * @RASQAL_EXPR_STR_MATCH: Expression for string A matches literal regex B with flags.
650  * @RASQAL_EXPR_STR_NMATCH: Expression for string A not-matches literal regex B with flags.
651  * @RASQAL_EXPR_REGEX: Expression for string A matches expression regex B with flags.
652  * @RASQAL_EXPR_TILDE: Expression for binary not A.
653  * @RASQAL_EXPR_BANG: Expression for logical not A.
654  * @RASQAL_EXPR_LITERAL: Expression for a #rasqal_literal.
655  * @RASQAL_EXPR_FUNCTION: Expression for a function A with arguments (B...).
656  * @RASQAL_EXPR_BOUND: Expression for SPARQL ISBOUND(A).
657  * @RASQAL_EXPR_STR: Expression for SPARQL STR(A).
658  * @RASQAL_EXPR_LANG: Expression for SPARQL LANG(A).
659  * @RASQAL_EXPR_LANGMATCHES: Expression for SPARQL LANGMATCHES(A, B).
660  * @RASQAL_EXPR_DATATYPE: Expression for SPARQL DATATYPE(A).
661  * @RASQAL_EXPR_ISURI: Expression for SPARQL ISURI(A).
662  * @RASQAL_EXPR_ISBLANK: Expression for SPARQL ISBLANK(A).
663  * @RASQAL_EXPR_ISLITERAL: Expression for SPARQL ISLITERAL(A).
664  * @RASQAL_EXPR_CAST: Expression for cast literal A to type B.
665  * @RASQAL_EXPR_ORDER_COND_ASC: Expression for SPARQL order condition ascending.
666  * @RASQAL_EXPR_ORDER_COND_DESC: Expression for SPARQL order condition descending.
667  * @RASQAL_EXPR_GROUP_COND_ASC: Obsolete - not used
668  * @RASQAL_EXPR_GROUP_COND_DESC: Obsolete - not used
669  * @RASQAL_EXPR_COUNT: Expression for LAQRS select COUNT() aggregate function
670  * @RASQAL_EXPR_VARSTAR: Expression for LAQRS select Variable *
671  * @RASQAL_EXPR_SAMETERM: Expression for SPARQL sameTerm
672  * @RASQAL_EXPR_SUM: Expression for LAQRS select SUM() aggregate function
673  * @RASQAL_EXPR_AVG: Expression for LAQRS select AVG() aggregate function
674  * @RASQAL_EXPR_MIN: Expression for LAQRS select MIN() aggregate function
675  * @RASQAL_EXPR_MAX: Expression for LAQRS select MAX() aggregate function
676  * @RASQAL_EXPR_COALESCE: Expression for LAQRS COALESCE(Expr+)
677  * @RASQAL_EXPR_IF: Expression for LAQRS IF(expr, expr, expr)
678  * @RASQAL_EXPR_URI: Expression for LAQRS URI(expr)
679  * @RASQAL_EXPR_IRI: Expression for LAQRS IRI(expr)
680  * @RASQAL_EXPR_STRLANG: Expression for LAQRS STRLANG(expr, expr)
681  * @RASQAL_EXPR_STRDT: Expression for LAQRS STRDT(expr, expr)
682  * @RASQAL_EXPR_BNODE: Expression for LAQRS BNODE() and BNODE(expr)
683  * @RASQAL_EXPR_GROUP_CONCAT: Expression for LAQRS GROUP_CONCAT(arglist) aggregate function
684  * @RASQAL_EXPR_SAMPLE: Expression for LAQRS SAMPLE(expr) aggregate function
685  * @RASQAL_EXPR_IN: Expression for LAQRS expr IN ( list of expr )
686  * @RASQAL_EXPR_NOT_IN: Expression for LAQRS expr NOT IN ( list of expr )
687  * @RASQAL_EXPR_ISNUMERIC: Expression for SPARQL 1.1 isNUMERIC(expr)
688  * @RASQAL_EXPR_YEAR: Expression for SPARQL 1.1 YEAR(datetime)
689  * @RASQAL_EXPR_MONTH: Expression for SPARQL 1.1 MONTH(datetime)
690  * @RASQAL_EXPR_DAY: Expression for SPARQL 1.1 DAY(datetime)
691  * @RASQAL_EXPR_HOURS: Expression for SPARQL 1.1 HOURS(datetime)
692  * @RASQAL_EXPR_MINUTES: Expression for SPARQL 1.1 MINUTES(datetime)
693  * @RASQAL_EXPR_SECONDS: Expression for SPARQL 1.1 SECONDS(datetime)
694  * @RASQAL_EXPR_TIMEZONE: Expression for SPARQL 1.1 TIMEZONE(datetime)
695  * @RASQAL_EXPR_CURRENT_DATETIME: Expression for LAQRS CURRENT_DATETIME( void )
696  * @RASQAL_EXPR_NOW: Expression for LAQRS NOW( void )
697  * @RASQAL_EXPR_FROM_UNIXTIME: Expression for LAQRS FROM_UNIXTIME(int)
698  * @RASQAL_EXPR_TO_UNIXTIME: Expression for LAQRS TO_UNIXTIME(datetime)
699  * @RASQAL_EXPR_CONCAT: Expression for SPARQL 1.1 CONCAT(strings)
700  * @RASQAL_EXPR_STRLEN: Expression for SPARQL 1.1 STRLEN(str)
701  * @RASQAL_EXPR_SUBSTR: Expression for SPARQL 1.1 SUBSTR(str, start[,offset])
702  * @RASQAL_EXPR_UCASE: Expression for SPARQL 1.1 UCASE(str)
703  * @RASQAL_EXPR_LCASE: Expression for SPARQL 1.1 LCASE(str)
704  * @RASQAL_EXPR_STRSTARTS: Expression for SPARQL 1.1 STRSTARTS(str, str)
705  * @RASQAL_EXPR_STRENDS: Expression for SPARQL 1.1 STRENDS(str, str)
706  * @RASQAL_EXPR_CONTAINS: Expression for SPARQL 1.1 CONTAINS(str, str)
707  * @RASQAL_EXPR_ENCODE_FOR_URI: Expression for SPARQL 1.1 ENCODE_FOR_URI(str)
708  * @RASQAL_EXPR_TZ: Expression for SPARQL 1.1 TZ()
709  * @RASQAL_EXPR_RAND: Expression for SPARQL 1.1 RAND()
710  * @RASQAL_EXPR_ABS: Expression for SPARQL 1.1 ABS()
711  * @RASQAL_EXPR_ROUND: Expression for SPARQL 1.1 ROUND()
712  * @RASQAL_EXPR_CEIL: Expression for SPARQL 1.1 CEIL()
713  * @RASQAL_EXPR_FLOOR: Expression for SPARQL 1.1 FLOOR()
714  * @RASQAL_EXPR_MD5: Expression for SPARQL 1.1 MD5()
715  * @RASQAL_EXPR_SHA1: Expression for SPARQL 1.1 SHA1()
716  * @RASQAL_EXPR_SHA224: Expression for SPARQL 1.1 SHA224()
717  * @RASQAL_EXPR_SHA256: Expression for SPARQL 1.1 SHA256()
718  * @RASQAL_EXPR_SHA384: Expression for SPARQL 1.1 SHA384()
719  * @RASQAL_EXPR_SHA512: Expression for SPARQL 1.1 SHA512()
720  * @RASQAL_EXPR_STRBEFORE: Expression for SPARQL 1.1 STRBEFORE()
721  * @RASQAL_EXPR_STRAFTER: Expression for SPARQL 1.1 STRAFTER()
722  * @RASQAL_EXPR_REPLACE: Expression for SPARQL 1.1 REPLACE()
723  * @RASQAL_EXPR_UUID: Expression for SPARQL 1.1 UUID()
724  * @RASQAL_EXPR_STRUUID: Expression for SPARQL 1.1 STRUUID()
725  * @RASQAL_EXPR_UNKNOWN: Internal
726  * @RASQAL_EXPR_LAST: Internal
727  *
728  * Rasqal expression operators.  A mixture of unary, binary and
729  * tertiary operators (string matches).  Also includes casting and
730  * two ordering operators from ORDER BY in SPARQL.
731  */
732 typedef enum {
733   /* internal */
734   RASQAL_EXPR_UNKNOWN,
735   RASQAL_EXPR_AND,
736   RASQAL_EXPR_OR,
737   RASQAL_EXPR_EQ,
738   RASQAL_EXPR_NEQ,
739   RASQAL_EXPR_LT,
740   RASQAL_EXPR_GT,
741   RASQAL_EXPR_LE,
742   RASQAL_EXPR_GE,
743   RASQAL_EXPR_UMINUS,
744   RASQAL_EXPR_PLUS,
745   RASQAL_EXPR_MINUS,
746   RASQAL_EXPR_STAR,
747   RASQAL_EXPR_SLASH,
748   RASQAL_EXPR_REM,
749   RASQAL_EXPR_STR_EQ,
750   RASQAL_EXPR_STR_NEQ,
751   RASQAL_EXPR_STR_MATCH,
752   RASQAL_EXPR_STR_NMATCH,
753   RASQAL_EXPR_TILDE,
754   RASQAL_EXPR_BANG,
755   RASQAL_EXPR_LITERAL,
756   RASQAL_EXPR_FUNCTION,
757   RASQAL_EXPR_BOUND,
758   RASQAL_EXPR_STR,
759   RASQAL_EXPR_LANG,
760   RASQAL_EXPR_DATATYPE,
761   RASQAL_EXPR_ISURI,
762   RASQAL_EXPR_ISBLANK,
763   RASQAL_EXPR_ISLITERAL,
764   RASQAL_EXPR_CAST,
765   RASQAL_EXPR_ORDER_COND_ASC,
766   RASQAL_EXPR_ORDER_COND_DESC,
767   RASQAL_EXPR_LANGMATCHES,
768   RASQAL_EXPR_REGEX,
769   RASQAL_EXPR_GROUP_COND_ASC,
770   RASQAL_EXPR_GROUP_COND_DESC,
771   RASQAL_EXPR_COUNT,
772   RASQAL_EXPR_VARSTAR,
773   RASQAL_EXPR_SAMETERM,
774   RASQAL_EXPR_SUM,
775   RASQAL_EXPR_AVG,
776   RASQAL_EXPR_MIN,
777   RASQAL_EXPR_MAX,
778   RASQAL_EXPR_COALESCE,
779   RASQAL_EXPR_IF,
780   RASQAL_EXPR_URI,
781   RASQAL_EXPR_IRI,
782   RASQAL_EXPR_STRLANG,
783   RASQAL_EXPR_STRDT,
784   RASQAL_EXPR_BNODE,
785   RASQAL_EXPR_GROUP_CONCAT,
786   RASQAL_EXPR_SAMPLE,
787   RASQAL_EXPR_IN,
788   RASQAL_EXPR_NOT_IN,
789   RASQAL_EXPR_ISNUMERIC,
790   RASQAL_EXPR_YEAR,
791   RASQAL_EXPR_MONTH,
792   RASQAL_EXPR_DAY,
793   RASQAL_EXPR_HOURS,
794   RASQAL_EXPR_MINUTES,
795   RASQAL_EXPR_SECONDS,
796   RASQAL_EXPR_TIMEZONE,
797   RASQAL_EXPR_CURRENT_DATETIME,
798   RASQAL_EXPR_NOW,
799   RASQAL_EXPR_FROM_UNIXTIME,
800   RASQAL_EXPR_TO_UNIXTIME,
801   RASQAL_EXPR_CONCAT,
802   RASQAL_EXPR_STRLEN,
803   RASQAL_EXPR_SUBSTR,
804   RASQAL_EXPR_UCASE,
805   RASQAL_EXPR_LCASE,
806   RASQAL_EXPR_STRSTARTS,
807   RASQAL_EXPR_STRENDS,
808   RASQAL_EXPR_CONTAINS,
809   RASQAL_EXPR_ENCODE_FOR_URI,
810   RASQAL_EXPR_TZ,
811   RASQAL_EXPR_RAND,
812   RASQAL_EXPR_ABS,
813   RASQAL_EXPR_ROUND,
814   RASQAL_EXPR_CEIL,
815   RASQAL_EXPR_FLOOR,
816   RASQAL_EXPR_MD5,
817   RASQAL_EXPR_SHA1,
818   RASQAL_EXPR_SHA224,
819   RASQAL_EXPR_SHA256,
820   RASQAL_EXPR_SHA384,
821   RASQAL_EXPR_SHA512,
822   RASQAL_EXPR_STRBEFORE,
823   RASQAL_EXPR_STRAFTER,
824   RASQAL_EXPR_REPLACE,
825   RASQAL_EXPR_UUID,
826   RASQAL_EXPR_STRUUID,
827   /* internal */
828   RASQAL_EXPR_LAST = RASQAL_EXPR_STRUUID
829 } rasqal_op;
830 
831 
832 /**
833  * rasqal_expression_flags:
834  * @RASQAL_EXPR_FLAG_DISTINCT: Distinct
835  * @RASQAL_EXPR_FLAG_AGGREGATE: Aggregate function expression
836  *
837  * Flags for expressions.
838  */
839 typedef enum {
840   RASQAL_EXPR_FLAG_DISTINCT = 1,
841   RASQAL_EXPR_FLAG_AGGREGATE = 2
842 } rasqal_expression_flags;
843 
844 
845 /**
846  * rasqal_expression:
847  * @world: rasqal_world object
848  * @usage: reference count - 1 for itself
849  * @op: expression operation
850  * @arg1: first argument
851  * @arg2: second argument
852  * @arg3: third argument (for #RASQAL_EXPR_REGEX )
853  * @literal: literal argument
854  * @value: UTF-8 value
855  * @name: name for extension function qname(args...) and cast-to-uri
856  * @args: args for extension function qname(args...), cast-to-uri and COALESCE
857  * @params: args for extension function parameters (SPARQL 1.1) (Rasqal 0.9.20+)
858  * @flags: bitflags from #rasqal_expression_flags for expressions (Rasqal 0.9.20+)
859  * @arg4: fourth argument (for #RASQAL_EXPR_REPLACE )
860  *
861  * Expression with arguments
862  *
863  */
864 struct rasqal_expression_s {
865   rasqal_world* world;
866 
867   int usage;
868 
869   rasqal_op op;
870 
871   struct rasqal_expression_s* arg1;
872   struct rasqal_expression_s* arg2;
873   struct rasqal_expression_s* arg3;
874   rasqal_literal* literal;
875   unsigned char *value;
876 
877   raptor_uri* name;
878   raptor_sequence* args;
879 
880   raptor_sequence* params;
881   unsigned int flags;
882   struct rasqal_expression_s* arg4;
883 };
884 typedef struct rasqal_expression_s rasqal_expression;
885 
886 
887 /**
888  * rasqal_triple:
889  * @subject: Triple subject.
890  * @predicate: Triple predicate.
891  * @object: Triple object.
892  * @origin: Triple origin.
893  * @flags: Or of enum #rasqal_triple_flags bits.
894  *
895  * A triple pattern or RDF triple.
896  *
897  * This is used as a triple pattern in queries and
898  * an RDF triple when generating RDF triples such as with SPARQL CONSTRUCT.
899  */
900 typedef struct {
901   rasqal_literal* subject;
902   rasqal_literal* predicate;
903   rasqal_literal* object;
904   rasqal_literal* origin;
905   unsigned int flags;
906 } rasqal_triple;
907 
908 
909 /**
910  * rasqal_pattern_flags:
911  * @RASQAL_PATTERN_FLAGS_OPTIONAL: True when the graph pattern is an optional match.
912  * @RASQAL_PATTERN_FLAGS_LAST: Internal
913  *
914  * Flags for #rasqal_graph_pattern.
915  */
916 typedef enum {
917   RASQAL_PATTERN_FLAGS_OPTIONAL = 1,
918 
919   RASQAL_PATTERN_FLAGS_LAST     = RASQAL_PATTERN_FLAGS_OPTIONAL
920 } rasqal_pattern_flags;
921 
922 
923 /**
924  * rasqal_generate_bnodeid_handler:
925  * @world: world arg
926  * @user_data: user data given to
927  * @user_bnodeid: user blank node ID string passed in
928  *
929  * User handler used with rasqal_world_set_generate_bnodeid_handler() to set method for generating a blank node ID.
930  *
931  * Return value: blank node ID string or NULL on failure.
932  */
933 typedef unsigned char* (*rasqal_generate_bnodeid_handler)(rasqal_world* world, void *user_data, unsigned char *user_bnodeid);
934 
935 
936 /**
937  * rasqal_query_verb:
938  * @RASQAL_QUERY_VERB_SELECT: SPARQL query select verb.
939  * @RASQAL_QUERY_VERB_CONSTRUCT: SPARQL query construct verb.
940  * @RASQAL_QUERY_VERB_DESCRIBE: SPARQL query describe verb.
941  * @RASQAL_QUERY_VERB_ASK: SPARQL query ask verb.
942  * @RASQAL_QUERY_VERB_DELETE: LAQRS query delete verb.
943  * @RASQAL_QUERY_VERB_INSERT: LAQRS query insert verb.
944  * @RASQAL_QUERY_VERB_UPDATE: SPARQL 1.1 (draft) update operation
945  * @RASQAL_QUERY_VERB_UNKNOWN: Internal
946  * @RASQAL_QUERY_VERB_LAST: Internal
947  *
948  * Query main operation verbs describing the major type of query
949  * being performed.
950  */
951 typedef enum {
952   /* internal */
953   RASQAL_QUERY_VERB_UNKNOWN   = 0,
954   RASQAL_QUERY_VERB_SELECT    = 1,
955   RASQAL_QUERY_VERB_CONSTRUCT = 2,
956   RASQAL_QUERY_VERB_DESCRIBE  = 3,
957   RASQAL_QUERY_VERB_ASK       = 4,
958   RASQAL_QUERY_VERB_DELETE    = 5,
959   RASQAL_QUERY_VERB_INSERT    = 6,
960   RASQAL_QUERY_VERB_UPDATE    = 7,
961 
962   /* internal */
963   RASQAL_QUERY_VERB_LAST = RASQAL_QUERY_VERB_UPDATE
964 } rasqal_query_verb;
965 
966 
967 /**
968  * rasqal_query_results_type:
969  * @RASQAL_QUERY_RESULTS_BINDINGS: variable binding
970  * @RASQAL_QUERY_RESULTS_BOOLEAN: a single boolean
971  * @RASQAL_QUERY_RESULTS_GRAPH: an RDF graph
972  * @RASQAL_QUERY_RESULTS_SYNTAX: a syntax
973  * @RASQAL_QUERY_RESULTS_UNKNOWN: unknown type
974  * @RASQAL_QUERY_RESULTS_LAST: internal
975  *
976  * Query result type.
977  */
978 
979 typedef enum {
980   RASQAL_QUERY_RESULTS_BINDINGS,
981   RASQAL_QUERY_RESULTS_BOOLEAN,
982   RASQAL_QUERY_RESULTS_GRAPH,
983   RASQAL_QUERY_RESULTS_SYNTAX,
984   RASQAL_QUERY_RESULTS_UNKNOWN,
985   RASQAL_QUERY_RESULTS_LAST = RASQAL_QUERY_RESULTS_UNKNOWN
986 } rasqal_query_results_type;
987 
988 
989 /**
990  * rasqal_update_type:
991  * @RASQAL_UPDATE_TYPE_CLEAR: Clear graph.
992  * @RASQAL_UPDATE_TYPE_CREATE: Create graph.
993  * @RASQAL_UPDATE_TYPE_DROP: Drop graph.
994  * @RASQAL_UPDATE_TYPE_LOAD: Load graph.
995  * @RASQAL_UPDATE_TYPE_UPDATE: Insert or Delete graph or triples.
996  * @RASQAL_UPDATE_TYPE_ADD: Add graph to another graph.
997  * @RASQAL_UPDATE_TYPE_MOVE: Move graph to another grpah.
998  * @RASQAL_UPDATE_TYPE_COPY: Copy graph to another graph.
999  * @RASQAL_UPDATE_TYPE_UNKNOWN: Internal
1000  * @RASQAL_UPDATE_TYPE_LAST: Internal
1001  *
1002  * Update type being performed.
1003  *
1004  */
1005 typedef enum {
1006   /* internal */
1007   RASQAL_UPDATE_TYPE_UNKNOWN   = 0,
1008   RASQAL_UPDATE_TYPE_CLEAR     = 1,
1009   RASQAL_UPDATE_TYPE_CREATE    = 2,
1010   RASQAL_UPDATE_TYPE_DROP      = 3,
1011   RASQAL_UPDATE_TYPE_LOAD      = 4,
1012   RASQAL_UPDATE_TYPE_UPDATE    = 5,
1013   RASQAL_UPDATE_TYPE_ADD       = 6,
1014   RASQAL_UPDATE_TYPE_MOVE      = 7,
1015   RASQAL_UPDATE_TYPE_COPY      = 8,
1016 
1017   /* internal */
1018   RASQAL_UPDATE_TYPE_LAST = RASQAL_UPDATE_TYPE_COPY
1019 } rasqal_update_type;
1020 
1021 
1022 /**
1023  * rasqal_update_flags:
1024  * @RASQAL_UPDATE_FLAGS_SILENT: the update operation should be silent
1025  * @RASQAL_UPDATE_FLAGS_DATA: the update operation is triple data not templates
1026  *
1027  * Bitflags for graph update operations
1028  */
1029 typedef enum {
1030   RASQAL_UPDATE_FLAGS_SILENT = 1,
1031   RASQAL_UPDATE_FLAGS_DATA = 2
1032 } rasqal_update_flags;
1033 
1034 
1035 /**
1036  * rasqal_update_graph_applies:
1037  * @RASQAL_UPDATE_GRAPH_ONE: the update operation applies to 1 graph
1038  * @RASQAL_UPDATE_GRAPH_DEFAULT: the update operation applies to the default graph
1039  * @RASQAL_UPDATE_GRAPH_NAMED: the update operation applies to all named graphs
1040  * @RASQAL_UPDATE_GRAPH_ALL: the update operation applies ALL graphs
1041  *
1042  * The graph(s) that the update operation applies to.
1043  */
1044 typedef enum {
1045   RASQAL_UPDATE_GRAPH_ONE = 0,
1046   RASQAL_UPDATE_GRAPH_DEFAULT = 1,
1047   RASQAL_UPDATE_GRAPH_NAMED = 2,
1048   RASQAL_UPDATE_GRAPH_ALL = 3
1049 } rasqal_update_graph_applies;
1050 
1051 
1052 /**
1053  * rasqal_update_operation:
1054  * @type: type of update
1055  * @graph_uri: optional graph URI (clear, drop, load, with ... delete, insert); source graph (add, move, copy)
1056  * @document_uri: optional document URI (load); destination graph (add, move, copy)
1057  * @insert_templates: optional sequence of #rasqal_triple to insert. Data triples if @flags is #RASQAL_UPDATE_FLAGS_DATA set, templates otherwise.
1058  * @delete_templates: optional sequence of #rasqal_triple templates to delete
1059  * @where: optional where template (insert/delete)
1060  * @flags: update flags - bit-or of flags defined in #rasqal_update_flags
1061  * @applies: the graph(s) that the update operation applies to, or @graph_uri if #RASQAL_UPDATE_GRAPH_ONE
1062  *
1063  * Update operation - changing the dataset
1064  *
1065  * For LOAD and CLEAR if @applies is set (not 0) then the operation
1066  * applies to just those graph(), otherwise it applies to the @graph_uri.
1067  *
1068  * For ADD, MOVE and COPY the source graph is stored in @graph_uri
1069  * field and the destination graph in the @document_uri field.  The
1070  * field names have no meaning in this case since both values are
1071  * always present, always graphs and a NULL value signifies the
1072  * default graph.
1073  *
1074  */
1075 typedef struct {
1076   rasqal_update_type type;
1077 
1078   raptor_uri* graph_uri;
1079 
1080   raptor_uri* document_uri;
1081 
1082   raptor_sequence* insert_templates;
1083 
1084   raptor_sequence* delete_templates;
1085 
1086   rasqal_graph_pattern* where;
1087 
1088   int flags;
1089 
1090   rasqal_update_graph_applies applies;
1091 } rasqal_update_operation;
1092 
1093 
1094 /**
1095  * rasqal_graph_pattern_operator:
1096  * @RASQAL_GRAPH_PATTERN_OPERATOR_BASIC: Just triple patterns and constraints.
1097  * @RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL: Set of graph patterns (ANDed) and constraints.
1098  * @RASQAL_GRAPH_PATTERN_OPERATOR_UNION: Set of graph patterns (UNIONed) and constraints.
1099  * @RASQAL_GRAPH_PATTERN_OPERATOR_GROUP: Set of graph patterns (ANDed) and constraints.
1100  * @RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH: A graph term + a graph pattern and constraints.
1101  * @RASQAL_GRAPH_PATTERN_OPERATOR_FILTER: A filter graph pattern with an expression
1102  * @RASQAL_GRAPH_PATTERN_OPERATOR_LET: LET ?var := Expression (LAQRS)
1103  * @RASQAL_GRAPH_PATTERN_OPERATOR_SELECT: SELECT graph pattern
1104  * @RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE: SERVICE graph pattern
1105  * @RASQAL_GRAPH_PATTERN_OPERATOR_MINUS: MINUS graph pattern
1106  * @RASQAL_GRAPH_PATTERN_OPERATOR_VALUES: VALUES graph pattern
1107  * @RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN: Internal.
1108  * @RASQAL_GRAPH_PATTERN_OPERATOR_LAST: Internal.
1109  *
1110  * Graph pattern operators
1111  */
1112 typedef enum {
1113   RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN   = 0,
1114   RASQAL_GRAPH_PATTERN_OPERATOR_BASIC     = 1,
1115   RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL  = 2,
1116   RASQAL_GRAPH_PATTERN_OPERATOR_UNION     = 3,
1117   RASQAL_GRAPH_PATTERN_OPERATOR_GROUP     = 4,
1118   RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH     = 5,
1119   RASQAL_GRAPH_PATTERN_OPERATOR_FILTER    = 6,
1120   RASQAL_GRAPH_PATTERN_OPERATOR_LET       = 7,
1121   RASQAL_GRAPH_PATTERN_OPERATOR_SELECT    = 8,
1122   RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE   = 9,
1123   RASQAL_GRAPH_PATTERN_OPERATOR_MINUS     = 10,
1124   RASQAL_GRAPH_PATTERN_OPERATOR_VALUES    = 11,
1125 
1126   RASQAL_GRAPH_PATTERN_OPERATOR_LAST = RASQAL_GRAPH_PATTERN_OPERATOR_VALUES
1127 } rasqal_graph_pattern_operator;
1128 
1129 
1130 /**
1131  * rasqal_graph_pattern_visit_fn:
1132  * @query: #rasqal_query containing the graph pattern
1133  * @gp: current graph_pattern
1134  * @user_data: user data passed in
1135  *
1136  * User function to visit a graph_pattern and operate on it with
1137  * rasqal_graph_pattern_visit() or rasqal_query_graph_pattern_visit()
1138  *
1139  * Return value: non-0 to truncate the visit
1140  */
1141 typedef int (*rasqal_graph_pattern_visit_fn)(rasqal_query* query, rasqal_graph_pattern* gp, void *user_data);
1142 
1143 
1144 /* RASQAL API */
1145 
1146 /* Public functions */
1147 
1148 RASQAL_API
1149 rasqal_world *rasqal_new_world(void);
1150 RASQAL_API
1151 int rasqal_world_open(rasqal_world* world);
1152 RASQAL_API
1153 void rasqal_free_world(rasqal_world* world);
1154 
1155 RASQAL_API
1156 void rasqal_world_set_raptor(rasqal_world* world, raptor_world* raptor_world_ptr);
1157 RASQAL_API
1158 raptor_world *rasqal_world_get_raptor(rasqal_world* world);
1159 
1160 RASQAL_API
1161 void rasqal_world_set_log_handler(rasqal_world* world, void *user_data, raptor_log_handler handler);
1162 
1163 RASQAL_API
1164 int rasqal_world_set_default_generate_bnodeid_parameters(rasqal_world* world, char *prefix, int base);
1165 RASQAL_API
1166 int rasqal_world_set_generate_bnodeid_handler(rasqal_world* world, void *user_data, rasqal_generate_bnodeid_handler handler);
1167 
1168 RASQAL_API
1169 int rasqal_world_set_warning_level(rasqal_world* world, unsigned int warning_level);
1170 
1171 RASQAL_API
1172 const raptor_syntax_description* rasqal_world_get_query_results_format_description(rasqal_world* world, unsigned int counter);
1173 
1174 RASQAL_API
1175 const char* rasqal_world_guess_query_results_format_name(rasqal_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier);
1176 
1177 /* Features */
1178 RASQAL_API
1179 int rasqal_features_enumerate(rasqal_world* world, const rasqal_feature feature, const char **name, raptor_uri **uri, const char **label);
1180 RASQAL_API
1181 unsigned int rasqal_get_feature_count(void);
1182 RASQAL_API
1183 rasqal_feature rasqal_feature_from_uri(rasqal_world* world, raptor_uri *uri);
1184 RASQAL_API
1185 int rasqal_feature_value_type(const rasqal_feature feature);
1186 
1187 
1188 RASQAL_API
1189 const raptor_syntax_description* rasqal_world_get_query_language_description(rasqal_world* world, unsigned int counter);
1190 
1191 RASQAL_API RASQAL_DEPRECATED
1192 int rasqal_languages_enumerate(rasqal_world* world, unsigned int counter, const char **name, const char **label, const unsigned char **uri_string);
1193 
1194 RASQAL_API
1195 int rasqal_language_name_check(rasqal_world* world, const char *name);
1196 
1197 
1198 /* Query class */
1199 
1200 /* Create */
1201 RASQAL_API
1202 rasqal_query* rasqal_new_query(rasqal_world* world, const char *name, const unsigned char *uri);
1203 
1204 /* Destroy */
1205 RASQAL_API
1206 void rasqal_free_query(rasqal_query* query);
1207 
1208 /* Methods */
1209 RASQAL_API
1210 const char* rasqal_query_get_name(rasqal_query* query);
1211 RASQAL_API
1212 const char* rasqal_query_get_label(rasqal_query* query);
1213 
1214 
1215 RASQAL_API
1216 int rasqal_query_set_feature(rasqal_query* query, rasqal_feature feature, int value);
1217 RASQAL_API
1218 int rasqal_query_set_feature_string(rasqal_query *query, rasqal_feature feature, const unsigned char *value);
1219 RASQAL_API
1220 int rasqal_query_get_feature(rasqal_query *query, rasqal_feature feature);
1221 RASQAL_API
1222 const unsigned char* rasqal_query_get_feature_string(rasqal_query *query, rasqal_feature feature);
1223 
1224 RASQAL_API
1225 rasqal_query_verb rasqal_query_get_verb(rasqal_query* query);
1226 RASQAL_API
1227 int rasqal_query_get_wildcard(rasqal_query* query);
1228 RASQAL_API
1229 void rasqal_query_set_wildcard(rasqal_query* query, int wildcard);
1230 RASQAL_API
1231 int rasqal_query_get_distinct(rasqal_query* query);
1232 RASQAL_API
1233 void rasqal_query_set_distinct(rasqal_query* query, int distinct_mode);
1234 RASQAL_API
1235 int rasqal_query_get_explain(rasqal_query* query);
1236 RASQAL_API
1237 void rasqal_query_set_explain(rasqal_query* query, int is_explain);
1238 RASQAL_API
1239 int rasqal_query_get_limit(rasqal_query* query);
1240 RASQAL_API
1241 void rasqal_query_set_limit(rasqal_query* query, int limit);
1242 RASQAL_API
1243 int rasqal_query_get_offset(rasqal_query* query);
1244 RASQAL_API
1245 void rasqal_query_set_offset(rasqal_query* query, int offset);
1246 
1247 RASQAL_API
1248 int rasqal_query_add_data_graph(rasqal_query* query, rasqal_data_graph* data_graph);
1249 RASQAL_API
1250 int rasqal_query_add_data_graphs(rasqal_query* query, raptor_sequence* data_graphs);
1251 
1252 RASQAL_API
1253 raptor_sequence* rasqal_query_get_data_graph_sequence(rasqal_query* query);
1254 RASQAL_API
1255 rasqal_data_graph* rasqal_query_get_data_graph(rasqal_query* query, int idx);
1256 RASQAL_API
1257 int rasqal_query_dataset_contains_named_graph(rasqal_query* query, raptor_uri *graph_uri);
1258 
1259 RASQAL_API
1260 int rasqal_query_add_variable(rasqal_query* query, rasqal_variable* var);
1261 RASQAL_API
1262 raptor_sequence* rasqal_query_get_bound_variable_sequence(rasqal_query* query);
1263 RASQAL_API
1264 raptor_sequence* rasqal_query_get_describe_sequence(rasqal_query* query);
1265 RASQAL_API
1266 raptor_sequence* rasqal_query_get_anonymous_variable_sequence(rasqal_query* query);
1267 RASQAL_API
1268 raptor_sequence* rasqal_query_get_all_variable_sequence(rasqal_query* query);
1269 RASQAL_API
1270 rasqal_variable* rasqal_query_get_variable(rasqal_query* query, int idx);
1271 RASQAL_API
1272 int rasqal_query_has_variable2(rasqal_query* query, rasqal_variable_type type, const unsigned char *name);
1273 RASQAL_API RASQAL_DEPRECATED
1274 int rasqal_query_has_variable(rasqal_query* query, const unsigned char *name);
1275 RASQAL_API
1276 int rasqal_query_set_variable2(rasqal_query* query, rasqal_variable_type type, const unsigned char *name, rasqal_literal* value);
1277 RASQAL_API RASQAL_DEPRECATED
1278 int rasqal_query_set_variable(rasqal_query* query, const unsigned char *name, rasqal_literal* value);
1279 RASQAL_API
1280 raptor_sequence* rasqal_query_get_triple_sequence(rasqal_query* query);
1281 RASQAL_API
1282 rasqal_triple* rasqal_query_get_triple(rasqal_query* query, int idx);
1283 RASQAL_API
1284 int rasqal_query_add_prefix(rasqal_query* query, rasqal_prefix* prefix);
1285 RASQAL_API
1286 raptor_sequence* rasqal_query_get_prefix_sequence(rasqal_query* query);
1287 RASQAL_API
1288 rasqal_prefix* rasqal_query_get_prefix(rasqal_query* query, int idx);
1289 RASQAL_API
1290 raptor_sequence* rasqal_query_get_order_conditions_sequence(rasqal_query* query);
1291 RASQAL_API
1292 rasqal_expression* rasqal_query_get_order_condition(rasqal_query* query, int idx);
1293 RASQAL_API
1294 raptor_sequence* rasqal_query_get_group_conditions_sequence(rasqal_query* query);
1295 RASQAL_API
1296 rasqal_expression* rasqal_query_get_group_condition(rasqal_query* query, int idx);
1297 RASQAL_API
1298 raptor_sequence* rasqal_query_get_having_conditions_sequence(rasqal_query* query);
1299 RASQAL_API
1300 rasqal_expression* rasqal_query_get_having_condition(rasqal_query* query, int idx);
1301 RASQAL_API
1302 raptor_sequence* rasqal_query_get_construct_triples_sequence(rasqal_query* query);
1303 RASQAL_API
1304 rasqal_triple* rasqal_query_get_construct_triple(rasqal_query* query, int idx);
1305 RASQAL_API RASQAL_DEPRECATED
1306 void rasqal_query_graph_pattern_visit(rasqal_query* query, rasqal_graph_pattern_visit_fn visit_fn, void* data);
1307 RASQAL_API
1308 int rasqal_query_graph_pattern_visit2(rasqal_query* query, rasqal_graph_pattern_visit_fn visit_fn, void* data);
1309 RASQAL_API
1310 int rasqal_query_write(raptor_iostream* iostr, rasqal_query* query, raptor_uri* format_uri, raptor_uri* base_uri);
1311 
1312 /* update */
1313 RASQAL_API
1314 raptor_sequence* rasqal_query_get_update_operations_sequence(rasqal_query* query);
1315 RASQAL_API
1316 rasqal_update_operation* rasqal_query_get_update_operation(rasqal_query* query, int idx);
1317 
1318 /* results */
1319 int rasqal_query_set_store_results(rasqal_query* query, int store_results);
1320 
1321 /* graph patterns */
1322 RASQAL_API
1323 rasqal_graph_pattern* rasqal_query_get_query_graph_pattern(rasqal_query* query);
1324 RASQAL_API
1325 raptor_sequence* rasqal_query_get_graph_pattern_sequence(rasqal_query* query);
1326 RASQAL_API
1327 rasqal_graph_pattern* rasqal_query_get_graph_pattern(rasqal_query* query, int idx);
1328 RASQAL_API
1329 int rasqal_graph_pattern_add_sub_graph_pattern(rasqal_graph_pattern* graph_pattern, rasqal_graph_pattern* sub_graph_pattern);
1330 RASQAL_API
1331 rasqal_triple* rasqal_graph_pattern_get_triple(rasqal_graph_pattern* graph_pattern, int idx);
1332 RASQAL_API
1333 raptor_sequence* rasqal_graph_pattern_get_sub_graph_pattern_sequence(rasqal_graph_pattern* graph_pattern);
1334 RASQAL_API
1335 rasqal_graph_pattern* rasqal_graph_pattern_get_sub_graph_pattern(rasqal_graph_pattern* graph_pattern, int idx);
1336 RASQAL_API
1337 rasqal_graph_pattern_operator rasqal_graph_pattern_get_operator(rasqal_graph_pattern* graph_pattern);
1338 RASQAL_API
1339 const char* rasqal_graph_pattern_operator_as_string(rasqal_graph_pattern_operator op);
1340 RASQAL_API
1341 int rasqal_graph_pattern_print(rasqal_graph_pattern* gp, FILE* fh);
1342 RASQAL_API
1343 int rasqal_graph_pattern_set_filter_expression(rasqal_graph_pattern* gp, rasqal_expression* expr);
1344 RASQAL_API
1345 rasqal_expression* rasqal_graph_pattern_get_filter_expression(rasqal_graph_pattern* gp);
1346 RASQAL_API
1347 int rasqal_graph_pattern_visit(rasqal_query* query, rasqal_graph_pattern *gp, rasqal_graph_pattern_visit_fn fn, void* user_data);
1348 RASQAL_API
1349 int rasqal_graph_pattern_get_index(rasqal_graph_pattern* gp);
1350 RASQAL_API
1351 int rasqal_graph_pattern_variable_bound_in(rasqal_graph_pattern *gp, rasqal_variable *v);
1352 RASQAL_API
1353 rasqal_literal* rasqal_graph_pattern_get_origin(rasqal_graph_pattern* graph_pattern);
1354 RASQAL_API
1355 rasqal_variable* rasqal_graph_pattern_get_variable(rasqal_graph_pattern* graph_pattern);
1356 RASQAL_API
1357 rasqal_literal* rasqal_graph_pattern_get_service(rasqal_graph_pattern* graph_pattern);
1358 RASQAL_API
1359 raptor_sequence* rasqal_graph_pattern_get_flattened_triples(rasqal_query* query, rasqal_graph_pattern* graph_pattern);
1360 RASQAL_API
1361 raptor_sequence* rasqal_graph_pattern_get_triples(rasqal_query* query, rasqal_graph_pattern* graph_pattern);
1362 
1363 
1364 /* Utility methods */
1365 RASQAL_API
1366 const char* rasqal_query_verb_as_string(rasqal_query_verb verb);
1367 RASQAL_API
1368 int rasqal_query_print(rasqal_query* query, FILE* fh);
1369 
1370 /* Query */
1371 RASQAL_API
1372 int rasqal_query_prepare(rasqal_query* query, const unsigned char *query_string, raptor_uri *base_uri);
1373 RASQAL_API
1374 rasqal_query_results* rasqal_query_execute(rasqal_query* query);
1375 
1376 RASQAL_API
1377 void* rasqal_query_get_user_data(rasqal_query* query);
1378 RASQAL_API
1379 void rasqal_query_set_user_data(rasqal_query* query, void *user_data);
1380 
1381 RASQAL_API
1382 raptor_sequence* rasqal_query_get_bindings_variables_sequence(rasqal_query* query);
1383 RASQAL_API
1384 rasqal_variable* rasqal_query_get_bindings_variable(rasqal_query* query, int idx);
1385 RASQAL_API
1386 raptor_sequence* rasqal_query_get_bindings_rows_sequence(rasqal_query* query);
1387 RASQAL_API
1388 rasqal_row* rasqal_query_get_bindings_row(rasqal_query* query, int idx);
1389 RASQAL_API
1390 rasqal_query_results_type rasqal_query_get_result_type(rasqal_query* query);
1391 
1392 /* query results */
1393 RASQAL_API
1394 rasqal_query_results* rasqal_new_query_results2(rasqal_world* world, rasqal_query* query, rasqal_query_results_type type);
1395 RASQAL_API RASQAL_DEPRECATED
1396 rasqal_query_results* rasqal_new_query_results(rasqal_world* world, rasqal_query* query, rasqal_query_results_type type, rasqal_variables_table* vars_table);
1397 RASQAL_API
1398 rasqal_query_results* rasqal_new_query_results_from_string(rasqal_world* world, rasqal_query_results_type type, raptor_uri* base_uri, const char* string, size_t string_len);
1399 RASQAL_API
1400 void rasqal_free_query_results(rasqal_query_results *query_results);
1401 
1402 RASQAL_API
1403 rasqal_query* rasqal_query_results_get_query(rasqal_query_results* query_results);
1404 
1405 /* Bindings result format */
1406 RASQAL_API
1407 rasqal_query_results_type rasqal_query_results_get_type(rasqal_query_results* query_results);
1408 RASQAL_API
1409 const char* rasqal_query_results_type_label(rasqal_query_results_type type);
1410 RASQAL_API
1411 int rasqal_query_results_is_bindings(rasqal_query_results *query_results);
1412 RASQAL_API
1413 int rasqal_query_results_get_count(rasqal_query_results *query_results);
1414 RASQAL_API
1415 int rasqal_query_results_next(rasqal_query_results *query_results);
1416 RASQAL_API
1417 int rasqal_query_results_finished(rasqal_query_results *query_results);
1418 RASQAL_API
1419 int rasqal_query_results_get_bindings(rasqal_query_results *query_results, const unsigned char ***names, rasqal_literal ***values);
1420 RASQAL_API
1421 rasqal_literal* rasqal_query_results_get_binding_value(rasqal_query_results *query_results, int offset);
1422 RASQAL_API
1423 const unsigned char* rasqal_query_results_get_binding_name(rasqal_query_results *query_results, int offset);
1424 RASQAL_API
1425 rasqal_literal* rasqal_query_results_get_binding_value_by_name(rasqal_query_results *query_results, const unsigned char *name);
1426 RASQAL_API
1427 int rasqal_query_results_get_bindings_count(rasqal_query_results *query_results);
1428 RASQAL_API
1429 int rasqal_query_results_add_row(rasqal_query_results* query_results, rasqal_row* row);
1430 RASQAL_API
1431 rasqal_row* rasqal_query_results_get_row_by_offset(rasqal_query_results* query_results, int result_offset);
1432 
1433 /* Boolean result format */
1434 RASQAL_API
1435 int rasqal_query_results_is_boolean(rasqal_query_results *query_results);
1436 RASQAL_API
1437 int rasqal_query_results_get_boolean(rasqal_query_results *query_results);
1438 
1439 /* Graph result format */
1440 RASQAL_API
1441 int rasqal_query_results_is_graph(rasqal_query_results *query_results);
1442 RASQAL_API
1443 raptor_statement* rasqal_query_results_get_triple(rasqal_query_results *query_results);
1444 RASQAL_API
1445 int rasqal_query_results_next_triple(rasqal_query_results *query_results);
1446 
1447 /* Syntax result format */
1448 RASQAL_API
1449 int rasqal_query_results_is_syntax(rasqal_query_results* query_results);
1450 
1451 RASQAL_API
1452 int rasqal_query_results_write(raptor_iostream *iostr, rasqal_query_results *results, const char* name, const char* mime_type, raptor_uri *format_uri, raptor_uri *base_uri);
1453 RASQAL_API
1454 int rasqal_query_results_read(raptor_iostream *iostr, rasqal_query_results *results, const char* name, const char* mime_type, raptor_uri *format_uri, raptor_uri *base_uri);
1455 
1456 /* One more time */
1457 RASQAL_API
1458 int rasqal_query_results_rewind(rasqal_query_results* query_results);
1459 
1460 
1461 /**
1462  * rasqal_query_results_format_flags:
1463  * @RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER: format can be read.
1464  * @RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER: format can be written.
1465  *
1466  * Bitflags for rasqal_query_results_formats_check() to find formats with features.
1467  */
1468 typedef enum {
1469   RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER = 1,
1470   RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER = 2
1471 } rasqal_query_results_format_flags;
1472 
1473 
1474 RASQAL_API
1475 int rasqal_query_results_formats_check2(rasqal_world* world, const char *name, raptor_uri* uri, const char *mime_type, int flags);
1476 RASQAL_API RASQAL_DEPRECATED
1477 int rasqal_query_results_formats_check(rasqal_world* world, const char *name, raptor_uri* uri, const char *mime_type, int flags);
1478 RASQAL_API
1479 rasqal_query_results_formatter* rasqal_new_query_results_formatter(rasqal_world* world, const char *name, const char *mime_type, raptor_uri* format_uri);
1480 RASQAL_API
1481 rasqal_query_results_formatter* rasqal_new_query_results_formatter_for_content(rasqal_world* world, raptor_uri *uri, const char *mime_type, const unsigned char *buffer, size_t len, const unsigned char *identifier);
1482 RASQAL_API
1483 void rasqal_free_query_results_formatter(rasqal_query_results_formatter* formatter);
1484 RASQAL_API
1485 int rasqal_query_results_formatter_write(raptor_iostream *iostr, rasqal_query_results_formatter* formatter, rasqal_query_results* results, raptor_uri *base_uri);
1486 RASQAL_API
1487 int rasqal_query_results_formatter_read(rasqal_world* world, raptor_iostream *iostr, rasqal_query_results_formatter* formatter, rasqal_query_results* results, raptor_uri *base_uri);
1488 
1489 RASQAL_API
1490 int rasqal_query_iostream_write_escaped_counted_string(rasqal_query* query, raptor_iostream* iostr, const unsigned char* string, size_t len);
1491 RASQAL_API
1492 unsigned char* rasqal_query_escape_counted_string(rasqal_query* query, const unsigned char *string, size_t len, size_t* output_len_p);
1493 
1494 
1495 /* Data graph class */
1496 RASQAL_API
1497 rasqal_data_graph* rasqal_new_data_graph_from_uri(rasqal_world* world, raptor_uri* uri, raptor_uri* name_uri, unsigned int flags, const char* format_type, const char* format_name, raptor_uri* format_uri);
1498 RASQAL_API
1499 rasqal_data_graph* rasqal_new_data_graph_from_iostream(rasqal_world* world, raptor_iostream* iostr, raptor_uri* base_uri, raptor_uri* name_uri, unsigned int flags, const char* format_type, const char* format_name, raptor_uri* format_uri);
1500 RASQAL_API
1501 rasqal_data_graph* rasqal_new_data_graph_from_data_graph(rasqal_data_graph* dg);
1502 RASQAL_API
1503 void rasqal_free_data_graph(rasqal_data_graph* dg);
1504 RASQAL_API
1505 int rasqal_data_graph_print(rasqal_data_graph* dg, FILE* fh);
1506 
1507 
1508 /**
1509  * rasqal_compare_flags:
1510  * @RASQAL_COMPARE_NOCASE: String comparisons are case independent.
1511  * @RASQAL_COMPARE_XQUERY: XQuery comparsion rules apply.
1512  * @RASQAL_COMPARE_RDF:    RDF Term comparsion rules apply.
1513  * @RASQAL_COMPARE_URI:    Allow comparison of URIs and allow strings to have a boolean value (unused; was for RDQL)
1514  * @RASQAL_COMPARE_SAMETERM: SPARQL sameTerm() builtin rules apply.
1515  *
1516  * Flags for rasqal_expression_evaluate(), rasqal_literal_compare() or
1517  * rasqal_literal_as_string_flags()
1518  */
1519 typedef enum {
1520   RASQAL_COMPARE_NOCASE = 1,
1521   RASQAL_COMPARE_XQUERY = 2,
1522   RASQAL_COMPARE_RDF    = 4,
1523   RASQAL_COMPARE_URI    = 8,
1524   RASQAL_COMPARE_SAMETERM = 16
1525 } rasqal_compare_flags;
1526 
1527 
1528 /**
1529  * rasqal_random:
1530  *
1531  * Internal
1532  */
1533 typedef struct rasqal_random_s rasqal_random;
1534 
1535 
1536 /**
1537  * rasqal_evaluation_context:
1538  * @world: rasqal world
1539  * @base_uri: base URI of expression context (or NULL)
1540  * @locator: locator or NULL
1541  * @flags: expression comparison flags
1542  * @seed: random seeed
1543  * @random: random number generator object
1544  *
1545  * A context for evaluating an expression such as with
1546  * rasqal_expression_evaluate2()
1547  */
1548 typedef struct {
1549   rasqal_world *world;
1550   raptor_uri* base_uri;
1551   raptor_locator *locator;
1552   int flags;
1553   unsigned int seed;
1554   rasqal_random* random;
1555 } rasqal_evaluation_context;
1556 
1557 
1558 /* Expression class */
1559 RASQAL_API
1560 rasqal_expression* rasqal_new_0op_expression(rasqal_world* world, rasqal_op op);
1561 RASQAL_API
1562 rasqal_expression* rasqal_new_1op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg);
1563 RASQAL_API
1564 rasqal_expression* rasqal_new_2op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2);
1565 RASQAL_API
1566 rasqal_expression* rasqal_new_3op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1,  rasqal_expression* arg2, rasqal_expression* arg3);
1567 RASQAL_API
1568 rasqal_expression* rasqal_new_4op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2, rasqal_expression* arg3, rasqal_expression* arg4);
1569 RASQAL_API
1570 rasqal_expression* rasqal_new_string_op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_literal* literal);
1571 RASQAL_API
1572 rasqal_expression* rasqal_new_literal_expression(rasqal_world* world, rasqal_literal* literal);
1573 RASQAL_API
1574 rasqal_expression* rasqal_new_function_expression(rasqal_world* world, raptor_uri* name, raptor_sequence* args, raptor_sequence* params, unsigned int flags);
1575 RASQAL_API
1576 rasqal_expression* rasqal_new_aggregate_function_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, raptor_sequence* params, unsigned int flags);
1577 RASQAL_API
1578 rasqal_expression* rasqal_new_cast_expression(rasqal_world* world, raptor_uri* name, rasqal_expression *value);
1579 RASQAL_API
1580 rasqal_expression* rasqal_new_expr_seq_expression(rasqal_world* world, rasqal_op op, raptor_sequence* args);
1581 RASQAL_API
1582 rasqal_expression* rasqal_new_set_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, raptor_sequence* args);
1583 RASQAL_API
1584 rasqal_expression* rasqal_new_group_concat_expression(rasqal_world* world, unsigned int flags, raptor_sequence* args, rasqal_literal* separator);
1585 RASQAL_API
1586 rasqal_expression* rasqal_new_expression_from_expression(rasqal_expression* e);
1587 
1588 RASQAL_API
1589 void rasqal_free_expression(rasqal_expression* e);
1590 RASQAL_API
1591 void rasqal_expression_print_op(rasqal_expression* e, FILE* fh);
1592 RASQAL_API
1593 int rasqal_expression_print(rasqal_expression* e, FILE* fh);
1594 RASQAL_API RASQAL_DEPRECATED
1595 rasqal_literal* rasqal_expression_evaluate(rasqal_world *world, raptor_locator *locator, rasqal_expression* e, int flags);
1596 RASQAL_API
1597 rasqal_literal* rasqal_expression_evaluate2(rasqal_expression *e, rasqal_evaluation_context* eval_context, int *error_p);
1598 RASQAL_API
1599 const char* rasqal_expression_op_label(rasqal_op op);
1600 RASQAL_API
1601 int rasqal_expression_compare(rasqal_expression* e1, rasqal_expression* e2, int flags, int* error_p);
1602 
1603 /**
1604  * rasqal_expression_visit_fn:
1605  * @user_data: user data passed in with rasqal_expression_visit()
1606  * @e: current expression
1607  *
1608  * User function to visit an expression and operate on it with
1609  * rasqal_expression_visit()
1610  *
1611  * Return value: non-0 to truncate the visit
1612  */
1613 typedef int (*rasqal_expression_visit_fn)(void *user_data, rasqal_expression *e);
1614 RASQAL_API
1615 int rasqal_expression_visit(rasqal_expression* e, rasqal_expression_visit_fn fn, void *user_data);
1616 
1617 RASQAL_API
1618 rasqal_evaluation_context* rasqal_new_evaluation_context(rasqal_world* world, raptor_locator* locator, int flags);
1619 RASQAL_API
1620 void rasqal_free_evaluation_context(rasqal_evaluation_context* eval_context);
1621 RASQAL_API
1622 int rasqal_evaluation_context_set_base_uri(rasqal_evaluation_context* eval_context, raptor_uri *base_uri);
1623 RASQAL_API
1624 int rasqal_evaluation_context_set_rand_seed(rasqal_evaluation_context* eval_context, unsigned int seed);
1625 
1626 
1627 /* Literal class */
1628 RASQAL_API
1629 rasqal_literal* rasqal_new_integer_literal(rasqal_world* world, rasqal_literal_type type, int integer);
1630 RASQAL_API
1631 rasqal_literal* rasqal_new_numeric_literal_from_long(rasqal_world* world, rasqal_literal_type type, long value);
1632 RASQAL_API
1633 rasqal_literal* rasqal_new_typed_literal(rasqal_world* world, rasqal_literal_type type, const unsigned char* string);
1634 RASQAL_API
1635 rasqal_literal* rasqal_new_double_literal(rasqal_world* world, double d);
1636 RASQAL_API
1637 rasqal_literal* rasqal_new_floating_literal(rasqal_world *world, rasqal_literal_type type, double d);
1638 RASQAL_API RASQAL_DEPRECATED
1639 rasqal_literal* rasqal_new_float_literal(rasqal_world* world, float f);
1640 RASQAL_API
1641 rasqal_literal* rasqal_new_uri_literal(rasqal_world* world, raptor_uri* uri);
1642 RASQAL_API
1643 rasqal_literal* rasqal_new_pattern_literal(rasqal_world* world, const unsigned char *pattern, const char *flags);
1644 RASQAL_API
1645 rasqal_literal* rasqal_new_string_literal(rasqal_world* world, const unsigned char *string, const char *language, raptor_uri *datatype, const unsigned char *datatype_qname);
1646 RASQAL_API
1647 rasqal_literal* rasqal_new_simple_literal(rasqal_world* world, rasqal_literal_type type, const unsigned char *string);
1648 RASQAL_API
1649 rasqal_literal* rasqal_new_boolean_literal(rasqal_world* world, int value);
1650 RASQAL_API
1651 rasqal_literal* rasqal_new_variable_literal(rasqal_world* world, rasqal_variable *variable);
1652 RASQAL_API
1653 rasqal_literal* rasqal_new_decimal_literal(rasqal_world* world, const unsigned char *string);
1654 RASQAL_API
1655 rasqal_literal* rasqal_new_decimal_literal_from_decimal(rasqal_world* world, const unsigned char *string, rasqal_xsd_decimal* decimal);
1656 RASQAL_API
1657 rasqal_literal* rasqal_new_datetime_literal_from_datetime(rasqal_world* world, rasqal_xsd_datetime* dt);
1658 
1659 
1660 RASQAL_API
1661 rasqal_literal* rasqal_new_literal_from_literal(rasqal_literal* l);
1662 RASQAL_API
1663 void rasqal_free_literal(rasqal_literal* l);
1664 RASQAL_API
1665 int rasqal_literal_print(rasqal_literal* l, FILE* fh);
1666 RASQAL_API
1667 const char* rasqal_literal_type_label(rasqal_literal_type type);
1668 RASQAL_API
1669 void rasqal_literal_print_type(rasqal_literal* l, FILE* fh);
1670 RASQAL_API
1671 rasqal_variable* rasqal_literal_as_variable(rasqal_literal* l);
1672 RASQAL_API
1673 const unsigned char* rasqal_literal_as_counted_string(rasqal_literal* l, size_t *len_p, int flags, int *error_p);
1674 RASQAL_API
1675 const unsigned char* rasqal_literal_as_string(rasqal_literal* l);
1676 RASQAL_API
1677 const unsigned char* rasqal_literal_as_string_flags(rasqal_literal* l, int flags, int *error_p);
1678 RASQAL_API
1679 rasqal_literal* rasqal_literal_as_node(rasqal_literal* l);
1680 RASQAL_API
1681 raptor_uri* rasqal_literal_datatype(rasqal_literal* l);
1682 RASQAL_API
1683 rasqal_literal* rasqal_literal_value(rasqal_literal* l);
1684 
1685 RASQAL_API
1686 int rasqal_literal_compare(rasqal_literal* l1, rasqal_literal* l2, int flags, int *error_p);
1687 RASQAL_API
1688 int rasqal_literal_equals(rasqal_literal* l1, rasqal_literal* l2);
1689 RASQAL_API
1690 int rasqal_literal_same_term(rasqal_literal* l1, rasqal_literal* l2);
1691 RASQAL_API
1692 rasqal_literal_type rasqal_literal_get_rdf_term_type(rasqal_literal* l);
1693 RASQAL_API
1694 rasqal_literal_type rasqal_literal_get_type(rasqal_literal* l);
1695 RASQAL_API
1696 char* rasqal_literal_get_language(rasqal_literal* l);
1697 RASQAL_API
1698 int rasqal_literal_is_rdf_literal(rasqal_literal* l);
1699 
1700 
1701 RASQAL_API
1702 rasqal_prefix* rasqal_new_prefix(rasqal_world* world, const unsigned char* prefix, raptor_uri* uri);
1703 RASQAL_API
1704 void rasqal_free_prefix(rasqal_prefix* p);
1705 RASQAL_API
1706 int rasqal_prefix_print(rasqal_prefix* p, FILE* fh);
1707 
1708 
1709 /* Row class */
1710 RASQAL_API
1711 rasqal_row* rasqal_new_row_for_size(rasqal_world* world, int size);
1712 RASQAL_API
1713 void rasqal_free_row(rasqal_row* row);
1714 RASQAL_API
1715 int rasqal_row_set_value_at(rasqal_row* row, int offset, rasqal_literal* value);
1716 
1717 
1718 /* Triple class */
1719 RASQAL_API
1720 rasqal_triple* rasqal_new_triple(rasqal_literal* subject, rasqal_literal* predicate, rasqal_literal* object);
1721 RASQAL_API
1722 rasqal_triple* rasqal_new_triple_from_triple(rasqal_triple* t);
1723 RASQAL_API
1724 void rasqal_free_triple(rasqal_triple* t);
1725 RASQAL_API
1726 int rasqal_triple_print(rasqal_triple* t, FILE* fh);
1727 RASQAL_API
1728 void rasqal_triple_set_origin(rasqal_triple* t, rasqal_literal *l);
1729 RASQAL_API
1730 rasqal_literal* rasqal_triple_get_origin(rasqal_triple* t);
1731 
1732 /* Variable class */
1733 RASQAL_API
1734 rasqal_variable* rasqal_new_variable_from_variable(rasqal_variable* v);
1735 RASQAL_API
1736 void rasqal_free_variable(rasqal_variable* v);
1737 RASQAL_API
1738 int rasqal_variable_print(rasqal_variable* v, FILE* fh);
1739 RASQAL_API
1740 void rasqal_variable_set_value(rasqal_variable* v, rasqal_literal* l);
1741 
1742 
1743 /* Variables Table */
1744 RASQAL_API
1745 rasqal_variables_table* rasqal_new_variables_table(rasqal_world* world);
1746 RASQAL_API
1747 void rasqal_free_variables_table(rasqal_variables_table* vt);
1748 RASQAL_API RASQAL_DEPRECATED
1749 rasqal_variable* rasqal_variables_table_add(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name, rasqal_literal *value);
1750 RASQAL_API
1751 rasqal_variable* rasqal_variables_table_add2(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name, size_t name_len, rasqal_literal *value);
1752 RASQAL_API
1753 int rasqal_variables_table_add_variable(rasqal_variables_table* vt, rasqal_variable* variable);
1754 RASQAL_API
1755 rasqal_variable* rasqal_variables_table_get_by_name(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name);
1756 RASQAL_API
1757 int rasqal_variables_table_contains(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name);
1758 
1759 /* memory functions */
1760 RASQAL_API
1761 void rasqal_free_memory(void *ptr);
1762 RASQAL_API
1763 void* rasqal_alloc_memory(size_t size);
1764 RASQAL_API
1765 void* rasqal_calloc_memory(size_t nmemb, size_t size);
1766 
1767 
1768 /* decimal functions */
1769 RASQAL_API
1770 rasqal_xsd_decimal* rasqal_new_xsd_decimal(rasqal_world* world);
1771 RASQAL_API
1772 void rasqal_free_xsd_decimal(rasqal_xsd_decimal* dec);
1773 RASQAL_API
1774 int rasqal_xsd_decimal_set_string(rasqal_xsd_decimal* dec, const char* string);
1775 RASQAL_API
1776 double rasqal_xsd_decimal_get_double(rasqal_xsd_decimal* dec);
1777 RASQAL_API
1778 long rasqal_xsd_decimal_get_long(rasqal_xsd_decimal* dec, int* error_p);
1779 RASQAL_API
1780 char* rasqal_xsd_decimal_as_string(rasqal_xsd_decimal* dec);
1781 RASQAL_API
1782 char* rasqal_xsd_decimal_as_counted_string(rasqal_xsd_decimal* dec, size_t* len_p);
1783 RASQAL_API
1784 int rasqal_xsd_decimal_set_long(rasqal_xsd_decimal* dec, long l);
1785 RASQAL_API
1786 int rasqal_xsd_decimal_set_double(rasqal_xsd_decimal* dec, double d);
1787 RASQAL_API
1788 int rasqal_xsd_decimal_print(rasqal_xsd_decimal* dec, FILE* stream);
1789 RASQAL_API
1790 int rasqal_xsd_decimal_add(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1791 RASQAL_API
1792 int rasqal_xsd_decimal_subtract(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1793 RASQAL_API
1794 int rasqal_xsd_decimal_multiply(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1795 RASQAL_API
1796 int rasqal_xsd_decimal_divide(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1797 RASQAL_API
1798 int rasqal_xsd_decimal_negate(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1799 RASQAL_API
1800 int rasqal_xsd_decimal_compare(rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1801 RASQAL_API
1802 int rasqal_xsd_decimal_equals(rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1803 RASQAL_API
1804 int rasqal_xsd_decimal_is_zero(rasqal_xsd_decimal* d);
1805 RASQAL_API
1806 int rasqal_xsd_decimal_abs(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1807 RASQAL_API
1808 int rasqal_xsd_decimal_round(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1809 RASQAL_API
1810 int rasqal_xsd_decimal_ceil(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1811 RASQAL_API
1812 int rasqal_xsd_decimal_floor(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1813 
1814 
1815 /* date functions */
1816 RASQAL_API
1817 rasqal_xsd_date* rasqal_new_xsd_date(rasqal_world* world, const char *date_string);
1818 RASQAL_API
1819 void rasqal_free_xsd_date(rasqal_xsd_date* d);
1820 RASQAL_API
1821 char* rasqal_xsd_date_to_counted_string(const rasqal_xsd_date *date, size_t *len_p);
1822 RASQAL_API
1823 char* rasqal_xsd_date_to_string(const rasqal_xsd_date *d);
1824 RASQAL_API
1825 int rasqal_xsd_date_equals(const rasqal_xsd_date *d1, const rasqal_xsd_date *d2, int *incomparible_p);
1826 RASQAL_API
1827 int rasqal_xsd_date_compare(const rasqal_xsd_date *d1, const rasqal_xsd_date *d2, int *incomparible_p);
1828 
1829 /* datetime functions */
1830 RASQAL_API
1831 rasqal_xsd_datetime* rasqal_new_xsd_datetime(rasqal_world* world, const char *datetime_string);
1832 RASQAL_API
1833 rasqal_xsd_datetime* rasqal_new_xsd_datetime_from_unixtime(rasqal_world* world, time_t secs);
1834 RASQAL_API
1835 rasqal_xsd_datetime* rasqal_new_xsd_datetime_from_timeval(rasqal_world* world, struct timeval *tv);
1836 RASQAL_API
1837 rasqal_xsd_datetime* rasqal_new_xsd_datetime_from_xsd_date(rasqal_world* world, rasqal_xsd_date *date);
1838 RASQAL_API
1839 void rasqal_free_xsd_datetime(rasqal_xsd_datetime* dt);
1840 RASQAL_API
1841 char* rasqal_xsd_datetime_to_counted_string(const rasqal_xsd_datetime *dt, size_t *len_p);
1842 RASQAL_API
1843 char* rasqal_xsd_datetime_to_string(const rasqal_xsd_datetime *dt);
1844 RASQAL_API
1845 int rasqal_xsd_datetime_equals2(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2, int *incomparible_p);
1846 RASQAL_API RASQAL_DEPRECATED
1847 int rasqal_xsd_datetime_equals(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2);
1848 RASQAL_API
1849 int rasqal_xsd_datetime_compare2(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2, int *incomparible_p);
1850 RASQAL_API RASQAL_DEPRECATED
1851 int rasqal_xsd_datetime_compare(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2);
1852 RASQAL_API
1853 rasqal_xsd_decimal* rasqal_xsd_datetime_get_seconds_as_decimal(rasqal_world* world, rasqal_xsd_datetime* dt);
1854 RASQAL_API
1855 int rasqal_xsd_datetime_set_from_timeval(rasqal_xsd_datetime *dt, struct timeval *tv);
1856 RASQAL_API
1857 int rasqal_xsd_datetime_set_from_unixtime(rasqal_xsd_datetime* dt, time_t clock);
1858 RASQAL_API
1859 time_t rasqal_xsd_datetime_get_as_unixtime(rasqal_xsd_datetime* dt);
1860 RASQAL_API
1861 struct timeval* rasqal_xsd_datetime_get_as_timeval(rasqal_xsd_datetime *dt);
1862 RASQAL_API
1863 char* rasqal_xsd_datetime_get_timezone_as_counted_string(rasqal_xsd_datetime *dt, size_t *len_p);
1864 RASQAL_API
1865 char* rasqal_xsd_datetime_get_tz_as_counted_string(rasqal_xsd_datetime* dt, size_t *len_p);
1866 
1867 
1868 /* regex utilities */
1869 RASQAL_API
1870 char* rasqal_regex_replace(rasqal_world* world, raptor_locator* locator, const char* pattern, const char* regex_flags, const char* subject, size_t subject_len, const char* replace, size_t replace_len, size_t* result_len_p);
1871 
1872 
1873 /**
1874  * rasqal_service:
1875  *
1876  * Rasqal SPARQL Protocol Service
1877  */
1878 typedef struct rasqal_service_s rasqal_service;
1879 
1880 RASQAL_API
1881 rasqal_service* rasqal_new_service(rasqal_world* world, raptor_uri* service_uri, const unsigned char* query_string, raptor_sequence* data_graphs);
1882 RASQAL_API
1883 void rasqal_free_service(rasqal_service* svc);
1884 RASQAL_API
1885 rasqal_query_results* rasqal_service_execute(rasqal_service* svc);
1886 RASQAL_API
1887 int rasqal_service_set_www(rasqal_service* svc, raptor_www* www);
1888 RASQAL_API
1889 int rasqal_service_set_format(rasqal_service* svc, const char *format);
1890 
1891 
1892 
1893 /**
1894  * rasqal_triple_parts:
1895  * @RASQAL_TRIPLE_NONE: no parts
1896  * @RASQAL_TRIPLE_SUBJECT: Subject present in a triple.
1897  * @RASQAL_TRIPLE_PREDICATE: Predicate present in a triple.
1898  * @RASQAL_TRIPLE_OBJECT: Object present in a triple.
1899  * @RASQAL_TRIPLE_ORIGIN: Origin/graph present in a triple.
1900  * @RASQAL_TRIPLE_GRAPH:  Alias for RASQAL_TRIPLE_ORIGIN
1901  * @RASQAL_TRIPLE_SPO: Subject, Predicate and Object present in a triple.
1902  * @RASQAL_TRIPLE_SPOG: Subject, Predicate, Object, Graph present in a triple.
1903  *
1904  * Flags for parts of a triple.
1905  */
1906 typedef enum {
1907   RASQAL_TRIPLE_NONE     = 0,
1908   RASQAL_TRIPLE_SUBJECT  = 1,
1909   RASQAL_TRIPLE_PREDICATE= 2,
1910   RASQAL_TRIPLE_OBJECT   = 4,
1911   RASQAL_TRIPLE_ORIGIN   = 8,
1912   RASQAL_TRIPLE_GRAPH    = RASQAL_TRIPLE_ORIGIN,
1913   RASQAL_TRIPLE_SPO      = RASQAL_TRIPLE_SUBJECT | RASQAL_TRIPLE_PREDICATE | RASQAL_TRIPLE_OBJECT,
1914   RASQAL_TRIPLE_SPOG     = RASQAL_TRIPLE_SPO | RASQAL_TRIPLE_GRAPH
1915 } rasqal_triple_parts;
1916 
1917 
1918 
1919 /**
1920  * rasqal_triples_match:
1921  * @world: rasqal_world object
1922  * @user_data: User data pointer for factory methods.
1923  * @bind_match: The [4]array (s,p,o,origin) bindings against the current triple match only touching triple parts given. Returns parts that were bound or 0 on failure.
1924  * @next_match: Move to next match.
1925  * @is_end: Check for end of triple match - return non-0 if is end.
1926  * @finish: Finish triples match and destroy any allocated memory.
1927  * @is_exact: non-0 if triple to match is all literal constants
1928  * @finished: >0 if the match has finished
1929  *
1930  * Triples match structure as initialised by #rasqal_triples_source
1931  * method init_triples_match.
1932  */
1933 struct rasqal_triples_match_s {
1934   rasqal_world *world;
1935 
1936   void *user_data;
1937 
1938   rasqal_triple_parts (*bind_match)(struct rasqal_triples_match_s* rtm, void *user_data, rasqal_variable *bindings[4], rasqal_triple_parts parts);
1939 
1940   void (*next_match)(struct rasqal_triples_match_s* rtm, void *user_data);
1941 
1942   int (*is_end)(struct rasqal_triples_match_s* rtm, void *user_data);
1943 
1944   void (*finish)(struct rasqal_triples_match_s* rtm, void *user_data);
1945 
1946   int is_exact;
1947 
1948   int finished;
1949 };
1950 typedef struct rasqal_triples_match_s rasqal_triples_match;
1951 
1952 
1953 /**
1954  * rasqal_triple_meta:
1955  * @bindings: Variable bindings for this triple+origin to set.
1956  * @triples_match: The matcher that is setting these bindings.
1957  * @context: Context data used by the matcher.
1958  * @parts: Bitmask of #rasqal_triple_parts flags describing the parts of the triple pattern that will bind to variables.  There may also be variables mentioned that are bound in other triple patterns even if @parts is 0.
1959  * @is_exact: unused
1960  * @executed: unused
1961  *
1962  * Metadata for triple pattern matching for one triple pattern.
1963  */
1964 typedef struct {
1965   /* triple (subject, predicate, object) and origin */
1966   rasqal_variable* bindings[4];
1967 
1968   rasqal_triples_match *triples_match;
1969 
1970   void *context;
1971 
1972   rasqal_triple_parts parts;
1973 
1974   int is_exact;
1975 
1976   int executed;
1977 } rasqal_triple_meta;
1978 
1979 
1980 /**
1981  * RASQAL_TRIPLES_SOURCE_MIN_VERSION:
1982  *
1983  * Lowest accepted @rasqal_triples_source API version
1984  */
1985 #define RASQAL_TRIPLES_SOURCE_MIN_VERSION 1
1986 
1987 /**
1988  * RASQAL_TRIPLES_SOURCE_MAX_VERSION:
1989  *
1990  * Highest accepted @rasqal_triples_source API version
1991  */
1992 #define RASQAL_TRIPLES_SOURCE_MAX_VERSION 2
1993 
1994 
1995 /**
1996  * rasqal_triples_source_feature:
1997  * @RASQAL_TRIPLES_SOURCE_FEATURE_NONE: No feature
1998  * @RASQAL_TRIPLES_SOURCE_FEATURE_IOSTREAM_DATA_GRAPH: Support raptor_iostream data graphs
1999  *
2000  * Optional features that may be supported by a triple source factory
2001  */
2002 typedef enum {
2003   RASQAL_TRIPLES_SOURCE_FEATURE_NONE,
2004   RASQAL_TRIPLES_SOURCE_FEATURE_IOSTREAM_DATA_GRAPH
2005 } rasqal_triples_source_feature;
2006 
2007 
2008 /**
2009  * rasqal_triples_source:
2010  * @version: API version - only V1 is defined for now
2011  * @query: Source for this query.
2012  * @user_data: Context user data passed into the factory methods.
2013  * @init_triples_match: Factory method to initialize a new #rasqal_triples_match.
2014  * @triple_present: Factory method to return presence or absence of a complete triple.
2015  * @free_triples_source: Factory method to deallocate resources.
2016  * @support_feature: Factory method to test support for a feature, returning non-0 if supported
2017  *
2018  * Triples source as initialised by a #rasqal_triples_source_factory.
2019  */
2020 struct rasqal_triples_source_s {
2021   int version;
2022 
2023   rasqal_query* query;
2024 
2025   void *user_data;
2026 
2027   /* API v1 */
2028   int (*init_triples_match)(rasqal_triples_match* rtm, struct rasqal_triples_source_s* rts, void *user_data, rasqal_triple_meta *m, rasqal_triple *t);
2029 
2030   int (*triple_present)(struct rasqal_triples_source_s* rts, void *user_data, rasqal_triple *t);
2031 
2032   void (*free_triples_source)(void *user_data);
2033 
2034   /* API v2 onwards */
2035   int (*support_feature)(void *user_data, rasqal_triples_source_feature feature);
2036 };
2037 typedef struct rasqal_triples_source_s rasqal_triples_source;
2038 
2039 
2040 /**
2041  * RASQAL_TRIPLES_SOURCE_FACTORY_MIN_VERSION:
2042  *
2043  * Lowest accepted @rasqal_triples_source_factory API version
2044  */
2045 #define RASQAL_TRIPLES_SOURCE_FACTORY_MIN_VERSION 1
2046 
2047 /**
2048  * RASQAL_TRIPLES_SOURCE_FACTORY_MAX_VERSION:
2049  *
2050  * Highest accepted @rasqal_triples_source_factory API version
2051  */
2052 #define RASQAL_TRIPLES_SOURCE_FACTORY_MAX_VERSION 3
2053 
2054 
2055 /**
2056  * rasqal_triples_error_handler:
2057  * @query: query object
2058  * @locator: error locator (or NULL)
2059  * @message: error message
2060  *
2061  * Triples source factory error handler callback.
2062  */
2063 typedef void (*rasqal_triples_error_handler)(rasqal_query* query, raptor_locator* locator, const char* message);
2064 
2065 
2066 /**
2067  * rasqal_triples_error_handler2:
2068  * @world: world object
2069  * @locator: error locator (or NULL)
2070  * @message: error message
2071  *
2072  * Triples source factory error handler callback.
2073  */
2074 typedef void (*rasqal_triples_error_handler2)(rasqal_world* world, raptor_locator* locator, const char* message);
2075 
2076 
2077 /**
2078  * rasqal_triples_source_factory:
2079  * @version: API factory version from 1 to 3
2080  * @user_data: User data for triples_source_factory.
2081  * @user_data_size: Size of @user_data for new_triples_source.
2082  * @new_triples_source: Create a new triples source - returns non-zero on failure &lt; 0 is a 'no rdf data error', &gt; 0 is an unspecified error. Error messages are generated by rasqal internally. (V1)
2083  * @init_triples_source: Initialise a new triples source V2 for a particular source URI/base URI and syntax. Returns non-zero on failure with errors reported via the handler callback by the implementation. (V2)
2084  * @init_triples_source2: Initialise a new triples source V3 for a particular source URI/base URI and syntax and given data graphs. Returns non-zero on failure with errors reported via the handler callback by the implementation. If bit 0 of flags is 1, enforce RAPTOR_FEATURE_NO_NET (V3)
2085  *
2086  * A factory that initialises #rasqal_triples_source structures to
2087  * returning matches to a triple pattern across the dataset formed
2088  * from the data graphs recorded in the @query object.
2089  */
2090 typedef struct {
2091   int version;
2092 
2093   void *user_data;
2094   size_t user_data_size;
2095 
2096   /* API v1 */
2097   int (*new_triples_source)(rasqal_query* query, void *factory_user_data, void *user_data, rasqal_triples_source* rts);
2098   /* API v2 onwards */
2099   int (*init_triples_source)(rasqal_query* query, void *factory_user_data, void *user_data, rasqal_triples_source* rts, rasqal_triples_error_handler handler);
2100   /* API v3 onwards */
2101   int (*init_triples_source2)(rasqal_world* world, raptor_sequence* data_graphs, void *factory_user_data, void *user_data, rasqal_triples_source *rts, rasqal_triples_error_handler2 handler, unsigned int flags);
2102 } rasqal_triples_source_factory;
2103 
2104 
2105 /**
2106  * rasqal_triples_source_factory_register_fn:
2107  * @factory: factory to register
2108  *
2109  * Register a factory for generating triples sources #rasqal_triples_source
2110  *
2111  * Return value: non-0 on failure
2112  */
2113 typedef int (*rasqal_triples_source_factory_register_fn)(rasqal_triples_source_factory *factory);
2114 
2115 
2116 /* set the triples_source_factory */
2117 RASQAL_API
2118 int rasqal_set_triples_source_factory(rasqal_world* world, rasqal_triples_source_factory_register_fn register_fn, void* user_data);
2119 
2120 
2121 
2122 /* The info below is solely for gtk-doc - ignore it */
2123 
2124 /**
2125  * raptor_world:
2126  *
2127  * Internal
2128  */
2129 
2130 /**
2131  * RASQAL_QUERY_RESULTS_FORMATTER_DECLARED:
2132  *
2133  * Internal
2134  */
2135 
2136 /**
2137  * RASQAL_WORLD_DECLARED:
2138  *
2139  * Internal
2140  */
2141 
2142 
2143 /**
2144  * RASQAL_LITERAL_UDT_DEFINED
2145  *
2146  * Internal
2147  */
2148 
2149 /**
2150  * rasqal_expression_s:
2151  * @world: Internal
2152  * @usage: Internal
2153  * @op: Internal
2154  * @arg1: Internal
2155  * @arg2: Internal
2156  * @arg3: Internal
2157  * @literal: Internal
2158  * @value: Internal
2159  * @name: Internal
2160  * @args: Internal
2161  * @params: Internal
2162  * @flags: Internal
2163  * @arg4: Internal
2164  *
2165  * Internal - see #rasqal_expression.
2166  *
2167  */
2168 
2169 /**
2170  * bind_match:
2171  * @rtm: triples match context
2172  * @user_data: user data
2173  * @bindings: variable binding for parts of triple (s, p, o, g)
2174  * @parts: parts of triple to match
2175  *
2176  * Internal - see #rasqal_triples_match
2177  *
2178  * Return value: match parts
2179 */
2180 
2181 /**
2182  * next_match:
2183  * @rtm: triples match context
2184  * @user_data: user data
2185  *
2186  * Internal - see #rasqal_triples_match
2187  */
2188 
2189 /**
2190  * is_end:
2191  * @rtm: triples match context
2192  * @user_data: user data
2193  *
2194  * Internal - see #rasqal_triples_match
2195  *
2196  * Return value: non-0 if end of match
2197  */
2198 
2199 /**
2200  * finish:
2201  * @rtm: triples match context
2202  * @user_data: user data
2203  *
2204  * Internal - see #rasqal_triples_match
2205  */
2206 
2207 /**
2208  * init_triples_match:
2209  * @rtm: triples match context
2210  * @rts: triples match source
2211  * @user_data: user data
2212  * @m: triple meta
2213  * @t: triple
2214  *
2215  * Internal - see #rasqal_triples_source
2216  *
2217  * Return value: non-0 on failure
2218  */
2219 
2220 /**
2221  * triple_present:
2222  * @rts: triples match source
2223  * @user_data: user data
2224  * @t: triple to test for presence
2225  *
2226  * Internal - see #rasqal_triples_source
2227  *
2228  * Return value: non-0 on failure
2229  */
2230 
2231 /**
2232  * free_triples_source:
2233  * @user_data: user data
2234  *
2235  * Internal - see #rasqal_triples_source
2236  */
2237 
2238 /**
2239  * support_feature:
2240  * @user_data: user data
2241  * @feature: feature to test
2242  *
2243  * Internal - see #rasqal_triples_source
2244  *
2245  * Return value: non-0 if supported
2246  */
2247 
2248 /**
2249  * rasqal_variables_table:
2250  *
2251  * Internal - for now
2252  */
2253 
2254 
2255 #ifdef __cplusplus
2256 }
2257 #endif
2258 
2259 #endif
2260