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.
38 * Rasqal library version number
40 * Format: major * 10000 + minor * 100 + release
42 #define RASQAL_VERSION 930
45 * RASQAL_VERSION_STRING:
47 * Rasqal library version string
49 #define RASQAL_VERSION_STRING "0.9.30"
52 * RASQAL_VERSION_MAJOR:
54 * Rasqal library major version
56 #define RASQAL_VERSION_MAJOR 0
59 * RASQAL_VERSION_MINOR:
61 * Rasqal library minor version
63 #define RASQAL_VERSION_MINOR 9
66 * RASQAL_VERSION_RELEASE:
68 * Rasqal library release
70 #define RASQAL_VERSION_RELEASE 30
76 * Macro for wrapping API function call declarations.
83 # define _declspec(x) __declspec(x)
88 # ifdef RASQAL_INTERNAL
89 # define RASQAL_API _declspec(dllexport)
91 # define RASQAL_API _declspec(dllimport)
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))
105 #define RASQAL_DEPRECATED
109 #ifndef LIBRDF_OBJC_FRAMEWORK
112 #include <Redland/raptor.h>
116 #include <sys/time.h>
125 * rasqal_short_copyright_string:
127 * Short copyright string (one line).
130 extern const char * const rasqal_short_copyright_string
;
133 * rasqal_copyright_string:
135 * Copyright string (multiple lines).
138 extern const char * const rasqal_copyright_string
;
141 * rasqal_version_string:
143 * Rasqal version as a string.
146 extern const char * const rasqal_version_string
;
149 * rasqal_version_major:
151 * Rasqal major version number.
154 extern const unsigned int rasqal_version_major
;
157 * rasqal_version_minor:
159 * Rasqal minor version number.
162 extern const unsigned int rasqal_version_minor
;
165 * rasqal_version_release:
167 * Rasqal release version number.
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
180 extern const unsigned int rasqal_version_decimal
;
183 * rasqal_license_string:
185 * Rasqal license string.
188 extern const char * const rasqal_license_string
;
191 * rasqal_home_url_string:
193 * Rasqal home page URL.
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
215 * Rasqal world class.
217 typedef struct rasqal_world_s rasqal_world
;
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
;
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
;
266 * @RASQAL_FEATURE_NO_NET: Deny network requests.
267 * @RASQAL_FEATURE_RAND_SEED: Set rand() / rand_r() seed
268 * @RASQAL_FEATURE_LAST: Internal.
272 * None currently defined.
275 RASQAL_FEATURE_NO_NET
,
276 RASQAL_FEATURE_RAND_SEED
,
277 RASQAL_FEATURE_LAST
= RASQAL_FEATURE_RAND_SEED
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.
296 const unsigned char *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
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
;
326 * @vars_table: variables table that owns this variable
327 * @name: Variable name.
328 * @value: Variable value or NULL if unbound.
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.
341 rasqal_variables_table
* vars_table
;
342 const unsigned char *name
;
343 rasqal_literal
* value
;
345 rasqal_variable_type type
;
346 struct rasqal_expression_s
* expression
;
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.
364 RASQAL_DATA_GRAPH_NONE
= 0,
365 RASQAL_DATA_GRAPH_NAMED
= 1,
366 RASQAL_DATA_GRAPH_BACKGROUND
= 2,
367 } rasqal_data_graph_flags
;
372 * @world: rasqal_world object
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
395 raptor_uri
* name_uri
;
399 raptor_uri
* format_uri
;
400 raptor_iostream
* iostr
;
401 raptor_uri
* base_uri
;
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.
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
450 RASQAL_LITERAL_UNKNOWN
,
451 RASQAL_LITERAL_BLANK
,
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
,
462 RASQAL_LITERAL_FIRST_XSD
= RASQAL_LITERAL_XSD_STRING
,
464 RASQAL_LITERAL_LAST_XSD
= RASQAL_LITERAL_DATETIME
,
466 RASQAL_LITERAL_PATTERN
,
467 RASQAL_LITERAL_QNAME
,
468 RASQAL_LITERAL_VARIABLE
,
470 RASQAL_LITERAL_INTEGER_SUBTYPE
,
473 RASQAL_LITERAL_LAST
= RASQAL_LITERAL_DATE
474 } rasqal_literal_type
;
476 #define RASQAL_LITERAL_UDT_DEFINED 1
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)
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'
521 /* the following fields are integer values not characters */
524 signed short timezone_minutes
;
525 time_t time_on_timeline
;
531 * rasqal_xsd_datetime:
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'
558 /* the following fields are integer values not characters */
562 signed int microseconds
;
563 signed short timezone_minutes
;
564 time_t time_on_timeline
;
566 } rasqal_xsd_datetime
;
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
{
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
;
598 /* integer and boolean types */
600 /* double and float */
602 /* uri (can be temporarily NULL if a qname, see flags below) */
605 rasqal_variable
* variable
;
607 rasqal_xsd_decimal
* decimal
;
609 rasqal_xsd_datetime
* datetime
;
611 rasqal_xsd_date
* date
;
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
;
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.
751 RASQAL_EXPR_STR_MATCH
,
752 RASQAL_EXPR_STR_NMATCH
,
756 RASQAL_EXPR_FUNCTION
,
760 RASQAL_EXPR_DATATYPE
,
763 RASQAL_EXPR_ISLITERAL
,
765 RASQAL_EXPR_ORDER_COND_ASC
,
766 RASQAL_EXPR_ORDER_COND_DESC
,
767 RASQAL_EXPR_LANGMATCHES
,
769 RASQAL_EXPR_GROUP_COND_ASC
,
770 RASQAL_EXPR_GROUP_COND_DESC
,
773 RASQAL_EXPR_SAMETERM
,
778 RASQAL_EXPR_COALESCE
,
785 RASQAL_EXPR_GROUP_CONCAT
,
789 RASQAL_EXPR_ISNUMERIC
,
796 RASQAL_EXPR_TIMEZONE
,
797 RASQAL_EXPR_CURRENT_DATETIME
,
799 RASQAL_EXPR_FROM_UNIXTIME
,
800 RASQAL_EXPR_TO_UNIXTIME
,
806 RASQAL_EXPR_STRSTARTS
,
808 RASQAL_EXPR_CONTAINS
,
809 RASQAL_EXPR_ENCODE_FOR_URI
,
822 RASQAL_EXPR_STRBEFORE
,
823 RASQAL_EXPR_STRAFTER
,
828 RASQAL_EXPR_LAST
= RASQAL_EXPR_STRUUID
833 * rasqal_expression_flags:
834 * @RASQAL_EXPR_FLAG_DISTINCT: Distinct
835 * @RASQAL_EXPR_FLAG_AGGREGATE: Aggregate function expression
837 * Flags for expressions.
840 RASQAL_EXPR_FLAG_DISTINCT
= 1,
841 RASQAL_EXPR_FLAG_AGGREGATE
= 2
842 } rasqal_expression_flags
;
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
{
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
;
877 raptor_sequence
* args
;
879 raptor_sequence
* params
;
881 struct rasqal_expression_s
* arg4
;
883 typedef struct rasqal_expression_s rasqal_expression
;
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.
900 rasqal_literal
* subject
;
901 rasqal_literal
* predicate
;
902 rasqal_literal
* object
;
903 rasqal_literal
* origin
;
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.
916 RASQAL_PATTERN_FLAGS_OPTIONAL
= 1,
918 RASQAL_PATTERN_FLAGS_LAST
= RASQAL_PATTERN_FLAGS_OPTIONAL
919 } rasqal_pattern_flags
;
923 * rasqal_generate_bnodeid_handler:
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
);
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
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,
962 RASQAL_QUERY_VERB_LAST
= RASQAL_QUERY_VERB_UPDATE
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
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.
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,
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
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.
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
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
;
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
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
);
1141 /* Public functions */
1144 rasqal_world
*rasqal_new_world(void);
1146 int rasqal_world_open(rasqal_world
* world
);
1148 void rasqal_free_world(rasqal_world
* world
);
1151 void rasqal_world_set_raptor(rasqal_world
* world
, raptor_world
* raptor_world_ptr
);
1153 raptor_world
*rasqal_world_get_raptor(rasqal_world
* world
);
1156 void rasqal_world_set_log_handler(rasqal_world
* world
, void *user_data
, raptor_log_handler handler
);
1159 int rasqal_world_set_default_generate_bnodeid_parameters(rasqal_world
* world
, char *prefix
, int base
);
1161 int rasqal_world_set_generate_bnodeid_handler(rasqal_world
* world
, void *user_data
, rasqal_generate_bnodeid_handler handler
);
1164 int rasqal_world_set_warning_level(rasqal_world
* world
, unsigned int warning_level
);
1167 const raptor_syntax_description
* rasqal_world_get_query_results_format_description(rasqal_world
* world
, unsigned int counter
);
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
);
1174 int rasqal_features_enumerate(rasqal_world
* world
, const rasqal_feature feature
, const char **name
, raptor_uri
**uri
, const char **label
);
1176 unsigned int rasqal_get_feature_count(void);
1178 rasqal_feature
rasqal_feature_from_uri(rasqal_world
* world
, raptor_uri
*uri
);
1180 int rasqal_feature_value_type(const rasqal_feature feature
);
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
);
1190 int rasqal_language_name_check(rasqal_world
* world
, const char *name
);
1197 rasqal_query
* rasqal_new_query(rasqal_world
* world
, const char *name
, const unsigned char *uri
);
1201 void rasqal_free_query(rasqal_query
* query
);
1205 const char* rasqal_query_get_name(rasqal_query
* query
);
1207 const char* rasqal_query_get_label(rasqal_query
* query
);
1211 int rasqal_query_set_feature(rasqal_query
* query
, rasqal_feature feature
, int value
);
1213 int rasqal_query_set_feature_string(rasqal_query
*query
, rasqal_feature feature
, const unsigned char *value
);
1215 int rasqal_query_get_feature(rasqal_query
*query
, rasqal_feature feature
);
1217 const unsigned char* rasqal_query_get_feature_string(rasqal_query
*query
, rasqal_feature feature
);
1220 rasqal_query_verb
rasqal_query_get_verb(rasqal_query
* query
);
1222 int rasqal_query_get_wildcard(rasqal_query
* query
);
1224 void rasqal_query_set_wildcard(rasqal_query
* query
, int wildcard
);
1226 int rasqal_query_get_distinct(rasqal_query
* query
);
1228 void rasqal_query_set_distinct(rasqal_query
* query
, int distinct_mode
);
1230 int rasqal_query_get_explain(rasqal_query
* query
);
1232 void rasqal_query_set_explain(rasqal_query
* query
, int is_explain
);
1234 int rasqal_query_get_limit(rasqal_query
* query
);
1236 void rasqal_query_set_limit(rasqal_query
* query
, int limit
);
1238 int rasqal_query_get_offset(rasqal_query
* query
);
1240 void rasqal_query_set_offset(rasqal_query
* query
, int offset
);
1243 int rasqal_query_add_data_graph(rasqal_query
* query
, rasqal_data_graph
* data_graph
);
1245 int rasqal_query_add_data_graphs(rasqal_query
* query
, raptor_sequence
* data_graphs
);
1248 raptor_sequence
* rasqal_query_get_data_graph_sequence(rasqal_query
* query
);
1250 rasqal_data_graph
* rasqal_query_get_data_graph(rasqal_query
* query
, int idx
);
1252 int rasqal_query_dataset_contains_named_graph(rasqal_query
* query
, raptor_uri
*graph_uri
);
1255 int rasqal_query_add_variable(rasqal_query
* query
, rasqal_variable
* var
);
1257 raptor_sequence
* rasqal_query_get_bound_variable_sequence(rasqal_query
* query
);
1259 raptor_sequence
* rasqal_query_get_describe_sequence(rasqal_query
* query
);
1261 raptor_sequence
* rasqal_query_get_anonymous_variable_sequence(rasqal_query
* query
);
1263 raptor_sequence
* rasqal_query_get_all_variable_sequence(rasqal_query
* query
);
1265 rasqal_variable
* rasqal_query_get_variable(rasqal_query
* query
, int idx
);
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
);
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
);
1275 raptor_sequence
* rasqal_query_get_triple_sequence(rasqal_query
* query
);
1277 rasqal_triple
* rasqal_query_get_triple(rasqal_query
* query
, int idx
);
1279 int rasqal_query_add_prefix(rasqal_query
* query
, rasqal_prefix
* prefix
);
1281 raptor_sequence
* rasqal_query_get_prefix_sequence(rasqal_query
* query
);
1283 rasqal_prefix
* rasqal_query_get_prefix(rasqal_query
* query
, int idx
);
1285 raptor_sequence
* rasqal_query_get_order_conditions_sequence(rasqal_query
* query
);
1287 rasqal_expression
* rasqal_query_get_order_condition(rasqal_query
* query
, int idx
);
1289 raptor_sequence
* rasqal_query_get_group_conditions_sequence(rasqal_query
* query
);
1291 rasqal_expression
* rasqal_query_get_group_condition(rasqal_query
* query
, int idx
);
1293 raptor_sequence
* rasqal_query_get_having_conditions_sequence(rasqal_query
* query
);
1295 rasqal_expression
* rasqal_query_get_having_condition(rasqal_query
* query
, int idx
);
1297 raptor_sequence
* rasqal_query_get_construct_triples_sequence(rasqal_query
* query
);
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
);
1303 int rasqal_query_graph_pattern_visit2(rasqal_query
* query
, rasqal_graph_pattern_visit_fn visit_fn
, void* data
);
1305 int rasqal_query_write(raptor_iostream
* iostr
, rasqal_query
* query
, raptor_uri
* format_uri
, raptor_uri
* base_uri
);
1309 raptor_sequence
* rasqal_query_get_update_operations_sequence(rasqal_query
* query
);
1311 rasqal_update_operation
* rasqal_query_get_update_operation(rasqal_query
* query
, int idx
);
1314 int rasqal_query_set_store_results(rasqal_query
* query
, int store_results
);
1316 /* graph patterns */
1318 rasqal_graph_pattern
* rasqal_query_get_query_graph_pattern(rasqal_query
* query
);
1320 raptor_sequence
* rasqal_query_get_graph_pattern_sequence(rasqal_query
* query
);
1322 rasqal_graph_pattern
* rasqal_query_get_graph_pattern(rasqal_query
* query
, int idx
);
1324 int rasqal_graph_pattern_add_sub_graph_pattern(rasqal_graph_pattern
* graph_pattern
, rasqal_graph_pattern
* sub_graph_pattern
);
1326 rasqal_triple
* rasqal_graph_pattern_get_triple(rasqal_graph_pattern
* graph_pattern
, int idx
);
1328 raptor_sequence
* rasqal_graph_pattern_get_sub_graph_pattern_sequence(rasqal_graph_pattern
* graph_pattern
);
1330 rasqal_graph_pattern
* rasqal_graph_pattern_get_sub_graph_pattern(rasqal_graph_pattern
* graph_pattern
, int idx
);
1332 rasqal_graph_pattern_operator
rasqal_graph_pattern_get_operator(rasqal_graph_pattern
* graph_pattern
);
1334 const char* rasqal_graph_pattern_operator_as_string(rasqal_graph_pattern_operator op
);
1336 int rasqal_graph_pattern_print(rasqal_graph_pattern
* gp
, FILE* fh
);
1338 int rasqal_graph_pattern_set_filter_expression(rasqal_graph_pattern
* gp
, rasqal_expression
* expr
);
1340 rasqal_expression
* rasqal_graph_pattern_get_filter_expression(rasqal_graph_pattern
* gp
);
1342 int rasqal_graph_pattern_visit(rasqal_query
* query
, rasqal_graph_pattern
*gp
, rasqal_graph_pattern_visit_fn fn
, void* user_data
);
1344 int rasqal_graph_pattern_get_index(rasqal_graph_pattern
* gp
);
1346 int rasqal_graph_pattern_variable_bound_in(rasqal_graph_pattern
*gp
, rasqal_variable
*v
);
1348 rasqal_literal
* rasqal_graph_pattern_get_origin(rasqal_graph_pattern
* graph_pattern
);
1350 rasqal_variable
* rasqal_graph_pattern_get_variable(rasqal_graph_pattern
* graph_pattern
);
1352 rasqal_literal
* rasqal_graph_pattern_get_service(rasqal_graph_pattern
* graph_pattern
);
1354 raptor_sequence
* rasqal_graph_pattern_get_flattened_triples(rasqal_query
* query
, rasqal_graph_pattern
* graph_pattern
);
1356 /* Utility methods */
1358 const char* rasqal_query_verb_as_string(rasqal_query_verb verb
);
1360 int rasqal_query_print(rasqal_query
* query
, FILE* fh
);
1364 int rasqal_query_prepare(rasqal_query
* query
, const unsigned char *query_string
, raptor_uri
*base_uri
);
1366 rasqal_query_results
* rasqal_query_execute(rasqal_query
* query
);
1369 void* rasqal_query_get_user_data(rasqal_query
* query
);
1371 void rasqal_query_set_user_data(rasqal_query
* query
, void *user_data
);
1374 raptor_sequence
* rasqal_query_get_bindings_variables_sequence(rasqal_query
* query
);
1376 rasqal_variable
* rasqal_query_get_bindings_variable(rasqal_query
* query
, int idx
);
1378 raptor_sequence
* rasqal_query_get_bindings_rows_sequence(rasqal_query
* query
);
1380 rasqal_row
* rasqal_query_get_bindings_row(rasqal_query
* query
, int idx
);
1382 rasqal_query_results_type
rasqal_query_get_result_type(rasqal_query
* query
);
1386 rasqal_query_results
* rasqal_new_query_results(rasqal_world
* world
, rasqal_query
* query
, rasqal_query_results_type type
, rasqal_variables_table
* vars_table
);
1388 void rasqal_free_query_results(rasqal_query_results
*query_results
);
1391 rasqal_query
* rasqal_query_results_get_query(rasqal_query_results
* query_results
);
1393 /* Bindings result format */
1395 rasqal_query_results_type
rasqal_query_results_get_type(rasqal_query_results
* query_results
);
1397 int rasqal_query_results_is_bindings(rasqal_query_results
*query_results
);
1399 int rasqal_query_results_get_count(rasqal_query_results
*query_results
);
1401 int rasqal_query_results_next(rasqal_query_results
*query_results
);
1403 int rasqal_query_results_finished(rasqal_query_results
*query_results
);
1405 int rasqal_query_results_get_bindings(rasqal_query_results
*query_results
, const unsigned char ***names
, rasqal_literal
***values
);
1407 rasqal_literal
* rasqal_query_results_get_binding_value(rasqal_query_results
*query_results
, int offset
);
1409 const unsigned char* rasqal_query_results_get_binding_name(rasqal_query_results
*query_results
, int offset
);
1411 rasqal_literal
* rasqal_query_results_get_binding_value_by_name(rasqal_query_results
*query_results
, const unsigned char *name
);
1413 int rasqal_query_results_get_bindings_count(rasqal_query_results
*query_results
);
1415 int rasqal_query_results_add_row(rasqal_query_results
* query_results
, rasqal_row
* row
);
1417 rasqal_row
* rasqal_query_results_get_row_by_offset(rasqal_query_results
* query_results
, int result_offset
);
1419 /* Boolean result format */
1421 int rasqal_query_results_is_boolean(rasqal_query_results
*query_results
);
1423 int rasqal_query_results_get_boolean(rasqal_query_results
*query_results
);
1425 /* Graph result format */
1427 int rasqal_query_results_is_graph(rasqal_query_results
*query_results
);
1429 raptor_statement
* rasqal_query_results_get_triple(rasqal_query_results
*query_results
);
1431 int rasqal_query_results_next_triple(rasqal_query_results
*query_results
);
1433 /* Syntax result format */
1435 int rasqal_query_results_is_syntax(rasqal_query_results
* query_results
);
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
);
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
);
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.
1455 RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER
= 1,
1456 RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER
= 2
1457 } rasqal_query_results_format_flags
;
1461 int rasqal_query_results_formats_check(rasqal_world
* world
, const char *name
, raptor_uri
* uri
, const char *mime_type
, int flags
);
1463 rasqal_query_results_formatter
* rasqal_new_query_results_formatter(rasqal_world
* world
, const char *name
, const char *mime_type
, raptor_uri
* format_uri
);
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
);
1467 void rasqal_free_query_results_formatter(rasqal_query_results_formatter
* formatter
);
1469 int rasqal_query_results_formatter_write(raptor_iostream
*iostr
, rasqal_query_results_formatter
* formatter
, rasqal_query_results
* results
, raptor_uri
*base_uri
);
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
);
1474 int rasqal_query_iostream_write_escaped_counted_string(rasqal_query
* query
, raptor_iostream
* iostr
, const unsigned char* string
, size_t len
);
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 */
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
);
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
);
1485 rasqal_data_graph
* rasqal_new_data_graph_from_data_graph(rasqal_data_graph
* dg
);
1487 void rasqal_free_data_graph(rasqal_data_graph
* dg
);
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()
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
;
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()
1533 rasqal_world
*world
;
1534 raptor_uri
* base_uri
;
1535 raptor_locator
*locator
;
1538 rasqal_random
* random
;
1539 } rasqal_evaluation_context
;
1542 /* Expression class */
1544 rasqal_expression
* rasqal_new_0op_expression(rasqal_world
* world
, rasqal_op op
);
1546 rasqal_expression
* rasqal_new_1op_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg
);
1548 rasqal_expression
* rasqal_new_2op_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, rasqal_expression
* arg2
);
1550 rasqal_expression
* rasqal_new_3op_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, rasqal_expression
* arg2
, rasqal_expression
* arg3
);
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
);
1554 rasqal_expression
* rasqal_new_string_op_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, rasqal_literal
* literal
);
1556 rasqal_expression
* rasqal_new_literal_expression(rasqal_world
* world
, rasqal_literal
* literal
);
1558 rasqal_expression
* rasqal_new_function_expression(rasqal_world
* world
, raptor_uri
* name
, raptor_sequence
* args
, raptor_sequence
* params
, unsigned int flags
);
1560 rasqal_expression
* rasqal_new_aggregate_function_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, raptor_sequence
* params
, unsigned int flags
);
1562 rasqal_expression
* rasqal_new_cast_expression(rasqal_world
* world
, raptor_uri
* name
, rasqal_expression
*value
);
1564 rasqal_expression
* rasqal_new_expr_seq_expression(rasqal_world
* world
, rasqal_op op
, raptor_sequence
* args
);
1566 rasqal_expression
* rasqal_new_set_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, raptor_sequence
* args
);
1568 rasqal_expression
* rasqal_new_group_concat_expression(rasqal_world
* world
, int flags
, raptor_sequence
* args
, rasqal_literal
* separator
);
1570 rasqal_expression
* rasqal_new_expression_from_expression(rasqal_expression
* e
);
1573 void rasqal_free_expression(rasqal_expression
* e
);
1575 void rasqal_expression_print_op(rasqal_expression
* e
, FILE* fh
);
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
);
1581 rasqal_literal
* rasqal_expression_evaluate2(rasqal_expression
*e
, rasqal_evaluation_context
* eval_context
, int *error_p
);
1583 const char* rasqal_expression_op_label(rasqal_op op
);
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
);
1599 int rasqal_expression_visit(rasqal_expression
* e
, rasqal_expression_visit_fn fn
, void *user_data
);
1602 rasqal_evaluation_context
* rasqal_new_evaluation_context(rasqal_world
* world
, raptor_locator
* locator
, int flags
);
1604 void rasqal_free_evaluation_context(rasqal_evaluation_context
* eval_context
);
1606 int rasqal_evaluation_context_set_base_uri(rasqal_evaluation_context
* eval_context
, raptor_uri
*base_uri
);
1608 int rasqal_evaluation_context_set_rand_seed(rasqal_evaluation_context
* eval_context
, unsigned int seed
);
1613 rasqal_literal
* rasqal_new_integer_literal(rasqal_world
* world
, rasqal_literal_type type
, int integer
);
1615 rasqal_literal
* rasqal_new_numeric_literal_from_long(rasqal_world
* world
, rasqal_literal_type type
, long value
);
1617 rasqal_literal
* rasqal_new_typed_literal(rasqal_world
* world
, rasqal_literal_type type
, const unsigned char* string
);
1619 rasqal_literal
* rasqal_new_double_literal(rasqal_world
* world
, double d
);
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
);
1625 rasqal_literal
* rasqal_new_uri_literal(rasqal_world
* world
, raptor_uri
* uri
);
1627 rasqal_literal
* rasqal_new_pattern_literal(rasqal_world
* world
, const unsigned char *pattern
, const char *flags
);
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
);
1631 rasqal_literal
* rasqal_new_simple_literal(rasqal_world
* world
, rasqal_literal_type type
, const unsigned char *string
);
1633 rasqal_literal
* rasqal_new_boolean_literal(rasqal_world
* world
, int value
);
1635 rasqal_literal
* rasqal_new_variable_literal(rasqal_world
* world
, rasqal_variable
*variable
);
1637 rasqal_literal
* rasqal_new_decimal_literal(rasqal_world
* world
, const unsigned char *string
);
1639 rasqal_literal
* rasqal_new_decimal_literal_from_decimal(rasqal_world
* world
, const unsigned char *string
, rasqal_xsd_decimal
* decimal
);
1641 rasqal_literal
* rasqal_new_datetime_literal_from_datetime(rasqal_world
* world
, rasqal_xsd_datetime
* dt
);
1645 rasqal_literal
* rasqal_new_literal_from_literal(rasqal_literal
* l
);
1647 void rasqal_free_literal(rasqal_literal
* l
);
1649 int rasqal_literal_print(rasqal_literal
* l
, FILE* fh
);
1651 const char* rasqal_literal_type_label(rasqal_literal_type type
);
1653 void rasqal_literal_print_type(rasqal_literal
* l
, FILE* fh
);
1655 rasqal_variable
* rasqal_literal_as_variable(rasqal_literal
* l
);
1657 const unsigned char* rasqal_literal_as_counted_string(rasqal_literal
* l
, size_t *len_p
, int flags
, int *error_p
);
1659 const unsigned char* rasqal_literal_as_string(rasqal_literal
* l
);
1661 const unsigned char* rasqal_literal_as_string_flags(rasqal_literal
* l
, int flags
, int *error_p
);
1663 rasqal_literal
* rasqal_literal_as_node(rasqal_literal
* l
);
1665 raptor_uri
* rasqal_literal_datatype(rasqal_literal
* l
);
1667 rasqal_literal
* rasqal_literal_value(rasqal_literal
* l
);
1670 int rasqal_literal_compare(rasqal_literal
* l1
, rasqal_literal
* l2
, int flags
, int *error_p
);
1672 int rasqal_literal_equals(rasqal_literal
* l1
, rasqal_literal
* l2
);
1674 int rasqal_literal_same_term(rasqal_literal
* l1
, rasqal_literal
* l2
);
1676 rasqal_literal_type
rasqal_literal_get_rdf_term_type(rasqal_literal
* l
);
1678 int rasqal_literal_is_rdf_literal(rasqal_literal
* l
);
1682 rasqal_prefix
* rasqal_new_prefix(rasqal_world
* world
, const unsigned char* prefix
, raptor_uri
* uri
);
1684 void rasqal_free_prefix(rasqal_prefix
* p
);
1686 int rasqal_prefix_print(rasqal_prefix
* p
, FILE* fh
);
1691 rasqal_row
* rasqal_new_row_for_size(rasqal_world
* world
, int size
);
1693 void rasqal_free_row(rasqal_row
* row
);
1695 int rasqal_row_set_value_at(rasqal_row
* row
, int offset
, rasqal_literal
* value
);
1700 rasqal_triple
* rasqal_new_triple(rasqal_literal
* subject
, rasqal_literal
* predicate
, rasqal_literal
* object
);
1702 rasqal_triple
* rasqal_new_triple_from_triple(rasqal_triple
* t
);
1704 void rasqal_free_triple(rasqal_triple
* t
);
1706 int rasqal_triple_print(rasqal_triple
* t
, FILE* fh
);
1708 void rasqal_triple_set_origin(rasqal_triple
* t
, rasqal_literal
*l
);
1710 rasqal_literal
* rasqal_triple_get_origin(rasqal_triple
* t
);
1712 /* Variable class */
1714 rasqal_variable
* rasqal_new_variable_from_variable(rasqal_variable
* v
);
1716 void rasqal_free_variable(rasqal_variable
* v
);
1718 int rasqal_variable_print(rasqal_variable
* v
, FILE* fh
);
1720 void rasqal_variable_set_value(rasqal_variable
* v
, rasqal_literal
* l
);
1723 /* Variables Table */
1725 rasqal_variables_table
* rasqal_new_variables_table(rasqal_world
* world
);
1727 void rasqal_free_variables_table(rasqal_variables_table
* vt
);
1729 rasqal_variable
* rasqal_variables_table_add(rasqal_variables_table
* vt
, rasqal_variable_type type
, const unsigned char *name
, rasqal_literal
*value
);
1731 int rasqal_variables_table_add_variable(rasqal_variables_table
* vt
, rasqal_variable
* variable
);
1733 rasqal_variable
* rasqal_variables_table_get_by_name(rasqal_variables_table
* vt
, rasqal_variable_type type
, const unsigned char *name
);
1735 int rasqal_variables_table_contains(rasqal_variables_table
* vt
, rasqal_variable_type type
, const unsigned char *name
);
1737 /* memory functions */
1739 void rasqal_free_memory(void *ptr
);
1741 void* rasqal_alloc_memory(size_t size
);
1743 void* rasqal_calloc_memory(size_t nmemb
, size_t size
);
1746 /* decimal functions */
1748 rasqal_xsd_decimal
* rasqal_new_xsd_decimal(rasqal_world
* world
);
1750 void rasqal_free_xsd_decimal(rasqal_xsd_decimal
* dec
);
1752 int rasqal_xsd_decimal_set_string(rasqal_xsd_decimal
* dec
, const char* string
);
1754 double rasqal_xsd_decimal_get_double(rasqal_xsd_decimal
* dec
);
1756 long rasqal_xsd_decimal_get_long(rasqal_xsd_decimal
* dec
, int* error_p
);
1758 char* rasqal_xsd_decimal_as_string(rasqal_xsd_decimal
* dec
);
1760 char* rasqal_xsd_decimal_as_counted_string(rasqal_xsd_decimal
* dec
, size_t* len_p
);
1762 int rasqal_xsd_decimal_set_long(rasqal_xsd_decimal
* dec
, long l
);
1764 int rasqal_xsd_decimal_set_double(rasqal_xsd_decimal
* dec
, double d
);
1766 int rasqal_xsd_decimal_print(rasqal_xsd_decimal
* dec
, FILE* stream
);
1768 int rasqal_xsd_decimal_add(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1770 int rasqal_xsd_decimal_subtract(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1772 int rasqal_xsd_decimal_multiply(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1774 int rasqal_xsd_decimal_divide(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1776 int rasqal_xsd_decimal_negate(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1778 int rasqal_xsd_decimal_compare(rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1780 int rasqal_xsd_decimal_equals(rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1782 int rasqal_xsd_decimal_is_zero(rasqal_xsd_decimal
* d
);
1784 int rasqal_xsd_decimal_abs(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1786 int rasqal_xsd_decimal_round(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1788 int rasqal_xsd_decimal_ceil(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1790 int rasqal_xsd_decimal_floor(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1793 /* date functions */
1795 rasqal_xsd_date
* rasqal_new_xsd_date(rasqal_world
* world
, const char *date_string
);
1797 void rasqal_free_xsd_date(rasqal_xsd_date
* d
);
1799 char* rasqal_xsd_date_to_counted_string(const rasqal_xsd_date
*date
, size_t *len_p
);
1801 char* rasqal_xsd_date_to_string(const rasqal_xsd_date
*d
);
1803 int rasqal_xsd_date_equals(const rasqal_xsd_date
*d1
, const rasqal_xsd_date
*d2
, int *incomparible_p
);
1805 int rasqal_xsd_date_compare(const rasqal_xsd_date
*d1
, const rasqal_xsd_date
*d2
, int *incomparible_p
);
1807 /* datetime functions */
1809 rasqal_xsd_datetime
* rasqal_new_xsd_datetime(rasqal_world
* world
, const char *datetime_string
);
1811 rasqal_xsd_datetime
* rasqal_new_xsd_datetime_from_unixtime(rasqal_world
* world
, time_t secs
);
1813 rasqal_xsd_datetime
* rasqal_new_xsd_datetime_from_timeval(rasqal_world
* world
, struct timeval
*tv
);
1815 rasqal_xsd_datetime
* rasqal_new_xsd_datetime_from_xsd_date(rasqal_world
* world
, rasqal_xsd_date
*date
);
1817 void rasqal_free_xsd_datetime(rasqal_xsd_datetime
* dt
);
1819 char* rasqal_xsd_datetime_to_counted_string(const rasqal_xsd_datetime
*dt
, size_t *len_p
);
1821 char* rasqal_xsd_datetime_to_string(const rasqal_xsd_datetime
*dt
);
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
);
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
);
1831 rasqal_xsd_decimal
* rasqal_xsd_datetime_get_seconds_as_decimal(rasqal_world
* world
, rasqal_xsd_datetime
* dt
);
1833 int rasqal_xsd_datetime_set_from_timeval(rasqal_xsd_datetime
*dt
, struct timeval
*tv
);
1835 int rasqal_xsd_datetime_set_from_unixtime(rasqal_xsd_datetime
* dt
, time_t clock
);
1837 time_t rasqal_xsd_datetime_get_as_unixtime(rasqal_xsd_datetime
* dt
);
1839 struct timeval
* rasqal_xsd_datetime_get_as_timeval(rasqal_xsd_datetime
*dt
);
1841 char* rasqal_xsd_datetime_get_timezone_as_counted_string(rasqal_xsd_datetime
*dt
, size_t *len_p
);
1843 char* rasqal_xsd_datetime_get_tz_as_counted_string(rasqal_xsd_datetime
* dt
, size_t *len_p
);
1846 /* regex utilities */
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
);
1854 * Rasqal SPARQL Protocol Service
1856 typedef struct rasqal_service_s rasqal_service
;
1859 rasqal_service
* rasqal_new_service(rasqal_world
* world
, raptor_uri
* service_uri
, const unsigned char* query_string
, raptor_sequence
* data_graphs
);
1861 void rasqal_free_service(rasqal_service
* svc
);
1863 rasqal_query_results
* rasqal_service_execute(rasqal_service
* svc
);
1865 int rasqal_service_set_www(rasqal_service
* svc
, raptor_www
* www
);
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.
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
;
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
);
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.
1940 * Metadata for triple pattern matching for one triple pattern.
1943 /* triple (subject, predicate, object) and origin */
1944 rasqal_variable
* bindings
[4];
1946 rasqal_triples_match
*triples_match
;
1950 rasqal_triple_parts parts
;
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
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
{
2001 rasqal_query
* query
;
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 < 0 is a 'no rdf data error', > 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.
2060 size_t user_data_size
;
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 */
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 */
2095 * RASQAL_QUERY_RESULTS_FORMATTER_DECLARED:
2101 * RASQAL_WORLD_DECLARED:
2108 * RASQAL_LITERAL_UDT_DEFINED
2114 * rasqal_expression_s:
2120 * @literal: Internal
2127 * Internal - see #rasqal_expression.
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
2145 * @rtm: triples match context
2146 * @user_data: user data
2148 * Internal - see #rasqal_triples_match
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
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
2177 * Internal - see #rasqal_triples_source
2179 * Return value: non-0 on failure
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
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