fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / external / redland / rasqal / rasqal.h
blob331532d9cb2da930fe3dca189e34fe79a12810d2
1 /* -*- Mode: c; c-basic-offset: 2 -*-
3 * rasqal.h - Rasqal RDF Query library interfaces and definition
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/
8 * This package is Free Software and part of Redland http://librdf.org/
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
15 * You may not use this file except in compliance with at least one of
16 * the above three licenses.
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.
26 #ifndef RASQAL_H
27 #define RASQAL_H
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
35 /**
36 * RASQAL_VERSION:
38 * Rasqal library version number
40 * Format: major * 10000 + minor * 100 + release
42 #define RASQAL_VERSION 930
44 /**
45 * RASQAL_VERSION_STRING:
47 * Rasqal library version string
49 #define RASQAL_VERSION_STRING "0.9.30"
51 /**
52 * RASQAL_VERSION_MAJOR:
54 * Rasqal library major version
56 #define RASQAL_VERSION_MAJOR 0
58 /**
59 * RASQAL_VERSION_MINOR:
61 * Rasqal library minor version
63 #define RASQAL_VERSION_MINOR 9
65 /**
66 * RASQAL_VERSION_RELEASE:
68 * Rasqal library release
70 #define RASQAL_VERSION_RELEASE 30
73 /**
74 * RASQAL_API:
76 * Macro for wrapping API function call declarations.
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
99 /* Use gcc 3.1+ feature to allow marking of deprecated API calls.
100 * This gives a warning during compiling.
102 #if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
103 #define RASQAL_DEPRECATED __attribute__((deprecated))
104 #else
105 #define RASQAL_DEPRECATED
106 #endif
109 #ifndef LIBRDF_OBJC_FRAMEWORK
110 #include <raptor.h>
111 #else
112 #include <Redland/raptor.h>
113 #endif
115 #if 0
116 #include <sys/time.h>
117 #endif
118 #if 1
119 #include <time.h>
120 #endif
122 /* Public statics */
125 * rasqal_short_copyright_string:
127 * Short copyright string (one line).
129 RASQAL_API
130 extern const char * const rasqal_short_copyright_string;
133 * rasqal_copyright_string:
135 * Copyright string (multiple lines).
137 RASQAL_API
138 extern const char * const rasqal_copyright_string;
141 * rasqal_version_string:
143 * Rasqal version as a string.
145 RASQAL_API
146 extern const char * const rasqal_version_string;
149 * rasqal_version_major:
151 * Rasqal major version number.
153 RASQAL_API
154 extern const unsigned int rasqal_version_major;
157 * rasqal_version_minor:
159 * Rasqal minor version number.
161 RASQAL_API
162 extern const unsigned int rasqal_version_minor;
165 * rasqal_version_release:
167 * Rasqal release version number.
169 RASQAL_API
170 extern const unsigned int rasqal_version_release;
173 * rasqal_version_decimal:
175 * Rasqal version as a decimal number.
177 * Format: major * 10000 + minor * 100 + release
179 RASQAL_API
180 extern const unsigned int rasqal_version_decimal;
183 * rasqal_license_string:
185 * Rasqal license string.
187 RASQAL_API
188 extern const char * const rasqal_license_string;
191 * rasqal_home_url_string:
193 * Rasqal home page URL.
195 RASQAL_API
196 extern const char * const rasqal_home_url_string;
201 * RASQAL_RAPTOR_VERSION:
203 * Version of Raptor that Rasqal was configured against.
205 #define RASQAL_RAPTOR_VERSION 0
208 /* Public structures */
210 #ifndef RASQAL_WORLD_DECLARED
211 #define RASQAL_WORLD_DECLARED 1
213 * rasqal_world:
215 * Rasqal world class.
217 typedef struct rasqal_world_s rasqal_world;
218 #endif
221 * rasqal_query:
223 * Rasqal query class.
225 typedef struct rasqal_query_s rasqal_query;
228 * rasqal_query_results:
230 * Rasqal query results class.
232 typedef struct rasqal_query_results_s rasqal_query_results;
235 #ifndef RASQAL_QUERY_RESULTS_FORMATTER_DECLARED
236 #define RASQAL_QUERY_RESULTS_FORMATTER_DECLARED 1
238 * rasqal_query_results_formatter:
240 * Rasqal query results formatter class.
242 typedef struct rasqal_query_results_formatter_s rasqal_query_results_formatter;
243 #endif
246 typedef struct rasqal_literal_s rasqal_literal;
249 * rasqal_graph_pattern:
251 * Rasqal graph pattern class.
253 typedef struct rasqal_graph_pattern_s rasqal_graph_pattern;
257 * rasqal_variables_table:
259 * Rasqal variables table class.
261 typedef struct rasqal_variables_table_s rasqal_variables_table;
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.
270 * Query features.
272 * None currently defined.
274 typedef enum {
275 RASQAL_FEATURE_NO_NET,
276 RASQAL_FEATURE_RAND_SEED,
277 RASQAL_FEATURE_LAST = RASQAL_FEATURE_RAND_SEED
278 } rasqal_feature;
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.
289 * Namespace (prefix, uri) pair.
291 * Includes internal flags used for marking when prefixes are
292 * declared and at what XML element depth when used in XML formats.
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;
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.
309 * Rasqal variable types.
311 * ANONYMOUS can be used in queries but cannot be returned in a
312 * result.
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;
321 /* forward reference */
322 struct rasqal_expression_s;
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
335 * Binding between a variable name and a value.
337 * Includes internal field @offset for recording the offset into the
338 * (internal) rasqal_query variables array.
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;
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.
358 * Flags for the type of #rasqal_data_graph.
360 * These are used by rasqal_new_data_graph_from_uri() and
361 * rasqal_new_data_graph_from_iostream(). See #rasqal_data_graph.
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;
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
383 * A source of RDF data for querying.
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.
389 * In either case the @name_uri is the graph name as long as @flags
390 * is %RASQAL_DATA_GRAPH_NAMED
392 typedef struct {
393 rasqal_world* world;
394 raptor_uri* uri;
395 raptor_uri* name_uri;
396 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;
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.
429 * Types of literal.
431 * The order in the enumeration is significant as it encodes
432 * the SPARQL term ordering conditions:
434 * Blank Nodes << IRIs << RDF literals << typed literals
436 * which coresponds to in enum values
438 * BLANK << URI << STRING <<
439 * (BOOLEAN | INTEGER | DOUBLE | FLOAT | DECIMAL | DATETIME | XSD_STRING)
441 * (RASQAL_LITERAL_FIRST_XSD ... RASQAL_LITERAL_LAST_XSD)
443 * Not used (internal): PATTERN, QNAME, VARIABLE
445 * See rasqal_literal_compare() when used with flags
446 * %RASQAL_COMPARE_XQUERY
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;
476 #define RASQAL_LITERAL_UDT_DEFINED 1
480 * rasqal_row:
482 * Rasqal Result Row class.
484 typedef struct rasqal_row_s rasqal_row;
488 * rasqal_xsd_decimal:
490 * Rasqal XSD Decimal class.
492 typedef struct rasqal_xsd_decimal_s rasqal_xsd_decimal;
496 * RASQAL_XSD_DATETIME_NO_TZ:
498 * Sentinel XSD Decimal timezone value indicating no timezone is present.
500 #define RASQAL_XSD_DATETIME_NO_TZ (9999)
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
511 * XML schema date datatype (xsd:date)
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'
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;
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
543 * XML Schema dateTime datatype (xsd:dateTime)
545 * Signed types are required for normalization process where a value
546 * can be negative temporarily.
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'
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;
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
583 * Rasqal literal class.
586 struct rasqal_literal_s {
587 rasqal_world *world;
589 int usage;
591 rasqal_literal_type type;
593 /* UTF-8 string, pattern, qname, blank, double, float, decimal, datetime */
594 const unsigned char *string;
595 unsigned int string_len;
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;
614 /* for string */
615 const char *language;
616 raptor_uri *datatype;
618 /* various flags for literal types:
619 * pattern regex flags
620 * string datatype of qname
621 * uri qname of URI not yet expanded (temporary)
623 const unsigned char *flags;
625 rasqal_literal_type parent_type;
627 int valid;
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
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.
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;
833 * rasqal_expression_flags:
834 * @RASQAL_EXPR_FLAG_DISTINCT: Distinct
835 * @RASQAL_EXPR_FLAG_AGGREGATE: Aggregate function expression
837 * Flags for expressions.
839 typedef enum {
840 RASQAL_EXPR_FLAG_DISTINCT = 1,
841 RASQAL_EXPR_FLAG_AGGREGATE = 2
842 } rasqal_expression_flags;
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+)
860 * Expression with arguments
863 struct rasqal_expression_s {
864 rasqal_world* world;
866 int usage;
868 rasqal_op op;
870 struct rasqal_expression_s* arg1;
871 struct rasqal_expression_s* arg2;
872 struct rasqal_expression_s* arg3;
873 rasqal_literal* literal;
874 unsigned char *value;
876 raptor_uri* name;
877 raptor_sequence* args;
879 raptor_sequence* params;
880 unsigned int flags;
881 struct rasqal_expression_s* arg4;
883 typedef struct rasqal_expression_s rasqal_expression;
887 * rasqal_triple:
888 * @subject: Triple subject.
889 * @predicate: Triple predicate.
890 * @object: Triple object.
891 * @origin: Triple origin.
892 * @flags: Or of enum #rasqal_triple_flags bits.
894 * A triple pattern or RDF triple.
896 * This is used as a triple pattern in queries and
897 * an RDF triple when generating RDF triples such as with SPARQL CONSTRUCT.
899 typedef struct {
900 rasqal_literal* subject;
901 rasqal_literal* predicate;
902 rasqal_literal* object;
903 rasqal_literal* origin;
904 unsigned int flags;
905 } rasqal_triple;
909 * rasqal_pattern_flags:
910 * @RASQAL_PATTERN_FLAGS_OPTIONAL: True when the graph pattern is an optional match.
911 * @RASQAL_PATTERN_FLAGS_LAST: Internal
913 * Flags for #rasqal_graph_pattern.
915 typedef enum {
916 RASQAL_PATTERN_FLAGS_OPTIONAL = 1,
918 RASQAL_PATTERN_FLAGS_LAST = RASQAL_PATTERN_FLAGS_OPTIONAL
919 } rasqal_pattern_flags;
923 * rasqal_generate_bnodeid_handler:
924 * @world: world arg
925 * @user_data: user data given to
926 * @user_bnodeid: user blank node ID string passed in
928 * User handler used with rasqal_world_set_generate_bnodeid_handler() to set method for generating a blank node ID.
930 * Return value: blank node ID string or NULL on failure.
932 typedef unsigned char* (*rasqal_generate_bnodeid_handler)(rasqal_world* world, void *user_data, unsigned char *user_bnodeid);
936 * rasqal_query_verb:
937 * @RASQAL_QUERY_VERB_SELECT: SPARQL query select verb.
938 * @RASQAL_QUERY_VERB_CONSTRUCT: SPARQL query construct verb.
939 * @RASQAL_QUERY_VERB_DESCRIBE: SPARQL query describe verb.
940 * @RASQAL_QUERY_VERB_ASK: SPARQL query ask verb.
941 * @RASQAL_QUERY_VERB_DELETE: LAQRS query delete verb.
942 * @RASQAL_QUERY_VERB_INSERT: LAQRS query insert verb.
943 * @RASQAL_QUERY_VERB_UPDATE: SPARQL 1.1 (draft) update operation
944 * @RASQAL_QUERY_VERB_UNKNOWN: Internal
945 * @RASQAL_QUERY_VERB_LAST: Internal
947 * Query main operation verbs describing the major type of query
948 * being performed.
950 typedef enum {
951 /* internal */
952 RASQAL_QUERY_VERB_UNKNOWN = 0,
953 RASQAL_QUERY_VERB_SELECT = 1,
954 RASQAL_QUERY_VERB_CONSTRUCT = 2,
955 RASQAL_QUERY_VERB_DESCRIBE = 3,
956 RASQAL_QUERY_VERB_ASK = 4,
957 RASQAL_QUERY_VERB_DELETE = 5,
958 RASQAL_QUERY_VERB_INSERT = 6,
959 RASQAL_QUERY_VERB_UPDATE = 7,
961 /* internal */
962 RASQAL_QUERY_VERB_LAST = RASQAL_QUERY_VERB_UPDATE
963 } rasqal_query_verb;
967 * rasqal_query_results_type:
968 * @RASQAL_QUERY_RESULTS_BINDINGS: variable binding
969 * @RASQAL_QUERY_RESULTS_BOOLEAN: a single boolean
970 * @RASQAL_QUERY_RESULTS_GRAPH: an RDF graph
971 * @RASQAL_QUERY_RESULTS_SYNTAX: a syntax
972 * @RASQAL_QUERY_RESULTS_UNKNOWN: unknown type
974 * Query result type.
977 typedef enum {
978 RASQAL_QUERY_RESULTS_BINDINGS,
979 RASQAL_QUERY_RESULTS_BOOLEAN,
980 RASQAL_QUERY_RESULTS_GRAPH,
981 RASQAL_QUERY_RESULTS_SYNTAX,
982 RASQAL_QUERY_RESULTS_UNKNOWN
983 } rasqal_query_results_type;
987 * rasqal_update_type:
988 * @RASQAL_UPDATE_TYPE_CLEAR: Clear graph.
989 * @RASQAL_UPDATE_TYPE_CREATE: Create graph.
990 * @RASQAL_UPDATE_TYPE_DROP: Drop graph.
991 * @RASQAL_UPDATE_TYPE_LOAD: Load graph.
992 * @RASQAL_UPDATE_TYPE_UPDATE: Insert or Delete graph or triples.
993 * @RASQAL_UPDATE_TYPE_ADD: Add graph to another graph.
994 * @RASQAL_UPDATE_TYPE_MOVE: Move graph to another grpah.
995 * @RASQAL_UPDATE_TYPE_COPY: Copy graph to another graph.
996 * @RASQAL_UPDATE_TYPE_UNKNOWN: Internal
997 * @RASQAL_UPDATE_TYPE_LAST: Internal
999 * Update type being performed.
1002 typedef enum {
1003 /* internal */
1004 RASQAL_UPDATE_TYPE_UNKNOWN = 0,
1005 RASQAL_UPDATE_TYPE_CLEAR = 1,
1006 RASQAL_UPDATE_TYPE_CREATE = 2,
1007 RASQAL_UPDATE_TYPE_DROP = 3,
1008 RASQAL_UPDATE_TYPE_LOAD = 4,
1009 RASQAL_UPDATE_TYPE_UPDATE = 5,
1010 RASQAL_UPDATE_TYPE_ADD = 6,
1011 RASQAL_UPDATE_TYPE_MOVE = 7,
1012 RASQAL_UPDATE_TYPE_COPY = 8,
1014 /* internal */
1015 RASQAL_UPDATE_TYPE_LAST = RASQAL_UPDATE_TYPE_COPY
1016 } rasqal_update_type;
1020 * rasqal_update_flags:
1021 * @RASQAL_UPDATE_FLAGS_SILENT: the update operation should be silent
1022 * @RASQAL_UPDATE_FLAGS_DATA: the update operation is triple data not templates
1024 * Bitflags for graph update operations
1026 typedef enum {
1027 RASQAL_UPDATE_FLAGS_SILENT = 1,
1028 RASQAL_UPDATE_FLAGS_DATA = 2
1029 } rasqal_update_flags;
1033 * rasqal_update_graph_applies:
1034 * @RASQAL_UPDATE_GRAPH_ONE: the update operation applies to 1 graph
1035 * @RASQAL_UPDATE_GRAPH_DEFAULT: the update operation applies to the default graph
1036 * @RASQAL_UPDATE_GRAPH_NAMED: the update operation applies to all named graphs
1037 * @RASQAL_UPDATE_GRAPH_ALL: the update operation applies ALL graphs
1039 * The graph(s) that the update operation applies to.
1041 typedef enum {
1042 RASQAL_UPDATE_GRAPH_ONE = 0,
1043 RASQAL_UPDATE_GRAPH_DEFAULT = 1,
1044 RASQAL_UPDATE_GRAPH_NAMED = 2,
1045 RASQAL_UPDATE_GRAPH_ALL = 3
1046 } rasqal_update_graph_applies;
1050 * rasqal_update_operation:
1051 * @type: type of update
1052 * @graph_uri: optional graph URI (clear, drop, load, with ... delete, insert); source graph (add, move, copy)
1053 * @document_uri: optional document URI (load); destination graph (add, move, copy)
1054 * @insert_templates: optional sequence of #rasqal_triple to insert. Data triples if @flags is #RASQAL_UPDATE_FLAGS_DATA set, templates otherwise.
1055 * @delete_templates: optional sequence of #rasqal_triple templates to delete
1056 * @where: optional where template (insert/delete)
1057 * @flags: update flags - bit-or of flags defined in #rasqal_update_flags
1058 * @applies: the graph(s) that the update operation applies to, or @graph_uri if #RASQAL_UPDATE_GRAPH_ONE
1060 * Update operation - changing the dataset
1062 * For LOAD and CLEAR if @applies is set (not 0) then the operation
1063 * applies to just those graph(), otherwise it applies to the @graph_uri.
1065 * For ADD, MOVE and COPY the source graph is stored in @graph_uri
1066 * field and the destination graph in the @document_uri field. The
1067 * field names have no meaning in this case since both values are
1068 * always present, always graphs and a NULL value signifies the
1069 * default graph.
1072 typedef struct {
1073 rasqal_update_type type;
1075 raptor_uri* graph_uri;
1077 raptor_uri* document_uri;
1079 raptor_sequence* insert_templates;
1081 raptor_sequence* delete_templates;
1083 rasqal_graph_pattern* where;
1085 int flags;
1087 rasqal_update_graph_applies applies;
1088 } rasqal_update_operation;
1092 * rasqal_graph_pattern_operator:
1093 * @RASQAL_GRAPH_PATTERN_OPERATOR_BASIC: Just triple patterns and constraints.
1094 * @RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL: Set of graph patterns (ANDed) and constraints.
1095 * @RASQAL_GRAPH_PATTERN_OPERATOR_UNION: Set of graph patterns (UNIONed) and constraints.
1096 * @RASQAL_GRAPH_PATTERN_OPERATOR_GROUP: Set of graph patterns (ANDed) and constraints.
1097 * @RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH: A graph term + a graph pattern and constraints.
1098 * @RASQAL_GRAPH_PATTERN_OPERATOR_FILTER: A filter graph pattern with an expression
1099 * @RASQAL_GRAPH_PATTERN_OPERATOR_LET: LET ?var := Expression (LAQRS)
1100 * @RASQAL_GRAPH_PATTERN_OPERATOR_SELECT: SELECT graph pattern
1101 * @RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE: SERVICE graph pattern
1102 * @RASQAL_GRAPH_PATTERN_OPERATOR_MINUS: MINUS graph pattern
1103 * @RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN: Internal.
1104 * @RASQAL_GRAPH_PATTERN_OPERATOR_LAST: Internal.
1106 * Graph pattern operators
1108 typedef enum {
1109 RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN = 0,
1110 RASQAL_GRAPH_PATTERN_OPERATOR_BASIC = 1,
1111 RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL = 2,
1112 RASQAL_GRAPH_PATTERN_OPERATOR_UNION = 3,
1113 RASQAL_GRAPH_PATTERN_OPERATOR_GROUP = 4,
1114 RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH = 5,
1115 RASQAL_GRAPH_PATTERN_OPERATOR_FILTER = 6,
1116 RASQAL_GRAPH_PATTERN_OPERATOR_LET = 7,
1117 RASQAL_GRAPH_PATTERN_OPERATOR_SELECT = 8,
1118 RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE = 9,
1119 RASQAL_GRAPH_PATTERN_OPERATOR_MINUS = 10,
1121 RASQAL_GRAPH_PATTERN_OPERATOR_LAST = RASQAL_GRAPH_PATTERN_OPERATOR_MINUS
1122 } rasqal_graph_pattern_operator;
1126 * rasqal_graph_pattern_visit_fn:
1127 * @query: #rasqal_query containing the graph pattern
1128 * @gp: current graph_pattern
1129 * @user_data: user data passed in
1131 * User function to visit an graph_pattern and operate on it with
1132 * rasqal_graph_pattern_visit() or rasqal_query_graph_pattern_visit()
1134 * Return value: non-0 to truncate the visit
1136 typedef int (*rasqal_graph_pattern_visit_fn)(rasqal_query* query, rasqal_graph_pattern* gp, void *user_data);
1139 /* RASQAL API */
1141 /* Public functions */
1143 RASQAL_API
1144 rasqal_world *rasqal_new_world(void);
1145 RASQAL_API
1146 int rasqal_world_open(rasqal_world* world);
1147 RASQAL_API
1148 void rasqal_free_world(rasqal_world* world);
1150 RASQAL_API
1151 void rasqal_world_set_raptor(rasqal_world* world, raptor_world* raptor_world_ptr);
1152 RASQAL_API
1153 raptor_world *rasqal_world_get_raptor(rasqal_world* world);
1155 RASQAL_API
1156 void rasqal_world_set_log_handler(rasqal_world* world, void *user_data, raptor_log_handler handler);
1158 RASQAL_API
1159 int rasqal_world_set_default_generate_bnodeid_parameters(rasqal_world* world, char *prefix, int base);
1160 RASQAL_API
1161 int rasqal_world_set_generate_bnodeid_handler(rasqal_world* world, void *user_data, rasqal_generate_bnodeid_handler handler);
1163 RASQAL_API
1164 int rasqal_world_set_warning_level(rasqal_world* world, unsigned int warning_level);
1166 RASQAL_API
1167 const raptor_syntax_description* rasqal_world_get_query_results_format_description(rasqal_world* world, unsigned int counter);
1169 RASQAL_API
1170 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);
1172 /* Features */
1173 RASQAL_API
1174 int rasqal_features_enumerate(rasqal_world* world, const rasqal_feature feature, const char **name, raptor_uri **uri, const char **label);
1175 RASQAL_API
1176 unsigned int rasqal_get_feature_count(void);
1177 RASQAL_API
1178 rasqal_feature rasqal_feature_from_uri(rasqal_world* world, raptor_uri *uri);
1179 RASQAL_API
1180 int rasqal_feature_value_type(const rasqal_feature feature);
1183 RASQAL_API
1184 const raptor_syntax_description* rasqal_world_get_query_language_description(rasqal_world* world, unsigned int counter);
1186 RASQAL_API RASQAL_DEPRECATED
1187 int rasqal_languages_enumerate(rasqal_world* world, unsigned int counter, const char **name, const char **label, const unsigned char **uri_string);
1189 RASQAL_API
1190 int rasqal_language_name_check(rasqal_world* world, const char *name);
1193 /* Query class */
1195 /* Create */
1196 RASQAL_API
1197 rasqal_query* rasqal_new_query(rasqal_world* world, const char *name, const unsigned char *uri);
1199 /* Destroy */
1200 RASQAL_API
1201 void rasqal_free_query(rasqal_query* query);
1203 /* Methods */
1204 RASQAL_API
1205 const char* rasqal_query_get_name(rasqal_query* query);
1206 RASQAL_API
1207 const char* rasqal_query_get_label(rasqal_query* query);
1210 RASQAL_API
1211 int rasqal_query_set_feature(rasqal_query* query, rasqal_feature feature, int value);
1212 RASQAL_API
1213 int rasqal_query_set_feature_string(rasqal_query *query, rasqal_feature feature, const unsigned char *value);
1214 RASQAL_API
1215 int rasqal_query_get_feature(rasqal_query *query, rasqal_feature feature);
1216 RASQAL_API
1217 const unsigned char* rasqal_query_get_feature_string(rasqal_query *query, rasqal_feature feature);
1219 RASQAL_API
1220 rasqal_query_verb rasqal_query_get_verb(rasqal_query* query);
1221 RASQAL_API
1222 int rasqal_query_get_wildcard(rasqal_query* query);
1223 RASQAL_API
1224 void rasqal_query_set_wildcard(rasqal_query* query, int wildcard);
1225 RASQAL_API
1226 int rasqal_query_get_distinct(rasqal_query* query);
1227 RASQAL_API
1228 void rasqal_query_set_distinct(rasqal_query* query, int distinct_mode);
1229 RASQAL_API
1230 int rasqal_query_get_explain(rasqal_query* query);
1231 RASQAL_API
1232 void rasqal_query_set_explain(rasqal_query* query, int is_explain);
1233 RASQAL_API
1234 int rasqal_query_get_limit(rasqal_query* query);
1235 RASQAL_API
1236 void rasqal_query_set_limit(rasqal_query* query, int limit);
1237 RASQAL_API
1238 int rasqal_query_get_offset(rasqal_query* query);
1239 RASQAL_API
1240 void rasqal_query_set_offset(rasqal_query* query, int offset);
1242 RASQAL_API
1243 int rasqal_query_add_data_graph(rasqal_query* query, rasqal_data_graph* data_graph);
1244 RASQAL_API
1245 int rasqal_query_add_data_graphs(rasqal_query* query, raptor_sequence* data_graphs);
1247 RASQAL_API
1248 raptor_sequence* rasqal_query_get_data_graph_sequence(rasqal_query* query);
1249 RASQAL_API
1250 rasqal_data_graph* rasqal_query_get_data_graph(rasqal_query* query, int idx);
1251 RASQAL_API
1252 int rasqal_query_dataset_contains_named_graph(rasqal_query* query, raptor_uri *graph_uri);
1254 RASQAL_API
1255 int rasqal_query_add_variable(rasqal_query* query, rasqal_variable* var);
1256 RASQAL_API
1257 raptor_sequence* rasqal_query_get_bound_variable_sequence(rasqal_query* query);
1258 RASQAL_API
1259 raptor_sequence* rasqal_query_get_describe_sequence(rasqal_query* query);
1260 RASQAL_API
1261 raptor_sequence* rasqal_query_get_anonymous_variable_sequence(rasqal_query* query);
1262 RASQAL_API
1263 raptor_sequence* rasqal_query_get_all_variable_sequence(rasqal_query* query);
1264 RASQAL_API
1265 rasqal_variable* rasqal_query_get_variable(rasqal_query* query, int idx);
1266 RASQAL_API
1267 int rasqal_query_has_variable2(rasqal_query* query, rasqal_variable_type type, const unsigned char *name);
1268 RASQAL_API RASQAL_DEPRECATED
1269 int rasqal_query_has_variable(rasqal_query* query, const unsigned char *name);
1270 RASQAL_API
1271 int rasqal_query_set_variable2(rasqal_query* query, rasqal_variable_type type, const unsigned char *name, rasqal_literal* value);
1272 RASQAL_API RASQAL_DEPRECATED
1273 int rasqal_query_set_variable(rasqal_query* query, const unsigned char *name, rasqal_literal* value);
1274 RASQAL_API
1275 raptor_sequence* rasqal_query_get_triple_sequence(rasqal_query* query);
1276 RASQAL_API
1277 rasqal_triple* rasqal_query_get_triple(rasqal_query* query, int idx);
1278 RASQAL_API
1279 int rasqal_query_add_prefix(rasqal_query* query, rasqal_prefix* prefix);
1280 RASQAL_API
1281 raptor_sequence* rasqal_query_get_prefix_sequence(rasqal_query* query);
1282 RASQAL_API
1283 rasqal_prefix* rasqal_query_get_prefix(rasqal_query* query, int idx);
1284 RASQAL_API
1285 raptor_sequence* rasqal_query_get_order_conditions_sequence(rasqal_query* query);
1286 RASQAL_API
1287 rasqal_expression* rasqal_query_get_order_condition(rasqal_query* query, int idx);
1288 RASQAL_API
1289 raptor_sequence* rasqal_query_get_group_conditions_sequence(rasqal_query* query);
1290 RASQAL_API
1291 rasqal_expression* rasqal_query_get_group_condition(rasqal_query* query, int idx);
1292 RASQAL_API
1293 raptor_sequence* rasqal_query_get_having_conditions_sequence(rasqal_query* query);
1294 RASQAL_API
1295 rasqal_expression* rasqal_query_get_having_condition(rasqal_query* query, int idx);
1296 RASQAL_API
1297 raptor_sequence* rasqal_query_get_construct_triples_sequence(rasqal_query* query);
1298 RASQAL_API
1299 rasqal_triple* rasqal_query_get_construct_triple(rasqal_query* query, int idx);
1300 RASQAL_API RASQAL_DEPRECATED
1301 void rasqal_query_graph_pattern_visit(rasqal_query* query, rasqal_graph_pattern_visit_fn visit_fn, void* data);
1302 RASQAL_API
1303 int rasqal_query_graph_pattern_visit2(rasqal_query* query, rasqal_graph_pattern_visit_fn visit_fn, void* data);
1304 RASQAL_API
1305 int rasqal_query_write(raptor_iostream* iostr, rasqal_query* query, raptor_uri* format_uri, raptor_uri* base_uri);
1307 /* update */
1308 RASQAL_API
1309 raptor_sequence* rasqal_query_get_update_operations_sequence(rasqal_query* query);
1310 RASQAL_API
1311 rasqal_update_operation* rasqal_query_get_update_operation(rasqal_query* query, int idx);
1313 /* results */
1314 int rasqal_query_set_store_results(rasqal_query* query, int store_results);
1316 /* graph patterns */
1317 RASQAL_API
1318 rasqal_graph_pattern* rasqal_query_get_query_graph_pattern(rasqal_query* query);
1319 RASQAL_API
1320 raptor_sequence* rasqal_query_get_graph_pattern_sequence(rasqal_query* query);
1321 RASQAL_API
1322 rasqal_graph_pattern* rasqal_query_get_graph_pattern(rasqal_query* query, int idx);
1323 RASQAL_API
1324 int rasqal_graph_pattern_add_sub_graph_pattern(rasqal_graph_pattern* graph_pattern, rasqal_graph_pattern* sub_graph_pattern);
1325 RASQAL_API
1326 rasqal_triple* rasqal_graph_pattern_get_triple(rasqal_graph_pattern* graph_pattern, int idx);
1327 RASQAL_API
1328 raptor_sequence* rasqal_graph_pattern_get_sub_graph_pattern_sequence(rasqal_graph_pattern* graph_pattern);
1329 RASQAL_API
1330 rasqal_graph_pattern* rasqal_graph_pattern_get_sub_graph_pattern(rasqal_graph_pattern* graph_pattern, int idx);
1331 RASQAL_API
1332 rasqal_graph_pattern_operator rasqal_graph_pattern_get_operator(rasqal_graph_pattern* graph_pattern);
1333 RASQAL_API
1334 const char* rasqal_graph_pattern_operator_as_string(rasqal_graph_pattern_operator op);
1335 RASQAL_API
1336 int rasqal_graph_pattern_print(rasqal_graph_pattern* gp, FILE* fh);
1337 RASQAL_API
1338 int rasqal_graph_pattern_set_filter_expression(rasqal_graph_pattern* gp, rasqal_expression* expr);
1339 RASQAL_API
1340 rasqal_expression* rasqal_graph_pattern_get_filter_expression(rasqal_graph_pattern* gp);
1341 RASQAL_API
1342 int rasqal_graph_pattern_visit(rasqal_query* query, rasqal_graph_pattern *gp, rasqal_graph_pattern_visit_fn fn, void* user_data);
1343 RASQAL_API
1344 int rasqal_graph_pattern_get_index(rasqal_graph_pattern* gp);
1345 RASQAL_API
1346 int rasqal_graph_pattern_variable_bound_in(rasqal_graph_pattern *gp, rasqal_variable *v);
1347 RASQAL_API
1348 rasqal_literal* rasqal_graph_pattern_get_origin(rasqal_graph_pattern* graph_pattern);
1349 RASQAL_API
1350 rasqal_variable* rasqal_graph_pattern_get_variable(rasqal_graph_pattern* graph_pattern);
1351 RASQAL_API
1352 rasqal_literal* rasqal_graph_pattern_get_service(rasqal_graph_pattern* graph_pattern);
1353 RASQAL_API
1354 raptor_sequence* rasqal_graph_pattern_get_flattened_triples(rasqal_query* query, rasqal_graph_pattern* graph_pattern);
1356 /* Utility methods */
1357 RASQAL_API
1358 const char* rasqal_query_verb_as_string(rasqal_query_verb verb);
1359 RASQAL_API
1360 int rasqal_query_print(rasqal_query* query, FILE* fh);
1362 /* Query */
1363 RASQAL_API
1364 int rasqal_query_prepare(rasqal_query* query, const unsigned char *query_string, raptor_uri *base_uri);
1365 RASQAL_API
1366 rasqal_query_results* rasqal_query_execute(rasqal_query* query);
1368 RASQAL_API
1369 void* rasqal_query_get_user_data(rasqal_query* query);
1370 RASQAL_API
1371 void rasqal_query_set_user_data(rasqal_query* query, void *user_data);
1373 RASQAL_API
1374 raptor_sequence* rasqal_query_get_bindings_variables_sequence(rasqal_query* query);
1375 RASQAL_API
1376 rasqal_variable* rasqal_query_get_bindings_variable(rasqal_query* query, int idx);
1377 RASQAL_API
1378 raptor_sequence* rasqal_query_get_bindings_rows_sequence(rasqal_query* query);
1379 RASQAL_API
1380 rasqal_row* rasqal_query_get_bindings_row(rasqal_query* query, int idx);
1381 RASQAL_API
1382 rasqal_query_results_type rasqal_query_get_result_type(rasqal_query* query);
1384 /* query results */
1385 RASQAL_API
1386 rasqal_query_results* rasqal_new_query_results(rasqal_world* world, rasqal_query* query, rasqal_query_results_type type, rasqal_variables_table* vars_table);
1387 RASQAL_API
1388 void rasqal_free_query_results(rasqal_query_results *query_results);
1390 RASQAL_API
1391 rasqal_query* rasqal_query_results_get_query(rasqal_query_results* query_results);
1393 /* Bindings result format */
1394 RASQAL_API
1395 rasqal_query_results_type rasqal_query_results_get_type(rasqal_query_results* query_results);
1396 RASQAL_API
1397 int rasqal_query_results_is_bindings(rasqal_query_results *query_results);
1398 RASQAL_API
1399 int rasqal_query_results_get_count(rasqal_query_results *query_results);
1400 RASQAL_API
1401 int rasqal_query_results_next(rasqal_query_results *query_results);
1402 RASQAL_API
1403 int rasqal_query_results_finished(rasqal_query_results *query_results);
1404 RASQAL_API
1405 int rasqal_query_results_get_bindings(rasqal_query_results *query_results, const unsigned char ***names, rasqal_literal ***values);
1406 RASQAL_API
1407 rasqal_literal* rasqal_query_results_get_binding_value(rasqal_query_results *query_results, int offset);
1408 RASQAL_API
1409 const unsigned char* rasqal_query_results_get_binding_name(rasqal_query_results *query_results, int offset);
1410 RASQAL_API
1411 rasqal_literal* rasqal_query_results_get_binding_value_by_name(rasqal_query_results *query_results, const unsigned char *name);
1412 RASQAL_API
1413 int rasqal_query_results_get_bindings_count(rasqal_query_results *query_results);
1414 RASQAL_API
1415 int rasqal_query_results_add_row(rasqal_query_results* query_results, rasqal_row* row);
1416 RASQAL_API
1417 rasqal_row* rasqal_query_results_get_row_by_offset(rasqal_query_results* query_results, int result_offset);
1419 /* Boolean result format */
1420 RASQAL_API
1421 int rasqal_query_results_is_boolean(rasqal_query_results *query_results);
1422 RASQAL_API
1423 int rasqal_query_results_get_boolean(rasqal_query_results *query_results);
1425 /* Graph result format */
1426 RASQAL_API
1427 int rasqal_query_results_is_graph(rasqal_query_results *query_results);
1428 RASQAL_API
1429 raptor_statement* rasqal_query_results_get_triple(rasqal_query_results *query_results);
1430 RASQAL_API
1431 int rasqal_query_results_next_triple(rasqal_query_results *query_results);
1433 /* Syntax result format */
1434 RASQAL_API
1435 int rasqal_query_results_is_syntax(rasqal_query_results* query_results);
1437 RASQAL_API
1438 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);
1439 RASQAL_API
1440 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);
1442 /* One more time */
1443 RASQAL_API
1444 int rasqal_query_results_rewind(rasqal_query_results* query_results);
1448 * rasqal_query_results_format_flags:
1449 * @RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER: format can be read.
1450 * @RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER: format can be written.
1452 * Bitflags for rasqal_query_results_formats_check() to find formats with features.
1454 typedef enum {
1455 RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER = 1,
1456 RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER = 2
1457 } rasqal_query_results_format_flags;
1460 RASQAL_API
1461 int rasqal_query_results_formats_check(rasqal_world* world, const char *name, raptor_uri* uri, const char *mime_type, int flags);
1462 RASQAL_API
1463 rasqal_query_results_formatter* rasqal_new_query_results_formatter(rasqal_world* world, const char *name, const char *mime_type, raptor_uri* format_uri);
1464 RASQAL_API
1465 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);
1466 RASQAL_API
1467 void rasqal_free_query_results_formatter(rasqal_query_results_formatter* formatter);
1468 RASQAL_API
1469 int rasqal_query_results_formatter_write(raptor_iostream *iostr, rasqal_query_results_formatter* formatter, rasqal_query_results* results, raptor_uri *base_uri);
1470 RASQAL_API
1471 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);
1473 RASQAL_API
1474 int rasqal_query_iostream_write_escaped_counted_string(rasqal_query* query, raptor_iostream* iostr, const unsigned char* string, size_t len);
1475 RASQAL_API
1476 unsigned char* rasqal_query_escape_counted_string(rasqal_query* query, const unsigned char *string, size_t len, size_t* output_len_p);
1479 /* Data graph class */
1480 RASQAL_API
1481 rasqal_data_graph* rasqal_new_data_graph_from_uri(rasqal_world* world, raptor_uri* uri, raptor_uri* name_uri, int flags, const char* format_type, const char* format_name, raptor_uri* format_uri);
1482 RASQAL_API
1483 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);
1484 RASQAL_API
1485 rasqal_data_graph* rasqal_new_data_graph_from_data_graph(rasqal_data_graph* dg);
1486 RASQAL_API
1487 void rasqal_free_data_graph(rasqal_data_graph* dg);
1488 RASQAL_API
1489 int rasqal_data_graph_print(rasqal_data_graph* dg, FILE* fh);
1493 * rasqal_compare_flags:
1494 * @RASQAL_COMPARE_NOCASE: String comparisons are case independent.
1495 * @RASQAL_COMPARE_XQUERY: XQuery comparsion rules apply.
1496 * @RASQAL_COMPARE_RDF: RDF Term comparsion rules apply.
1497 * @RASQAL_COMPARE_URI: Allow comparison of URIs and allow strings to have a boolean value (unused; was for RDQL)
1498 * @RASQAL_COMPARE_SAMETERM: SPARQL sameTerm() builtin rules apply.
1500 * Flags for rasqal_expression_evaluate(), rasqal_literal_compare() or
1501 * rasqal_literal_as_string_flags()
1503 typedef enum {
1504 RASQAL_COMPARE_NOCASE = 1,
1505 RASQAL_COMPARE_XQUERY = 2,
1506 RASQAL_COMPARE_RDF = 4,
1507 RASQAL_COMPARE_URI = 8,
1508 RASQAL_COMPARE_SAMETERM = 16
1509 } rasqal_compare_flags;
1513 * rasqal_random:
1515 * Internal
1517 typedef struct rasqal_random_s rasqal_random;
1521 * rasqal_evaluation_context:
1522 * @world: rasqal world
1523 * @base_uri: base URI of expression context (or NULL)
1524 * @locator: locator or NULL
1525 * @flags: expression comparison flags
1526 * @seed: random seeed
1527 * @random: random number generator object
1529 * A context for evaluating an expression such as with
1530 * rasqal_expression_evaluate2()
1532 typedef struct {
1533 rasqal_world *world;
1534 raptor_uri* base_uri;
1535 raptor_locator *locator;
1536 int flags;
1537 unsigned int seed;
1538 rasqal_random* random;
1539 } rasqal_evaluation_context;
1542 /* Expression class */
1543 RASQAL_API
1544 rasqal_expression* rasqal_new_0op_expression(rasqal_world* world, rasqal_op op);
1545 RASQAL_API
1546 rasqal_expression* rasqal_new_1op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg);
1547 RASQAL_API
1548 rasqal_expression* rasqal_new_2op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2);
1549 RASQAL_API
1550 rasqal_expression* rasqal_new_3op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2, rasqal_expression* arg3);
1551 RASQAL_API
1552 rasqal_expression* rasqal_new_4op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2, rasqal_expression* arg3, rasqal_expression* arg4);
1553 RASQAL_API
1554 rasqal_expression* rasqal_new_string_op_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, rasqal_literal* literal);
1555 RASQAL_API
1556 rasqal_expression* rasqal_new_literal_expression(rasqal_world* world, rasqal_literal* literal);
1557 RASQAL_API
1558 rasqal_expression* rasqal_new_function_expression(rasqal_world* world, raptor_uri* name, raptor_sequence* args, raptor_sequence* params, unsigned int flags);
1559 RASQAL_API
1560 rasqal_expression* rasqal_new_aggregate_function_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, raptor_sequence* params, unsigned int flags);
1561 RASQAL_API
1562 rasqal_expression* rasqal_new_cast_expression(rasqal_world* world, raptor_uri* name, rasqal_expression *value);
1563 RASQAL_API
1564 rasqal_expression* rasqal_new_expr_seq_expression(rasqal_world* world, rasqal_op op, raptor_sequence* args);
1565 RASQAL_API
1566 rasqal_expression* rasqal_new_set_expression(rasqal_world* world, rasqal_op op, rasqal_expression* arg1, raptor_sequence* args);
1567 RASQAL_API
1568 rasqal_expression* rasqal_new_group_concat_expression(rasqal_world* world, int flags, raptor_sequence* args, rasqal_literal* separator);
1569 RASQAL_API
1570 rasqal_expression* rasqal_new_expression_from_expression(rasqal_expression* e);
1572 RASQAL_API
1573 void rasqal_free_expression(rasqal_expression* e);
1574 RASQAL_API
1575 void rasqal_expression_print_op(rasqal_expression* e, FILE* fh);
1576 RASQAL_API
1577 int rasqal_expression_print(rasqal_expression* e, FILE* fh);
1578 RASQAL_API RASQAL_DEPRECATED
1579 rasqal_literal* rasqal_expression_evaluate(rasqal_world *world, raptor_locator *locator, rasqal_expression* e, int flags);
1580 RASQAL_API
1581 rasqal_literal* rasqal_expression_evaluate2(rasqal_expression *e, rasqal_evaluation_context* eval_context, int *error_p);
1582 RASQAL_API
1583 const char* rasqal_expression_op_label(rasqal_op op);
1584 RASQAL_API
1585 int rasqal_expression_compare(rasqal_expression* e1, rasqal_expression* e2, int flags, int* error_p);
1588 * rasqal_expression_visit_fn:
1589 * @user_data: user data passed in with rasqal_expression_visit()
1590 * @e: current expression
1592 * User function to visit an expression and operate on it with
1593 * rasqal_expression_visit()
1595 * Return value: non-0 to truncate the visit
1597 typedef int (*rasqal_expression_visit_fn)(void *user_data, rasqal_expression *e);
1598 RASQAL_API
1599 int rasqal_expression_visit(rasqal_expression* e, rasqal_expression_visit_fn fn, void *user_data);
1601 RASQAL_API
1602 rasqal_evaluation_context* rasqal_new_evaluation_context(rasqal_world* world, raptor_locator* locator, int flags);
1603 RASQAL_API
1604 void rasqal_free_evaluation_context(rasqal_evaluation_context* eval_context);
1605 RASQAL_API
1606 int rasqal_evaluation_context_set_base_uri(rasqal_evaluation_context* eval_context, raptor_uri *base_uri);
1607 RASQAL_API
1608 int rasqal_evaluation_context_set_rand_seed(rasqal_evaluation_context* eval_context, unsigned int seed);
1611 /* Literal class */
1612 RASQAL_API
1613 rasqal_literal* rasqal_new_integer_literal(rasqal_world* world, rasqal_literal_type type, int integer);
1614 RASQAL_API
1615 rasqal_literal* rasqal_new_numeric_literal_from_long(rasqal_world* world, rasqal_literal_type type, long value);
1616 RASQAL_API
1617 rasqal_literal* rasqal_new_typed_literal(rasqal_world* world, rasqal_literal_type type, const unsigned char* string);
1618 RASQAL_API
1619 rasqal_literal* rasqal_new_double_literal(rasqal_world* world, double d);
1620 RASQAL_API
1621 rasqal_literal* rasqal_new_floating_literal(rasqal_world *world, rasqal_literal_type type, double d);
1622 RASQAL_API RASQAL_DEPRECATED
1623 rasqal_literal* rasqal_new_float_literal(rasqal_world* world, float f);
1624 RASQAL_API
1625 rasqal_literal* rasqal_new_uri_literal(rasqal_world* world, raptor_uri* uri);
1626 RASQAL_API
1627 rasqal_literal* rasqal_new_pattern_literal(rasqal_world* world, const unsigned char *pattern, const char *flags);
1628 RASQAL_API
1629 rasqal_literal* rasqal_new_string_literal(rasqal_world* world, const unsigned char *string, const char *language, raptor_uri *datatype, const unsigned char *datatype_qname);
1630 RASQAL_API
1631 rasqal_literal* rasqal_new_simple_literal(rasqal_world* world, rasqal_literal_type type, const unsigned char *string);
1632 RASQAL_API
1633 rasqal_literal* rasqal_new_boolean_literal(rasqal_world* world, int value);
1634 RASQAL_API
1635 rasqal_literal* rasqal_new_variable_literal(rasqal_world* world, rasqal_variable *variable);
1636 RASQAL_API
1637 rasqal_literal* rasqal_new_decimal_literal(rasqal_world* world, const unsigned char *string);
1638 RASQAL_API
1639 rasqal_literal* rasqal_new_decimal_literal_from_decimal(rasqal_world* world, const unsigned char *string, rasqal_xsd_decimal* decimal);
1640 RASQAL_API
1641 rasqal_literal* rasqal_new_datetime_literal_from_datetime(rasqal_world* world, rasqal_xsd_datetime* dt);
1644 RASQAL_API
1645 rasqal_literal* rasqal_new_literal_from_literal(rasqal_literal* l);
1646 RASQAL_API
1647 void rasqal_free_literal(rasqal_literal* l);
1648 RASQAL_API
1649 int rasqal_literal_print(rasqal_literal* l, FILE* fh);
1650 RASQAL_API
1651 const char* rasqal_literal_type_label(rasqal_literal_type type);
1652 RASQAL_API
1653 void rasqal_literal_print_type(rasqal_literal* l, FILE* fh);
1654 RASQAL_API
1655 rasqal_variable* rasqal_literal_as_variable(rasqal_literal* l);
1656 RASQAL_API
1657 const unsigned char* rasqal_literal_as_counted_string(rasqal_literal* l, size_t *len_p, int flags, int *error_p);
1658 RASQAL_API
1659 const unsigned char* rasqal_literal_as_string(rasqal_literal* l);
1660 RASQAL_API
1661 const unsigned char* rasqal_literal_as_string_flags(rasqal_literal* l, int flags, int *error_p);
1662 RASQAL_API
1663 rasqal_literal* rasqal_literal_as_node(rasqal_literal* l);
1664 RASQAL_API
1665 raptor_uri* rasqal_literal_datatype(rasqal_literal* l);
1666 RASQAL_API
1667 rasqal_literal* rasqal_literal_value(rasqal_literal* l);
1669 RASQAL_API
1670 int rasqal_literal_compare(rasqal_literal* l1, rasqal_literal* l2, int flags, int *error_p);
1671 RASQAL_API
1672 int rasqal_literal_equals(rasqal_literal* l1, rasqal_literal* l2);
1673 RASQAL_API
1674 int rasqal_literal_same_term(rasqal_literal* l1, rasqal_literal* l2);
1675 RASQAL_API
1676 rasqal_literal_type rasqal_literal_get_rdf_term_type(rasqal_literal* l);
1677 RASQAL_API
1678 int rasqal_literal_is_rdf_literal(rasqal_literal* l);
1681 RASQAL_API
1682 rasqal_prefix* rasqal_new_prefix(rasqal_world* world, const unsigned char* prefix, raptor_uri* uri);
1683 RASQAL_API
1684 void rasqal_free_prefix(rasqal_prefix* p);
1685 RASQAL_API
1686 int rasqal_prefix_print(rasqal_prefix* p, FILE* fh);
1689 /* Row class */
1690 RASQAL_API
1691 rasqal_row* rasqal_new_row_for_size(rasqal_world* world, int size);
1692 RASQAL_API
1693 void rasqal_free_row(rasqal_row* row);
1694 RASQAL_API
1695 int rasqal_row_set_value_at(rasqal_row* row, int offset, rasqal_literal* value);
1698 /* Triple class */
1699 RASQAL_API
1700 rasqal_triple* rasqal_new_triple(rasqal_literal* subject, rasqal_literal* predicate, rasqal_literal* object);
1701 RASQAL_API
1702 rasqal_triple* rasqal_new_triple_from_triple(rasqal_triple* t);
1703 RASQAL_API
1704 void rasqal_free_triple(rasqal_triple* t);
1705 RASQAL_API
1706 int rasqal_triple_print(rasqal_triple* t, FILE* fh);
1707 RASQAL_API
1708 void rasqal_triple_set_origin(rasqal_triple* t, rasqal_literal *l);
1709 RASQAL_API
1710 rasqal_literal* rasqal_triple_get_origin(rasqal_triple* t);
1712 /* Variable class */
1713 RASQAL_API
1714 rasqal_variable* rasqal_new_variable_from_variable(rasqal_variable* v);
1715 RASQAL_API
1716 void rasqal_free_variable(rasqal_variable* v);
1717 RASQAL_API
1718 int rasqal_variable_print(rasqal_variable* v, FILE* fh);
1719 RASQAL_API
1720 void rasqal_variable_set_value(rasqal_variable* v, rasqal_literal* l);
1723 /* Variables Table */
1724 RASQAL_API
1725 rasqal_variables_table* rasqal_new_variables_table(rasqal_world* world);
1726 RASQAL_API
1727 void rasqal_free_variables_table(rasqal_variables_table* vt);
1728 RASQAL_API
1729 rasqal_variable* rasqal_variables_table_add(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name, rasqal_literal *value);
1730 RASQAL_API
1731 int rasqal_variables_table_add_variable(rasqal_variables_table* vt, rasqal_variable* variable);
1732 RASQAL_API
1733 rasqal_variable* rasqal_variables_table_get_by_name(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name);
1734 RASQAL_API
1735 int rasqal_variables_table_contains(rasqal_variables_table* vt, rasqal_variable_type type, const unsigned char *name);
1737 /* memory functions */
1738 RASQAL_API
1739 void rasqal_free_memory(void *ptr);
1740 RASQAL_API
1741 void* rasqal_alloc_memory(size_t size);
1742 RASQAL_API
1743 void* rasqal_calloc_memory(size_t nmemb, size_t size);
1746 /* decimal functions */
1747 RASQAL_API
1748 rasqal_xsd_decimal* rasqal_new_xsd_decimal(rasqal_world* world);
1749 RASQAL_API
1750 void rasqal_free_xsd_decimal(rasqal_xsd_decimal* dec);
1751 RASQAL_API
1752 int rasqal_xsd_decimal_set_string(rasqal_xsd_decimal* dec, const char* string);
1753 RASQAL_API
1754 double rasqal_xsd_decimal_get_double(rasqal_xsd_decimal* dec);
1755 RASQAL_API
1756 long rasqal_xsd_decimal_get_long(rasqal_xsd_decimal* dec, int* error_p);
1757 RASQAL_API
1758 char* rasqal_xsd_decimal_as_string(rasqal_xsd_decimal* dec);
1759 RASQAL_API
1760 char* rasqal_xsd_decimal_as_counted_string(rasqal_xsd_decimal* dec, size_t* len_p);
1761 RASQAL_API
1762 int rasqal_xsd_decimal_set_long(rasqal_xsd_decimal* dec, long l);
1763 RASQAL_API
1764 int rasqal_xsd_decimal_set_double(rasqal_xsd_decimal* dec, double d);
1765 RASQAL_API
1766 int rasqal_xsd_decimal_print(rasqal_xsd_decimal* dec, FILE* stream);
1767 RASQAL_API
1768 int rasqal_xsd_decimal_add(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1769 RASQAL_API
1770 int rasqal_xsd_decimal_subtract(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1771 RASQAL_API
1772 int rasqal_xsd_decimal_multiply(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1773 RASQAL_API
1774 int rasqal_xsd_decimal_divide(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1775 RASQAL_API
1776 int rasqal_xsd_decimal_negate(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1777 RASQAL_API
1778 int rasqal_xsd_decimal_compare(rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1779 RASQAL_API
1780 int rasqal_xsd_decimal_equals(rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
1781 RASQAL_API
1782 int rasqal_xsd_decimal_is_zero(rasqal_xsd_decimal* d);
1783 RASQAL_API
1784 int rasqal_xsd_decimal_abs(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1785 RASQAL_API
1786 int rasqal_xsd_decimal_round(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1787 RASQAL_API
1788 int rasqal_xsd_decimal_ceil(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1789 RASQAL_API
1790 int rasqal_xsd_decimal_floor(rasqal_xsd_decimal* result, rasqal_xsd_decimal* a);
1793 /* date functions */
1794 RASQAL_API
1795 rasqal_xsd_date* rasqal_new_xsd_date(rasqal_world* world, const char *date_string);
1796 RASQAL_API
1797 void rasqal_free_xsd_date(rasqal_xsd_date* d);
1798 RASQAL_API
1799 char* rasqal_xsd_date_to_counted_string(const rasqal_xsd_date *date, size_t *len_p);
1800 RASQAL_API
1801 char* rasqal_xsd_date_to_string(const rasqal_xsd_date *d);
1802 RASQAL_API
1803 int rasqal_xsd_date_equals(const rasqal_xsd_date *d1, const rasqal_xsd_date *d2, int *incomparible_p);
1804 RASQAL_API
1805 int rasqal_xsd_date_compare(const rasqal_xsd_date *d1, const rasqal_xsd_date *d2, int *incomparible_p);
1807 /* datetime functions */
1808 RASQAL_API
1809 rasqal_xsd_datetime* rasqal_new_xsd_datetime(rasqal_world* world, const char *datetime_string);
1810 RASQAL_API
1811 rasqal_xsd_datetime* rasqal_new_xsd_datetime_from_unixtime(rasqal_world* world, time_t secs);
1812 RASQAL_API
1813 rasqal_xsd_datetime* rasqal_new_xsd_datetime_from_timeval(rasqal_world* world, struct timeval *tv);
1814 RASQAL_API
1815 rasqal_xsd_datetime* rasqal_new_xsd_datetime_from_xsd_date(rasqal_world* world, rasqal_xsd_date *date);
1816 RASQAL_API
1817 void rasqal_free_xsd_datetime(rasqal_xsd_datetime* dt);
1818 RASQAL_API
1819 char* rasqal_xsd_datetime_to_counted_string(const rasqal_xsd_datetime *dt, size_t *len_p);
1820 RASQAL_API
1821 char* rasqal_xsd_datetime_to_string(const rasqal_xsd_datetime *dt);
1822 RASQAL_API
1823 int rasqal_xsd_datetime_equals2(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2, int *incomparible_p);
1824 RASQAL_API RASQAL_DEPRECATED
1825 int rasqal_xsd_datetime_equals(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2);
1826 RASQAL_API
1827 int rasqal_xsd_datetime_compare2(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2, int *incomparible_p);
1828 RASQAL_API RASQAL_DEPRECATED
1829 int rasqal_xsd_datetime_compare(const rasqal_xsd_datetime *dt1, const rasqal_xsd_datetime *dt2);
1830 RASQAL_API
1831 rasqal_xsd_decimal* rasqal_xsd_datetime_get_seconds_as_decimal(rasqal_world* world, rasqal_xsd_datetime* dt);
1832 RASQAL_API
1833 int rasqal_xsd_datetime_set_from_timeval(rasqal_xsd_datetime *dt, struct timeval *tv);
1834 RASQAL_API
1835 int rasqal_xsd_datetime_set_from_unixtime(rasqal_xsd_datetime* dt, time_t clock);
1836 RASQAL_API
1837 time_t rasqal_xsd_datetime_get_as_unixtime(rasqal_xsd_datetime* dt);
1838 RASQAL_API
1839 struct timeval* rasqal_xsd_datetime_get_as_timeval(rasqal_xsd_datetime *dt);
1840 RASQAL_API
1841 char* rasqal_xsd_datetime_get_timezone_as_counted_string(rasqal_xsd_datetime *dt, size_t *len_p);
1842 RASQAL_API
1843 char* rasqal_xsd_datetime_get_tz_as_counted_string(rasqal_xsd_datetime* dt, size_t *len_p);
1846 /* regex utilities */
1847 RASQAL_API
1848 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);
1852 * rasqal_service:
1854 * Rasqal SPARQL Protocol Service
1856 typedef struct rasqal_service_s rasqal_service;
1858 RASQAL_API
1859 rasqal_service* rasqal_new_service(rasqal_world* world, raptor_uri* service_uri, const unsigned char* query_string, raptor_sequence* data_graphs);
1860 RASQAL_API
1861 void rasqal_free_service(rasqal_service* svc);
1862 RASQAL_API
1863 rasqal_query_results* rasqal_service_execute(rasqal_service* svc);
1864 RASQAL_API
1865 int rasqal_service_set_www(rasqal_service* svc, raptor_www* www);
1866 RASQAL_API
1867 int rasqal_service_set_format(rasqal_service* svc, const char *format);
1872 * rasqal_triple_parts:
1873 * @RASQAL_TRIPLE_NONE: no parts
1874 * @RASQAL_TRIPLE_SUBJECT: Subject present in a triple.
1875 * @RASQAL_TRIPLE_PREDICATE: Predicate present in a triple.
1876 * @RASQAL_TRIPLE_OBJECT: Object present in a triple.
1877 * @RASQAL_TRIPLE_ORIGIN: Origin/graph present in a triple.
1878 * @RASQAL_TRIPLE_GRAPH: Alias for RASQAL_TRIPLE_ORIGIN
1879 * @RASQAL_TRIPLE_SPO: Subject, Predicate and Object present in a triple.
1880 * @RASQAL_TRIPLE_SPOG: Subject, Predicate, Object, Graph present in a triple.
1882 * Flags for parts of a triple.
1884 typedef enum {
1885 RASQAL_TRIPLE_NONE = 0,
1886 RASQAL_TRIPLE_SUBJECT = 1,
1887 RASQAL_TRIPLE_PREDICATE= 2,
1888 RASQAL_TRIPLE_OBJECT = 4,
1889 RASQAL_TRIPLE_ORIGIN = 8,
1890 RASQAL_TRIPLE_GRAPH = RASQAL_TRIPLE_ORIGIN,
1891 RASQAL_TRIPLE_SPO = RASQAL_TRIPLE_SUBJECT | RASQAL_TRIPLE_PREDICATE | RASQAL_TRIPLE_OBJECT,
1892 RASQAL_TRIPLE_SPOG = RASQAL_TRIPLE_SPO | RASQAL_TRIPLE_GRAPH
1893 } rasqal_triple_parts;
1898 * rasqal_triples_match:
1899 * @world: rasqal_world object
1900 * @user_data: User data pointer for factory methods.
1901 * @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.
1902 * @next_match: Move to next match.
1903 * @is_end: Check for end of triple match - return non-0 if is end.
1904 * @finish: Finish triples match and destroy any allocated memory.
1905 * @is_exact: non-0 if triple to match is all literal constants
1906 * @finished: >0 if the match has finished
1908 * Triples match structure as initialised by #rasqal_triples_source
1909 * method init_triples_match.
1911 struct rasqal_triples_match_s {
1912 rasqal_world *world;
1914 void *user_data;
1916 rasqal_triple_parts (*bind_match)(struct rasqal_triples_match_s* rtm, void *user_data, rasqal_variable *bindings[4], rasqal_triple_parts parts);
1918 void (*next_match)(struct rasqal_triples_match_s* rtm, void *user_data);
1920 int (*is_end)(struct rasqal_triples_match_s* rtm, void *user_data);
1922 void (*finish)(struct rasqal_triples_match_s* rtm, void *user_data);
1924 int is_exact;
1926 int finished;
1928 typedef struct rasqal_triples_match_s rasqal_triples_match;
1932 * rasqal_triple_meta:
1933 * @bindings: Variable bindings for this triple+origin to set.
1934 * @triples_match: The matcher that is setting these bindings.
1935 * @context: Context data used by the matcher.
1936 * @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.
1937 * @is_exact: unused
1938 * @executed: unused
1940 * Metadata for triple pattern matching for one triple pattern.
1942 typedef struct {
1943 /* triple (subject, predicate, object) and origin */
1944 rasqal_variable* bindings[4];
1946 rasqal_triples_match *triples_match;
1948 void *context;
1950 rasqal_triple_parts parts;
1952 int is_exact;
1954 int executed;
1955 } rasqal_triple_meta;
1959 * RASQAL_TRIPLES_SOURCE_MIN_VERSION:
1961 * Lowest accepted @rasqal_triples_source API version
1963 #define RASQAL_TRIPLES_SOURCE_MIN_VERSION 1
1966 * RASQAL_TRIPLES_SOURCE_MAX_VERSION:
1968 * Highest accepted @rasqal_triples_source API version
1970 #define RASQAL_TRIPLES_SOURCE_MAX_VERSION 2
1974 * rasqal_triples_source_feature:
1975 * @RASQAL_TRIPLES_SOURCE_FEATURE_NONE: No feature
1976 * @RASQAL_TRIPLES_SOURCE_FEATURE_IOSTREAM_DATA_GRAPH: Support raptor_iostream data graphs
1978 * Optional features that may be supported by a triple source factory
1980 typedef enum {
1981 RASQAL_TRIPLES_SOURCE_FEATURE_NONE,
1982 RASQAL_TRIPLES_SOURCE_FEATURE_IOSTREAM_DATA_GRAPH
1983 } rasqal_triples_source_feature;
1987 * rasqal_triples_source:
1988 * @version: API version - only V1 is defined for now
1989 * @query: Source for this query.
1990 * @user_data: Context user data passed into the factory methods.
1991 * @init_triples_match: Factory method to initalise a new #rasqal_triples_match.
1992 * @triple_present: Factory method to return presence or absence of a complete triple.
1993 * @free_triples_source: Factory method to deallocate resources.
1994 * @support_feature: Factory method to test support for a feature, returning non-0 if supported
1996 * Triples source as initialised by a #rasqal_triples_source_factory.
1998 struct rasqal_triples_source_s {
1999 int version;
2001 rasqal_query* query;
2003 void *user_data;
2005 /* API v1 */
2006 int (*init_triples_match)(rasqal_triples_match* rtm, struct rasqal_triples_source_s* rts, void *user_data, rasqal_triple_meta *m, rasqal_triple *t);
2008 int (*triple_present)(struct rasqal_triples_source_s* rts, void *user_data, rasqal_triple *t);
2010 void (*free_triples_source)(void *user_data);
2012 /* API v2 onwards */
2013 int (*support_feature)(void *user_data, rasqal_triples_source_feature feature);
2015 typedef struct rasqal_triples_source_s rasqal_triples_source;
2019 * RASQAL_TRIPLES_SOURCE_FACTORY_MIN_VERSION:
2021 * Lowest accepted @rasqal_triples_source_factory API version
2023 #define RASQAL_TRIPLES_SOURCE_FACTORY_MIN_VERSION 1
2026 * RASQAL_TRIPLES_SOURCE_FACTORY_MAX_VERSION:
2028 * Highest accepted @rasqal_triples_source_factory API version
2030 #define RASQAL_TRIPLES_SOURCE_FACTORY_MAX_VERSION 2
2034 * rasqal_triples_error_handler:
2035 * @query: query object
2036 * @locator: error locator (or NULL)
2037 * @message: error message
2039 * Triples source factory error handler callback.
2041 typedef void (*rasqal_triples_error_handler)(rasqal_query* query, raptor_locator* locator, const char* message);
2045 * rasqal_triples_source_factory:
2046 * @version: API factory version from 1 to 2
2047 * @user_data: User data for triples_source_factory.
2048 * @user_data_size: Size of @user_data for new_triples_source.
2049 * @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)
2050 * @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)
2052 * A factory that initialises #rasqal_triples_source structures to
2053 * returning matches to a triple pattern across the dataset formed
2054 * from the data graphs recorded in the @query object.
2056 typedef struct {
2057 int version;
2059 void *user_data;
2060 size_t user_data_size;
2062 /* API v1 */
2063 int (*new_triples_source)(rasqal_query* query, void *factory_user_data, void *user_data, rasqal_triples_source* rts);
2064 /* API v2 onwards */
2065 int (*init_triples_source)(rasqal_query* query, void *factory_user_data, void *user_data, rasqal_triples_source* rts, rasqal_triples_error_handler handler);
2066 } rasqal_triples_source_factory;
2070 * rasqal_triples_source_factory_register_fn:
2071 * @factory: factory to register
2073 * Register a factory for generating triples sources #rasqal_triples_source
2075 * Return value: non-0 on failure
2077 typedef int (*rasqal_triples_source_factory_register_fn)(rasqal_triples_source_factory *factory);
2080 /* set the triples_source_factory */
2081 RASQAL_API
2082 int rasqal_set_triples_source_factory(rasqal_world* world, rasqal_triples_source_factory_register_fn register_fn, void* user_data);
2086 /* The info below is solely for gtk-doc - ignore it */
2089 * raptor_world:
2091 * Internal
2095 * RASQAL_QUERY_RESULTS_FORMATTER_DECLARED:
2097 * Internal
2101 * RASQAL_WORLD_DECLARED:
2103 * Internal
2108 * RASQAL_LITERAL_UDT_DEFINED
2110 * Internal
2114 * rasqal_expression_s:
2115 * @usage: Internal
2116 * @op: Internal
2117 * @arg1: Internal
2118 * @arg2: Internal
2119 * @arg3: Internal
2120 * @literal: Internal
2121 * @value: Internal
2122 * @name: Internal
2123 * @args: Internal
2124 * @params: Internal
2125 * @flags: Internal
2127 * Internal - see #rasqal_expression.
2132 * bind_match:
2133 * @rtm: triples match context
2134 * @user_data: user data
2135 * @bindings: variable binding for parts of triple (s, p, o, g)
2136 * @parts: parts of triple to match
2138 * Internal - see #rasqal_triples_match
2140 * Return value: match parts
2144 * next_match:
2145 * @rtm: triples match context
2146 * @user_data: user data
2148 * Internal - see #rasqal_triples_match
2152 * is_end:
2153 * @rtm: triples match context
2154 * @user_data: user data
2156 * Internal - see #rasqal_triples_match
2158 * Return value: non-0 if end of match
2162 * finish:
2163 * @rtm: triples match context
2164 * @user_data: user data
2166 * Internal - see #rasqal_triples_match
2170 * init_triples_match:
2171 * @rtm: triples match context
2172 * @rts: triples match source
2173 * @user_data: user data
2174 * @m: triple meta
2175 * @t: triple
2177 * Internal - see #rasqal_triples_source
2179 * Return value: non-0 on failure
2183 * triple_present:
2184 * @rts: triples match source
2185 * @user_data: user data
2186 * @t: triple to test for presence
2188 * Internal - see #rasqal_triples_source
2190 * Return value: non-0 on failure
2194 * free_triples_source:
2195 * @user_data: user data
2197 * Internal - see #rasqal_triples_source
2201 * support_feature:
2202 * @user_data: user data
2203 * @feature: feature to test
2205 * Internal - see #rasqal_triples_source
2207 * Return value: non-0 if supported
2211 * rasqal_variables_table:
2213 * Internal - for now
2217 #ifdef __cplusplus
2219 #endif
2221 #endif