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 933
45 * RASQAL_VERSION_STRING:
47 * Rasqal library version string
49 #define RASQAL_VERSION_STRING "0.9.33"
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 33
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 20015
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
;
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+)
859 * @arg4: fourth argument (for #RASQAL_EXPR_REPLACE )
861 * Expression with arguments
864 struct rasqal_expression_s
{
871 struct rasqal_expression_s
* arg1
;
872 struct rasqal_expression_s
* arg2
;
873 struct rasqal_expression_s
* arg3
;
874 rasqal_literal
* literal
;
875 unsigned char *value
;
878 raptor_sequence
* args
;
880 raptor_sequence
* params
;
882 struct rasqal_expression_s
* arg4
;
884 typedef struct rasqal_expression_s rasqal_expression
;
889 * @subject: Triple subject.
890 * @predicate: Triple predicate.
891 * @object: Triple object.
892 * @origin: Triple origin.
893 * @flags: Or of enum #rasqal_triple_flags bits.
895 * A triple pattern or RDF triple.
897 * This is used as a triple pattern in queries and
898 * an RDF triple when generating RDF triples such as with SPARQL CONSTRUCT.
901 rasqal_literal
* subject
;
902 rasqal_literal
* predicate
;
903 rasqal_literal
* object
;
904 rasqal_literal
* origin
;
910 * rasqal_pattern_flags:
911 * @RASQAL_PATTERN_FLAGS_OPTIONAL: True when the graph pattern is an optional match.
912 * @RASQAL_PATTERN_FLAGS_LAST: Internal
914 * Flags for #rasqal_graph_pattern.
917 RASQAL_PATTERN_FLAGS_OPTIONAL
= 1,
919 RASQAL_PATTERN_FLAGS_LAST
= RASQAL_PATTERN_FLAGS_OPTIONAL
920 } rasqal_pattern_flags
;
924 * rasqal_generate_bnodeid_handler:
926 * @user_data: user data given to
927 * @user_bnodeid: user blank node ID string passed in
929 * User handler used with rasqal_world_set_generate_bnodeid_handler() to set method for generating a blank node ID.
931 * Return value: blank node ID string or NULL on failure.
933 typedef unsigned char* (*rasqal_generate_bnodeid_handler
)(rasqal_world
* world
, void *user_data
, unsigned char *user_bnodeid
);
938 * @RASQAL_QUERY_VERB_SELECT: SPARQL query select verb.
939 * @RASQAL_QUERY_VERB_CONSTRUCT: SPARQL query construct verb.
940 * @RASQAL_QUERY_VERB_DESCRIBE: SPARQL query describe verb.
941 * @RASQAL_QUERY_VERB_ASK: SPARQL query ask verb.
942 * @RASQAL_QUERY_VERB_DELETE: LAQRS query delete verb.
943 * @RASQAL_QUERY_VERB_INSERT: LAQRS query insert verb.
944 * @RASQAL_QUERY_VERB_UPDATE: SPARQL 1.1 (draft) update operation
945 * @RASQAL_QUERY_VERB_UNKNOWN: Internal
946 * @RASQAL_QUERY_VERB_LAST: Internal
948 * Query main operation verbs describing the major type of query
953 RASQAL_QUERY_VERB_UNKNOWN
= 0,
954 RASQAL_QUERY_VERB_SELECT
= 1,
955 RASQAL_QUERY_VERB_CONSTRUCT
= 2,
956 RASQAL_QUERY_VERB_DESCRIBE
= 3,
957 RASQAL_QUERY_VERB_ASK
= 4,
958 RASQAL_QUERY_VERB_DELETE
= 5,
959 RASQAL_QUERY_VERB_INSERT
= 6,
960 RASQAL_QUERY_VERB_UPDATE
= 7,
963 RASQAL_QUERY_VERB_LAST
= RASQAL_QUERY_VERB_UPDATE
968 * rasqal_query_results_type:
969 * @RASQAL_QUERY_RESULTS_BINDINGS: variable binding
970 * @RASQAL_QUERY_RESULTS_BOOLEAN: a single boolean
971 * @RASQAL_QUERY_RESULTS_GRAPH: an RDF graph
972 * @RASQAL_QUERY_RESULTS_SYNTAX: a syntax
973 * @RASQAL_QUERY_RESULTS_UNKNOWN: unknown type
974 * @RASQAL_QUERY_RESULTS_LAST: internal
980 RASQAL_QUERY_RESULTS_BINDINGS
,
981 RASQAL_QUERY_RESULTS_BOOLEAN
,
982 RASQAL_QUERY_RESULTS_GRAPH
,
983 RASQAL_QUERY_RESULTS_SYNTAX
,
984 RASQAL_QUERY_RESULTS_UNKNOWN
,
985 RASQAL_QUERY_RESULTS_LAST
= RASQAL_QUERY_RESULTS_UNKNOWN
986 } rasqal_query_results_type
;
990 * rasqal_update_type:
991 * @RASQAL_UPDATE_TYPE_CLEAR: Clear graph.
992 * @RASQAL_UPDATE_TYPE_CREATE: Create graph.
993 * @RASQAL_UPDATE_TYPE_DROP: Drop graph.
994 * @RASQAL_UPDATE_TYPE_LOAD: Load graph.
995 * @RASQAL_UPDATE_TYPE_UPDATE: Insert or Delete graph or triples.
996 * @RASQAL_UPDATE_TYPE_ADD: Add graph to another graph.
997 * @RASQAL_UPDATE_TYPE_MOVE: Move graph to another grpah.
998 * @RASQAL_UPDATE_TYPE_COPY: Copy graph to another graph.
999 * @RASQAL_UPDATE_TYPE_UNKNOWN: Internal
1000 * @RASQAL_UPDATE_TYPE_LAST: Internal
1002 * Update type being performed.
1007 RASQAL_UPDATE_TYPE_UNKNOWN
= 0,
1008 RASQAL_UPDATE_TYPE_CLEAR
= 1,
1009 RASQAL_UPDATE_TYPE_CREATE
= 2,
1010 RASQAL_UPDATE_TYPE_DROP
= 3,
1011 RASQAL_UPDATE_TYPE_LOAD
= 4,
1012 RASQAL_UPDATE_TYPE_UPDATE
= 5,
1013 RASQAL_UPDATE_TYPE_ADD
= 6,
1014 RASQAL_UPDATE_TYPE_MOVE
= 7,
1015 RASQAL_UPDATE_TYPE_COPY
= 8,
1018 RASQAL_UPDATE_TYPE_LAST
= RASQAL_UPDATE_TYPE_COPY
1019 } rasqal_update_type
;
1023 * rasqal_update_flags:
1024 * @RASQAL_UPDATE_FLAGS_SILENT: the update operation should be silent
1025 * @RASQAL_UPDATE_FLAGS_DATA: the update operation is triple data not templates
1027 * Bitflags for graph update operations
1030 RASQAL_UPDATE_FLAGS_SILENT
= 1,
1031 RASQAL_UPDATE_FLAGS_DATA
= 2
1032 } rasqal_update_flags
;
1036 * rasqal_update_graph_applies:
1037 * @RASQAL_UPDATE_GRAPH_ONE: the update operation applies to 1 graph
1038 * @RASQAL_UPDATE_GRAPH_DEFAULT: the update operation applies to the default graph
1039 * @RASQAL_UPDATE_GRAPH_NAMED: the update operation applies to all named graphs
1040 * @RASQAL_UPDATE_GRAPH_ALL: the update operation applies ALL graphs
1042 * The graph(s) that the update operation applies to.
1045 RASQAL_UPDATE_GRAPH_ONE
= 0,
1046 RASQAL_UPDATE_GRAPH_DEFAULT
= 1,
1047 RASQAL_UPDATE_GRAPH_NAMED
= 2,
1048 RASQAL_UPDATE_GRAPH_ALL
= 3
1049 } rasqal_update_graph_applies
;
1053 * rasqal_update_operation:
1054 * @type: type of update
1055 * @graph_uri: optional graph URI (clear, drop, load, with ... delete, insert); source graph (add, move, copy)
1056 * @document_uri: optional document URI (load); destination graph (add, move, copy)
1057 * @insert_templates: optional sequence of #rasqal_triple to insert. Data triples if @flags is #RASQAL_UPDATE_FLAGS_DATA set, templates otherwise.
1058 * @delete_templates: optional sequence of #rasqal_triple templates to delete
1059 * @where: optional where template (insert/delete)
1060 * @flags: update flags - bit-or of flags defined in #rasqal_update_flags
1061 * @applies: the graph(s) that the update operation applies to, or @graph_uri if #RASQAL_UPDATE_GRAPH_ONE
1063 * Update operation - changing the dataset
1065 * For LOAD and CLEAR if @applies is set (not 0) then the operation
1066 * applies to just those graph(), otherwise it applies to the @graph_uri.
1068 * For ADD, MOVE and COPY the source graph is stored in @graph_uri
1069 * field and the destination graph in the @document_uri field. The
1070 * field names have no meaning in this case since both values are
1071 * always present, always graphs and a NULL value signifies the
1076 rasqal_update_type type
;
1078 raptor_uri
* graph_uri
;
1080 raptor_uri
* document_uri
;
1082 raptor_sequence
* insert_templates
;
1084 raptor_sequence
* delete_templates
;
1086 rasqal_graph_pattern
* where
;
1090 rasqal_update_graph_applies applies
;
1091 } rasqal_update_operation
;
1095 * rasqal_graph_pattern_operator:
1096 * @RASQAL_GRAPH_PATTERN_OPERATOR_BASIC: Just triple patterns and constraints.
1097 * @RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL: Set of graph patterns (ANDed) and constraints.
1098 * @RASQAL_GRAPH_PATTERN_OPERATOR_UNION: Set of graph patterns (UNIONed) and constraints.
1099 * @RASQAL_GRAPH_PATTERN_OPERATOR_GROUP: Set of graph patterns (ANDed) and constraints.
1100 * @RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH: A graph term + a graph pattern and constraints.
1101 * @RASQAL_GRAPH_PATTERN_OPERATOR_FILTER: A filter graph pattern with an expression
1102 * @RASQAL_GRAPH_PATTERN_OPERATOR_LET: LET ?var := Expression (LAQRS)
1103 * @RASQAL_GRAPH_PATTERN_OPERATOR_SELECT: SELECT graph pattern
1104 * @RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE: SERVICE graph pattern
1105 * @RASQAL_GRAPH_PATTERN_OPERATOR_MINUS: MINUS graph pattern
1106 * @RASQAL_GRAPH_PATTERN_OPERATOR_VALUES: VALUES graph pattern
1107 * @RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN: Internal.
1108 * @RASQAL_GRAPH_PATTERN_OPERATOR_LAST: Internal.
1110 * Graph pattern operators
1113 RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN
= 0,
1114 RASQAL_GRAPH_PATTERN_OPERATOR_BASIC
= 1,
1115 RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL
= 2,
1116 RASQAL_GRAPH_PATTERN_OPERATOR_UNION
= 3,
1117 RASQAL_GRAPH_PATTERN_OPERATOR_GROUP
= 4,
1118 RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH
= 5,
1119 RASQAL_GRAPH_PATTERN_OPERATOR_FILTER
= 6,
1120 RASQAL_GRAPH_PATTERN_OPERATOR_LET
= 7,
1121 RASQAL_GRAPH_PATTERN_OPERATOR_SELECT
= 8,
1122 RASQAL_GRAPH_PATTERN_OPERATOR_SERVICE
= 9,
1123 RASQAL_GRAPH_PATTERN_OPERATOR_MINUS
= 10,
1124 RASQAL_GRAPH_PATTERN_OPERATOR_VALUES
= 11,
1126 RASQAL_GRAPH_PATTERN_OPERATOR_LAST
= RASQAL_GRAPH_PATTERN_OPERATOR_VALUES
1127 } rasqal_graph_pattern_operator
;
1131 * rasqal_graph_pattern_visit_fn:
1132 * @query: #rasqal_query containing the graph pattern
1133 * @gp: current graph_pattern
1134 * @user_data: user data passed in
1136 * User function to visit a graph_pattern and operate on it with
1137 * rasqal_graph_pattern_visit() or rasqal_query_graph_pattern_visit()
1139 * Return value: non-0 to truncate the visit
1141 typedef int (*rasqal_graph_pattern_visit_fn
)(rasqal_query
* query
, rasqal_graph_pattern
* gp
, void *user_data
);
1146 /* Public functions */
1149 rasqal_world
*rasqal_new_world(void);
1151 int rasqal_world_open(rasqal_world
* world
);
1153 void rasqal_free_world(rasqal_world
* world
);
1156 void rasqal_world_set_raptor(rasqal_world
* world
, raptor_world
* raptor_world_ptr
);
1158 raptor_world
*rasqal_world_get_raptor(rasqal_world
* world
);
1161 void rasqal_world_set_log_handler(rasqal_world
* world
, void *user_data
, raptor_log_handler handler
);
1164 int rasqal_world_set_default_generate_bnodeid_parameters(rasqal_world
* world
, char *prefix
, int base
);
1166 int rasqal_world_set_generate_bnodeid_handler(rasqal_world
* world
, void *user_data
, rasqal_generate_bnodeid_handler handler
);
1169 int rasqal_world_set_warning_level(rasqal_world
* world
, unsigned int warning_level
);
1172 const raptor_syntax_description
* rasqal_world_get_query_results_format_description(rasqal_world
* world
, unsigned int counter
);
1175 const char* rasqal_world_guess_query_results_format_name(rasqal_world
* world
, raptor_uri
*uri
, const char *mime_type
, const unsigned char *buffer
, size_t len
, const unsigned char *identifier
);
1179 int rasqal_features_enumerate(rasqal_world
* world
, const rasqal_feature feature
, const char **name
, raptor_uri
**uri
, const char **label
);
1181 unsigned int rasqal_get_feature_count(void);
1183 rasqal_feature
rasqal_feature_from_uri(rasqal_world
* world
, raptor_uri
*uri
);
1185 int rasqal_feature_value_type(const rasqal_feature feature
);
1189 const raptor_syntax_description
* rasqal_world_get_query_language_description(rasqal_world
* world
, unsigned int counter
);
1191 RASQAL_API RASQAL_DEPRECATED
1192 int rasqal_languages_enumerate(rasqal_world
* world
, unsigned int counter
, const char **name
, const char **label
, const unsigned char **uri_string
);
1195 int rasqal_language_name_check(rasqal_world
* world
, const char *name
);
1202 rasqal_query
* rasqal_new_query(rasqal_world
* world
, const char *name
, const unsigned char *uri
);
1206 void rasqal_free_query(rasqal_query
* query
);
1210 const char* rasqal_query_get_name(rasqal_query
* query
);
1212 const char* rasqal_query_get_label(rasqal_query
* query
);
1216 int rasqal_query_set_feature(rasqal_query
* query
, rasqal_feature feature
, int value
);
1218 int rasqal_query_set_feature_string(rasqal_query
*query
, rasqal_feature feature
, const unsigned char *value
);
1220 int rasqal_query_get_feature(rasqal_query
*query
, rasqal_feature feature
);
1222 const unsigned char* rasqal_query_get_feature_string(rasqal_query
*query
, rasqal_feature feature
);
1225 rasqal_query_verb
rasqal_query_get_verb(rasqal_query
* query
);
1227 int rasqal_query_get_wildcard(rasqal_query
* query
);
1229 void rasqal_query_set_wildcard(rasqal_query
* query
, int wildcard
);
1231 int rasqal_query_get_distinct(rasqal_query
* query
);
1233 void rasqal_query_set_distinct(rasqal_query
* query
, int distinct_mode
);
1235 int rasqal_query_get_explain(rasqal_query
* query
);
1237 void rasqal_query_set_explain(rasqal_query
* query
, int is_explain
);
1239 int rasqal_query_get_limit(rasqal_query
* query
);
1241 void rasqal_query_set_limit(rasqal_query
* query
, int limit
);
1243 int rasqal_query_get_offset(rasqal_query
* query
);
1245 void rasqal_query_set_offset(rasqal_query
* query
, int offset
);
1248 int rasqal_query_add_data_graph(rasqal_query
* query
, rasqal_data_graph
* data_graph
);
1250 int rasqal_query_add_data_graphs(rasqal_query
* query
, raptor_sequence
* data_graphs
);
1253 raptor_sequence
* rasqal_query_get_data_graph_sequence(rasqal_query
* query
);
1255 rasqal_data_graph
* rasqal_query_get_data_graph(rasqal_query
* query
, int idx
);
1257 int rasqal_query_dataset_contains_named_graph(rasqal_query
* query
, raptor_uri
*graph_uri
);
1260 int rasqal_query_add_variable(rasqal_query
* query
, rasqal_variable
* var
);
1262 raptor_sequence
* rasqal_query_get_bound_variable_sequence(rasqal_query
* query
);
1264 raptor_sequence
* rasqal_query_get_describe_sequence(rasqal_query
* query
);
1266 raptor_sequence
* rasqal_query_get_anonymous_variable_sequence(rasqal_query
* query
);
1268 raptor_sequence
* rasqal_query_get_all_variable_sequence(rasqal_query
* query
);
1270 rasqal_variable
* rasqal_query_get_variable(rasqal_query
* query
, int idx
);
1272 int rasqal_query_has_variable2(rasqal_query
* query
, rasqal_variable_type type
, const unsigned char *name
);
1273 RASQAL_API RASQAL_DEPRECATED
1274 int rasqal_query_has_variable(rasqal_query
* query
, const unsigned char *name
);
1276 int rasqal_query_set_variable2(rasqal_query
* query
, rasqal_variable_type type
, const unsigned char *name
, rasqal_literal
* value
);
1277 RASQAL_API RASQAL_DEPRECATED
1278 int rasqal_query_set_variable(rasqal_query
* query
, const unsigned char *name
, rasqal_literal
* value
);
1280 raptor_sequence
* rasqal_query_get_triple_sequence(rasqal_query
* query
);
1282 rasqal_triple
* rasqal_query_get_triple(rasqal_query
* query
, int idx
);
1284 int rasqal_query_add_prefix(rasqal_query
* query
, rasqal_prefix
* prefix
);
1286 raptor_sequence
* rasqal_query_get_prefix_sequence(rasqal_query
* query
);
1288 rasqal_prefix
* rasqal_query_get_prefix(rasqal_query
* query
, int idx
);
1290 raptor_sequence
* rasqal_query_get_order_conditions_sequence(rasqal_query
* query
);
1292 rasqal_expression
* rasqal_query_get_order_condition(rasqal_query
* query
, int idx
);
1294 raptor_sequence
* rasqal_query_get_group_conditions_sequence(rasqal_query
* query
);
1296 rasqal_expression
* rasqal_query_get_group_condition(rasqal_query
* query
, int idx
);
1298 raptor_sequence
* rasqal_query_get_having_conditions_sequence(rasqal_query
* query
);
1300 rasqal_expression
* rasqal_query_get_having_condition(rasqal_query
* query
, int idx
);
1302 raptor_sequence
* rasqal_query_get_construct_triples_sequence(rasqal_query
* query
);
1304 rasqal_triple
* rasqal_query_get_construct_triple(rasqal_query
* query
, int idx
);
1305 RASQAL_API RASQAL_DEPRECATED
1306 void rasqal_query_graph_pattern_visit(rasqal_query
* query
, rasqal_graph_pattern_visit_fn visit_fn
, void* data
);
1308 int rasqal_query_graph_pattern_visit2(rasqal_query
* query
, rasqal_graph_pattern_visit_fn visit_fn
, void* data
);
1310 int rasqal_query_write(raptor_iostream
* iostr
, rasqal_query
* query
, raptor_uri
* format_uri
, raptor_uri
* base_uri
);
1314 raptor_sequence
* rasqal_query_get_update_operations_sequence(rasqal_query
* query
);
1316 rasqal_update_operation
* rasqal_query_get_update_operation(rasqal_query
* query
, int idx
);
1319 int rasqal_query_set_store_results(rasqal_query
* query
, int store_results
);
1321 /* graph patterns */
1323 rasqal_graph_pattern
* rasqal_query_get_query_graph_pattern(rasqal_query
* query
);
1325 raptor_sequence
* rasqal_query_get_graph_pattern_sequence(rasqal_query
* query
);
1327 rasqal_graph_pattern
* rasqal_query_get_graph_pattern(rasqal_query
* query
, int idx
);
1329 int rasqal_graph_pattern_add_sub_graph_pattern(rasqal_graph_pattern
* graph_pattern
, rasqal_graph_pattern
* sub_graph_pattern
);
1331 rasqal_triple
* rasqal_graph_pattern_get_triple(rasqal_graph_pattern
* graph_pattern
, int idx
);
1333 raptor_sequence
* rasqal_graph_pattern_get_sub_graph_pattern_sequence(rasqal_graph_pattern
* graph_pattern
);
1335 rasqal_graph_pattern
* rasqal_graph_pattern_get_sub_graph_pattern(rasqal_graph_pattern
* graph_pattern
, int idx
);
1337 rasqal_graph_pattern_operator
rasqal_graph_pattern_get_operator(rasqal_graph_pattern
* graph_pattern
);
1339 const char* rasqal_graph_pattern_operator_as_string(rasqal_graph_pattern_operator op
);
1341 int rasqal_graph_pattern_print(rasqal_graph_pattern
* gp
, FILE* fh
);
1343 int rasqal_graph_pattern_set_filter_expression(rasqal_graph_pattern
* gp
, rasqal_expression
* expr
);
1345 rasqal_expression
* rasqal_graph_pattern_get_filter_expression(rasqal_graph_pattern
* gp
);
1347 int rasqal_graph_pattern_visit(rasqal_query
* query
, rasqal_graph_pattern
*gp
, rasqal_graph_pattern_visit_fn fn
, void* user_data
);
1349 int rasqal_graph_pattern_get_index(rasqal_graph_pattern
* gp
);
1351 int rasqal_graph_pattern_variable_bound_in(rasqal_graph_pattern
*gp
, rasqal_variable
*v
);
1353 rasqal_literal
* rasqal_graph_pattern_get_origin(rasqal_graph_pattern
* graph_pattern
);
1355 rasqal_variable
* rasqal_graph_pattern_get_variable(rasqal_graph_pattern
* graph_pattern
);
1357 rasqal_literal
* rasqal_graph_pattern_get_service(rasqal_graph_pattern
* graph_pattern
);
1359 raptor_sequence
* rasqal_graph_pattern_get_flattened_triples(rasqal_query
* query
, rasqal_graph_pattern
* graph_pattern
);
1361 raptor_sequence
* rasqal_graph_pattern_get_triples(rasqal_query
* query
, rasqal_graph_pattern
* graph_pattern
);
1364 /* Utility methods */
1366 const char* rasqal_query_verb_as_string(rasqal_query_verb verb
);
1368 int rasqal_query_print(rasqal_query
* query
, FILE* fh
);
1372 int rasqal_query_prepare(rasqal_query
* query
, const unsigned char *query_string
, raptor_uri
*base_uri
);
1374 rasqal_query_results
* rasqal_query_execute(rasqal_query
* query
);
1377 void* rasqal_query_get_user_data(rasqal_query
* query
);
1379 void rasqal_query_set_user_data(rasqal_query
* query
, void *user_data
);
1382 raptor_sequence
* rasqal_query_get_bindings_variables_sequence(rasqal_query
* query
);
1384 rasqal_variable
* rasqal_query_get_bindings_variable(rasqal_query
* query
, int idx
);
1386 raptor_sequence
* rasqal_query_get_bindings_rows_sequence(rasqal_query
* query
);
1388 rasqal_row
* rasqal_query_get_bindings_row(rasqal_query
* query
, int idx
);
1390 rasqal_query_results_type
rasqal_query_get_result_type(rasqal_query
* query
);
1394 rasqal_query_results
* rasqal_new_query_results2(rasqal_world
* world
, rasqal_query
* query
, rasqal_query_results_type type
);
1395 RASQAL_API RASQAL_DEPRECATED
1396 rasqal_query_results
* rasqal_new_query_results(rasqal_world
* world
, rasqal_query
* query
, rasqal_query_results_type type
, rasqal_variables_table
* vars_table
);
1398 rasqal_query_results
* rasqal_new_query_results_from_string(rasqal_world
* world
, rasqal_query_results_type type
, raptor_uri
* base_uri
, const char* string
, size_t string_len
);
1400 void rasqal_free_query_results(rasqal_query_results
*query_results
);
1403 rasqal_query
* rasqal_query_results_get_query(rasqal_query_results
* query_results
);
1405 /* Bindings result format */
1407 rasqal_query_results_type
rasqal_query_results_get_type(rasqal_query_results
* query_results
);
1409 const char* rasqal_query_results_type_label(rasqal_query_results_type type
);
1411 int rasqal_query_results_is_bindings(rasqal_query_results
*query_results
);
1413 int rasqal_query_results_get_count(rasqal_query_results
*query_results
);
1415 int rasqal_query_results_next(rasqal_query_results
*query_results
);
1417 int rasqal_query_results_finished(rasqal_query_results
*query_results
);
1419 int rasqal_query_results_get_bindings(rasqal_query_results
*query_results
, const unsigned char ***names
, rasqal_literal
***values
);
1421 rasqal_literal
* rasqal_query_results_get_binding_value(rasqal_query_results
*query_results
, int offset
);
1423 const unsigned char* rasqal_query_results_get_binding_name(rasqal_query_results
*query_results
, int offset
);
1425 rasqal_literal
* rasqal_query_results_get_binding_value_by_name(rasqal_query_results
*query_results
, const unsigned char *name
);
1427 int rasqal_query_results_get_bindings_count(rasqal_query_results
*query_results
);
1429 int rasqal_query_results_add_row(rasqal_query_results
* query_results
, rasqal_row
* row
);
1431 rasqal_row
* rasqal_query_results_get_row_by_offset(rasqal_query_results
* query_results
, int result_offset
);
1433 /* Boolean result format */
1435 int rasqal_query_results_is_boolean(rasqal_query_results
*query_results
);
1437 int rasqal_query_results_get_boolean(rasqal_query_results
*query_results
);
1439 /* Graph result format */
1441 int rasqal_query_results_is_graph(rasqal_query_results
*query_results
);
1443 raptor_statement
* rasqal_query_results_get_triple(rasqal_query_results
*query_results
);
1445 int rasqal_query_results_next_triple(rasqal_query_results
*query_results
);
1447 /* Syntax result format */
1449 int rasqal_query_results_is_syntax(rasqal_query_results
* query_results
);
1452 int rasqal_query_results_write(raptor_iostream
*iostr
, rasqal_query_results
*results
, const char* name
, const char* mime_type
, raptor_uri
*format_uri
, raptor_uri
*base_uri
);
1454 int rasqal_query_results_read(raptor_iostream
*iostr
, rasqal_query_results
*results
, const char* name
, const char* mime_type
, raptor_uri
*format_uri
, raptor_uri
*base_uri
);
1458 int rasqal_query_results_rewind(rasqal_query_results
* query_results
);
1462 * rasqal_query_results_format_flags:
1463 * @RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER: format can be read.
1464 * @RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER: format can be written.
1466 * Bitflags for rasqal_query_results_formats_check() to find formats with features.
1469 RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER
= 1,
1470 RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER
= 2
1471 } rasqal_query_results_format_flags
;
1475 int rasqal_query_results_formats_check2(rasqal_world
* world
, const char *name
, raptor_uri
* uri
, const char *mime_type
, int flags
);
1476 RASQAL_API RASQAL_DEPRECATED
1477 int rasqal_query_results_formats_check(rasqal_world
* world
, const char *name
, raptor_uri
* uri
, const char *mime_type
, int flags
);
1479 rasqal_query_results_formatter
* rasqal_new_query_results_formatter(rasqal_world
* world
, const char *name
, const char *mime_type
, raptor_uri
* format_uri
);
1481 rasqal_query_results_formatter
* rasqal_new_query_results_formatter_for_content(rasqal_world
* world
, raptor_uri
*uri
, const char *mime_type
, const unsigned char *buffer
, size_t len
, const unsigned char *identifier
);
1483 void rasqal_free_query_results_formatter(rasqal_query_results_formatter
* formatter
);
1485 int rasqal_query_results_formatter_write(raptor_iostream
*iostr
, rasqal_query_results_formatter
* formatter
, rasqal_query_results
* results
, raptor_uri
*base_uri
);
1487 int rasqal_query_results_formatter_read(rasqal_world
* world
, raptor_iostream
*iostr
, rasqal_query_results_formatter
* formatter
, rasqal_query_results
* results
, raptor_uri
*base_uri
);
1490 int rasqal_query_iostream_write_escaped_counted_string(rasqal_query
* query
, raptor_iostream
* iostr
, const unsigned char* string
, size_t len
);
1492 unsigned char* rasqal_query_escape_counted_string(rasqal_query
* query
, const unsigned char *string
, size_t len
, size_t* output_len_p
);
1495 /* Data graph class */
1497 rasqal_data_graph
* rasqal_new_data_graph_from_uri(rasqal_world
* world
, raptor_uri
* uri
, raptor_uri
* name_uri
, unsigned int flags
, const char* format_type
, const char* format_name
, raptor_uri
* format_uri
);
1499 rasqal_data_graph
* rasqal_new_data_graph_from_iostream(rasqal_world
* world
, raptor_iostream
* iostr
, raptor_uri
* base_uri
, raptor_uri
* name_uri
, unsigned int flags
, const char* format_type
, const char* format_name
, raptor_uri
* format_uri
);
1501 rasqal_data_graph
* rasqal_new_data_graph_from_data_graph(rasqal_data_graph
* dg
);
1503 void rasqal_free_data_graph(rasqal_data_graph
* dg
);
1505 int rasqal_data_graph_print(rasqal_data_graph
* dg
, FILE* fh
);
1509 * rasqal_compare_flags:
1510 * @RASQAL_COMPARE_NOCASE: String comparisons are case independent.
1511 * @RASQAL_COMPARE_XQUERY: XQuery comparsion rules apply.
1512 * @RASQAL_COMPARE_RDF: RDF Term comparsion rules apply.
1513 * @RASQAL_COMPARE_URI: Allow comparison of URIs and allow strings to have a boolean value (unused; was for RDQL)
1514 * @RASQAL_COMPARE_SAMETERM: SPARQL sameTerm() builtin rules apply.
1516 * Flags for rasqal_expression_evaluate(), rasqal_literal_compare() or
1517 * rasqal_literal_as_string_flags()
1520 RASQAL_COMPARE_NOCASE
= 1,
1521 RASQAL_COMPARE_XQUERY
= 2,
1522 RASQAL_COMPARE_RDF
= 4,
1523 RASQAL_COMPARE_URI
= 8,
1524 RASQAL_COMPARE_SAMETERM
= 16
1525 } rasqal_compare_flags
;
1533 typedef struct rasqal_random_s rasqal_random
;
1537 * rasqal_evaluation_context:
1538 * @world: rasqal world
1539 * @base_uri: base URI of expression context (or NULL)
1540 * @locator: locator or NULL
1541 * @flags: expression comparison flags
1542 * @seed: random seeed
1543 * @random: random number generator object
1545 * A context for evaluating an expression such as with
1546 * rasqal_expression_evaluate2()
1549 rasqal_world
*world
;
1550 raptor_uri
* base_uri
;
1551 raptor_locator
*locator
;
1554 rasqal_random
* random
;
1555 } rasqal_evaluation_context
;
1558 /* Expression class */
1560 rasqal_expression
* rasqal_new_0op_expression(rasqal_world
* world
, rasqal_op op
);
1562 rasqal_expression
* rasqal_new_1op_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg
);
1564 rasqal_expression
* rasqal_new_2op_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, rasqal_expression
* arg2
);
1566 rasqal_expression
* rasqal_new_3op_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, rasqal_expression
* arg2
, rasqal_expression
* arg3
);
1568 rasqal_expression
* rasqal_new_4op_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, rasqal_expression
* arg2
, rasqal_expression
* arg3
, rasqal_expression
* arg4
);
1570 rasqal_expression
* rasqal_new_string_op_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, rasqal_literal
* literal
);
1572 rasqal_expression
* rasqal_new_literal_expression(rasqal_world
* world
, rasqal_literal
* literal
);
1574 rasqal_expression
* rasqal_new_function_expression(rasqal_world
* world
, raptor_uri
* name
, raptor_sequence
* args
, raptor_sequence
* params
, unsigned int flags
);
1576 rasqal_expression
* rasqal_new_aggregate_function_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, raptor_sequence
* params
, unsigned int flags
);
1578 rasqal_expression
* rasqal_new_cast_expression(rasqal_world
* world
, raptor_uri
* name
, rasqal_expression
*value
);
1580 rasqal_expression
* rasqal_new_expr_seq_expression(rasqal_world
* world
, rasqal_op op
, raptor_sequence
* args
);
1582 rasqal_expression
* rasqal_new_set_expression(rasqal_world
* world
, rasqal_op op
, rasqal_expression
* arg1
, raptor_sequence
* args
);
1584 rasqal_expression
* rasqal_new_group_concat_expression(rasqal_world
* world
, unsigned int flags
, raptor_sequence
* args
, rasqal_literal
* separator
);
1586 rasqal_expression
* rasqal_new_expression_from_expression(rasqal_expression
* e
);
1589 void rasqal_free_expression(rasqal_expression
* e
);
1591 void rasqal_expression_print_op(rasqal_expression
* e
, FILE* fh
);
1593 int rasqal_expression_print(rasqal_expression
* e
, FILE* fh
);
1594 RASQAL_API RASQAL_DEPRECATED
1595 rasqal_literal
* rasqal_expression_evaluate(rasqal_world
*world
, raptor_locator
*locator
, rasqal_expression
* e
, int flags
);
1597 rasqal_literal
* rasqal_expression_evaluate2(rasqal_expression
*e
, rasqal_evaluation_context
* eval_context
, int *error_p
);
1599 const char* rasqal_expression_op_label(rasqal_op op
);
1601 int rasqal_expression_compare(rasqal_expression
* e1
, rasqal_expression
* e2
, int flags
, int* error_p
);
1604 * rasqal_expression_visit_fn:
1605 * @user_data: user data passed in with rasqal_expression_visit()
1606 * @e: current expression
1608 * User function to visit an expression and operate on it with
1609 * rasqal_expression_visit()
1611 * Return value: non-0 to truncate the visit
1613 typedef int (*rasqal_expression_visit_fn
)(void *user_data
, rasqal_expression
*e
);
1615 int rasqal_expression_visit(rasqal_expression
* e
, rasqal_expression_visit_fn fn
, void *user_data
);
1618 rasqal_evaluation_context
* rasqal_new_evaluation_context(rasqal_world
* world
, raptor_locator
* locator
, int flags
);
1620 void rasqal_free_evaluation_context(rasqal_evaluation_context
* eval_context
);
1622 int rasqal_evaluation_context_set_base_uri(rasqal_evaluation_context
* eval_context
, raptor_uri
*base_uri
);
1624 int rasqal_evaluation_context_set_rand_seed(rasqal_evaluation_context
* eval_context
, unsigned int seed
);
1629 rasqal_literal
* rasqal_new_integer_literal(rasqal_world
* world
, rasqal_literal_type type
, int integer
);
1631 rasqal_literal
* rasqal_new_numeric_literal_from_long(rasqal_world
* world
, rasqal_literal_type type
, long value
);
1633 rasqal_literal
* rasqal_new_typed_literal(rasqal_world
* world
, rasqal_literal_type type
, const unsigned char* string
);
1635 rasqal_literal
* rasqal_new_double_literal(rasqal_world
* world
, double d
);
1637 rasqal_literal
* rasqal_new_floating_literal(rasqal_world
*world
, rasqal_literal_type type
, double d
);
1638 RASQAL_API RASQAL_DEPRECATED
1639 rasqal_literal
* rasqal_new_float_literal(rasqal_world
* world
, float f
);
1641 rasqal_literal
* rasqal_new_uri_literal(rasqal_world
* world
, raptor_uri
* uri
);
1643 rasqal_literal
* rasqal_new_pattern_literal(rasqal_world
* world
, const unsigned char *pattern
, const char *flags
);
1645 rasqal_literal
* rasqal_new_string_literal(rasqal_world
* world
, const unsigned char *string
, const char *language
, raptor_uri
*datatype
, const unsigned char *datatype_qname
);
1647 rasqal_literal
* rasqal_new_simple_literal(rasqal_world
* world
, rasqal_literal_type type
, const unsigned char *string
);
1649 rasqal_literal
* rasqal_new_boolean_literal(rasqal_world
* world
, int value
);
1651 rasqal_literal
* rasqal_new_variable_literal(rasqal_world
* world
, rasqal_variable
*variable
);
1653 rasqal_literal
* rasqal_new_decimal_literal(rasqal_world
* world
, const unsigned char *string
);
1655 rasqal_literal
* rasqal_new_decimal_literal_from_decimal(rasqal_world
* world
, const unsigned char *string
, rasqal_xsd_decimal
* decimal
);
1657 rasqal_literal
* rasqal_new_datetime_literal_from_datetime(rasqal_world
* world
, rasqal_xsd_datetime
* dt
);
1661 rasqal_literal
* rasqal_new_literal_from_literal(rasqal_literal
* l
);
1663 void rasqal_free_literal(rasqal_literal
* l
);
1665 int rasqal_literal_print(rasqal_literal
* l
, FILE* fh
);
1667 const char* rasqal_literal_type_label(rasqal_literal_type type
);
1669 void rasqal_literal_print_type(rasqal_literal
* l
, FILE* fh
);
1671 rasqal_variable
* rasqal_literal_as_variable(rasqal_literal
* l
);
1673 const unsigned char* rasqal_literal_as_counted_string(rasqal_literal
* l
, size_t *len_p
, int flags
, int *error_p
);
1675 const unsigned char* rasqal_literal_as_string(rasqal_literal
* l
);
1677 const unsigned char* rasqal_literal_as_string_flags(rasqal_literal
* l
, int flags
, int *error_p
);
1679 rasqal_literal
* rasqal_literal_as_node(rasqal_literal
* l
);
1681 raptor_uri
* rasqal_literal_datatype(rasqal_literal
* l
);
1683 rasqal_literal
* rasqal_literal_value(rasqal_literal
* l
);
1686 int rasqal_literal_compare(rasqal_literal
* l1
, rasqal_literal
* l2
, int flags
, int *error_p
);
1688 int rasqal_literal_equals(rasqal_literal
* l1
, rasqal_literal
* l2
);
1690 int rasqal_literal_same_term(rasqal_literal
* l1
, rasqal_literal
* l2
);
1692 rasqal_literal_type
rasqal_literal_get_rdf_term_type(rasqal_literal
* l
);
1694 rasqal_literal_type
rasqal_literal_get_type(rasqal_literal
* l
);
1696 char* rasqal_literal_get_language(rasqal_literal
* l
);
1698 int rasqal_literal_is_rdf_literal(rasqal_literal
* l
);
1702 rasqal_prefix
* rasqal_new_prefix(rasqal_world
* world
, const unsigned char* prefix
, raptor_uri
* uri
);
1704 void rasqal_free_prefix(rasqal_prefix
* p
);
1706 int rasqal_prefix_print(rasqal_prefix
* p
, FILE* fh
);
1711 rasqal_row
* rasqal_new_row_for_size(rasqal_world
* world
, int size
);
1713 void rasqal_free_row(rasqal_row
* row
);
1715 int rasqal_row_set_value_at(rasqal_row
* row
, int offset
, rasqal_literal
* value
);
1720 rasqal_triple
* rasqal_new_triple(rasqal_literal
* subject
, rasqal_literal
* predicate
, rasqal_literal
* object
);
1722 rasqal_triple
* rasqal_new_triple_from_triple(rasqal_triple
* t
);
1724 void rasqal_free_triple(rasqal_triple
* t
);
1726 int rasqal_triple_print(rasqal_triple
* t
, FILE* fh
);
1728 void rasqal_triple_set_origin(rasqal_triple
* t
, rasqal_literal
*l
);
1730 rasqal_literal
* rasqal_triple_get_origin(rasqal_triple
* t
);
1732 /* Variable class */
1734 rasqal_variable
* rasqal_new_variable_from_variable(rasqal_variable
* v
);
1736 void rasqal_free_variable(rasqal_variable
* v
);
1738 int rasqal_variable_print(rasqal_variable
* v
, FILE* fh
);
1740 void rasqal_variable_set_value(rasqal_variable
* v
, rasqal_literal
* l
);
1743 /* Variables Table */
1745 rasqal_variables_table
* rasqal_new_variables_table(rasqal_world
* world
);
1747 void rasqal_free_variables_table(rasqal_variables_table
* vt
);
1748 RASQAL_API RASQAL_DEPRECATED
1749 rasqal_variable
* rasqal_variables_table_add(rasqal_variables_table
* vt
, rasqal_variable_type type
, const unsigned char *name
, rasqal_literal
*value
);
1751 rasqal_variable
* rasqal_variables_table_add2(rasqal_variables_table
* vt
, rasqal_variable_type type
, const unsigned char *name
, size_t name_len
, rasqal_literal
*value
);
1753 int rasqal_variables_table_add_variable(rasqal_variables_table
* vt
, rasqal_variable
* variable
);
1755 rasqal_variable
* rasqal_variables_table_get_by_name(rasqal_variables_table
* vt
, rasqal_variable_type type
, const unsigned char *name
);
1757 int rasqal_variables_table_contains(rasqal_variables_table
* vt
, rasqal_variable_type type
, const unsigned char *name
);
1759 /* memory functions */
1761 void rasqal_free_memory(void *ptr
);
1763 void* rasqal_alloc_memory(size_t size
);
1765 void* rasqal_calloc_memory(size_t nmemb
, size_t size
);
1768 /* decimal functions */
1770 rasqal_xsd_decimal
* rasqal_new_xsd_decimal(rasqal_world
* world
);
1772 void rasqal_free_xsd_decimal(rasqal_xsd_decimal
* dec
);
1774 int rasqal_xsd_decimal_set_string(rasqal_xsd_decimal
* dec
, const char* string
);
1776 double rasqal_xsd_decimal_get_double(rasqal_xsd_decimal
* dec
);
1778 long rasqal_xsd_decimal_get_long(rasqal_xsd_decimal
* dec
, int* error_p
);
1780 char* rasqal_xsd_decimal_as_string(rasqal_xsd_decimal
* dec
);
1782 char* rasqal_xsd_decimal_as_counted_string(rasqal_xsd_decimal
* dec
, size_t* len_p
);
1784 int rasqal_xsd_decimal_set_long(rasqal_xsd_decimal
* dec
, long l
);
1786 int rasqal_xsd_decimal_set_double(rasqal_xsd_decimal
* dec
, double d
);
1788 int rasqal_xsd_decimal_print(rasqal_xsd_decimal
* dec
, FILE* stream
);
1790 int rasqal_xsd_decimal_add(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1792 int rasqal_xsd_decimal_subtract(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1794 int rasqal_xsd_decimal_multiply(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1796 int rasqal_xsd_decimal_divide(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1798 int rasqal_xsd_decimal_negate(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1800 int rasqal_xsd_decimal_compare(rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1802 int rasqal_xsd_decimal_equals(rasqal_xsd_decimal
* a
, rasqal_xsd_decimal
* b
);
1804 int rasqal_xsd_decimal_is_zero(rasqal_xsd_decimal
* d
);
1806 int rasqal_xsd_decimal_abs(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1808 int rasqal_xsd_decimal_round(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1810 int rasqal_xsd_decimal_ceil(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1812 int rasqal_xsd_decimal_floor(rasqal_xsd_decimal
* result
, rasqal_xsd_decimal
* a
);
1815 /* date functions */
1817 rasqal_xsd_date
* rasqal_new_xsd_date(rasqal_world
* world
, const char *date_string
);
1819 void rasqal_free_xsd_date(rasqal_xsd_date
* d
);
1821 char* rasqal_xsd_date_to_counted_string(const rasqal_xsd_date
*date
, size_t *len_p
);
1823 char* rasqal_xsd_date_to_string(const rasqal_xsd_date
*d
);
1825 int rasqal_xsd_date_equals(const rasqal_xsd_date
*d1
, const rasqal_xsd_date
*d2
, int *incomparible_p
);
1827 int rasqal_xsd_date_compare(const rasqal_xsd_date
*d1
, const rasqal_xsd_date
*d2
, int *incomparible_p
);
1829 /* datetime functions */
1831 rasqal_xsd_datetime
* rasqal_new_xsd_datetime(rasqal_world
* world
, const char *datetime_string
);
1833 rasqal_xsd_datetime
* rasqal_new_xsd_datetime_from_unixtime(rasqal_world
* world
, time_t secs
);
1835 rasqal_xsd_datetime
* rasqal_new_xsd_datetime_from_timeval(rasqal_world
* world
, struct timeval
*tv
);
1837 rasqal_xsd_datetime
* rasqal_new_xsd_datetime_from_xsd_date(rasqal_world
* world
, rasqal_xsd_date
*date
);
1839 void rasqal_free_xsd_datetime(rasqal_xsd_datetime
* dt
);
1841 char* rasqal_xsd_datetime_to_counted_string(const rasqal_xsd_datetime
*dt
, size_t *len_p
);
1843 char* rasqal_xsd_datetime_to_string(const rasqal_xsd_datetime
*dt
);
1845 int rasqal_xsd_datetime_equals2(const rasqal_xsd_datetime
*dt1
, const rasqal_xsd_datetime
*dt2
, int *incomparible_p
);
1846 RASQAL_API RASQAL_DEPRECATED
1847 int rasqal_xsd_datetime_equals(const rasqal_xsd_datetime
*dt1
, const rasqal_xsd_datetime
*dt2
);
1849 int rasqal_xsd_datetime_compare2(const rasqal_xsd_datetime
*dt1
, const rasqal_xsd_datetime
*dt2
, int *incomparible_p
);
1850 RASQAL_API RASQAL_DEPRECATED
1851 int rasqal_xsd_datetime_compare(const rasqal_xsd_datetime
*dt1
, const rasqal_xsd_datetime
*dt2
);
1853 rasqal_xsd_decimal
* rasqal_xsd_datetime_get_seconds_as_decimal(rasqal_world
* world
, rasqal_xsd_datetime
* dt
);
1855 int rasqal_xsd_datetime_set_from_timeval(rasqal_xsd_datetime
*dt
, struct timeval
*tv
);
1857 int rasqal_xsd_datetime_set_from_unixtime(rasqal_xsd_datetime
* dt
, time_t clock
);
1859 time_t rasqal_xsd_datetime_get_as_unixtime(rasqal_xsd_datetime
* dt
);
1861 struct timeval
* rasqal_xsd_datetime_get_as_timeval(rasqal_xsd_datetime
*dt
);
1863 char* rasqal_xsd_datetime_get_timezone_as_counted_string(rasqal_xsd_datetime
*dt
, size_t *len_p
);
1865 char* rasqal_xsd_datetime_get_tz_as_counted_string(rasqal_xsd_datetime
* dt
, size_t *len_p
);
1868 /* regex utilities */
1870 char* rasqal_regex_replace(rasqal_world
* world
, raptor_locator
* locator
, const char* pattern
, const char* regex_flags
, const char* subject
, size_t subject_len
, const char* replace
, size_t replace_len
, size_t* result_len_p
);
1876 * Rasqal SPARQL Protocol Service
1878 typedef struct rasqal_service_s rasqal_service
;
1881 rasqal_service
* rasqal_new_service(rasqal_world
* world
, raptor_uri
* service_uri
, const unsigned char* query_string
, raptor_sequence
* data_graphs
);
1883 void rasqal_free_service(rasqal_service
* svc
);
1885 rasqal_query_results
* rasqal_service_execute(rasqal_service
* svc
);
1887 int rasqal_service_set_www(rasqal_service
* svc
, raptor_www
* www
);
1889 int rasqal_service_set_format(rasqal_service
* svc
, const char *format
);
1894 * rasqal_triple_parts:
1895 * @RASQAL_TRIPLE_NONE: no parts
1896 * @RASQAL_TRIPLE_SUBJECT: Subject present in a triple.
1897 * @RASQAL_TRIPLE_PREDICATE: Predicate present in a triple.
1898 * @RASQAL_TRIPLE_OBJECT: Object present in a triple.
1899 * @RASQAL_TRIPLE_ORIGIN: Origin/graph present in a triple.
1900 * @RASQAL_TRIPLE_GRAPH: Alias for RASQAL_TRIPLE_ORIGIN
1901 * @RASQAL_TRIPLE_SPO: Subject, Predicate and Object present in a triple.
1902 * @RASQAL_TRIPLE_SPOG: Subject, Predicate, Object, Graph present in a triple.
1904 * Flags for parts of a triple.
1907 RASQAL_TRIPLE_NONE
= 0,
1908 RASQAL_TRIPLE_SUBJECT
= 1,
1909 RASQAL_TRIPLE_PREDICATE
= 2,
1910 RASQAL_TRIPLE_OBJECT
= 4,
1911 RASQAL_TRIPLE_ORIGIN
= 8,
1912 RASQAL_TRIPLE_GRAPH
= RASQAL_TRIPLE_ORIGIN
,
1913 RASQAL_TRIPLE_SPO
= RASQAL_TRIPLE_SUBJECT
| RASQAL_TRIPLE_PREDICATE
| RASQAL_TRIPLE_OBJECT
,
1914 RASQAL_TRIPLE_SPOG
= RASQAL_TRIPLE_SPO
| RASQAL_TRIPLE_GRAPH
1915 } rasqal_triple_parts
;
1920 * rasqal_triples_match:
1921 * @world: rasqal_world object
1922 * @user_data: User data pointer for factory methods.
1923 * @bind_match: The [4]array (s,p,o,origin) bindings against the current triple match only touching triple parts given. Returns parts that were bound or 0 on failure.
1924 * @next_match: Move to next match.
1925 * @is_end: Check for end of triple match - return non-0 if is end.
1926 * @finish: Finish triples match and destroy any allocated memory.
1927 * @is_exact: non-0 if triple to match is all literal constants
1928 * @finished: >0 if the match has finished
1930 * Triples match structure as initialised by #rasqal_triples_source
1931 * method init_triples_match.
1933 struct rasqal_triples_match_s
{
1934 rasqal_world
*world
;
1938 rasqal_triple_parts (*bind_match
)(struct rasqal_triples_match_s
* rtm
, void *user_data
, rasqal_variable
*bindings
[4], rasqal_triple_parts parts
);
1940 void (*next_match
)(struct rasqal_triples_match_s
* rtm
, void *user_data
);
1942 int (*is_end
)(struct rasqal_triples_match_s
* rtm
, void *user_data
);
1944 void (*finish
)(struct rasqal_triples_match_s
* rtm
, void *user_data
);
1950 typedef struct rasqal_triples_match_s rasqal_triples_match
;
1954 * rasqal_triple_meta:
1955 * @bindings: Variable bindings for this triple+origin to set.
1956 * @triples_match: The matcher that is setting these bindings.
1957 * @context: Context data used by the matcher.
1958 * @parts: Bitmask of #rasqal_triple_parts flags describing the parts of the triple pattern that will bind to variables. There may also be variables mentioned that are bound in other triple patterns even if @parts is 0.
1962 * Metadata for triple pattern matching for one triple pattern.
1965 /* triple (subject, predicate, object) and origin */
1966 rasqal_variable
* bindings
[4];
1968 rasqal_triples_match
*triples_match
;
1972 rasqal_triple_parts parts
;
1977 } rasqal_triple_meta
;
1981 * RASQAL_TRIPLES_SOURCE_MIN_VERSION:
1983 * Lowest accepted @rasqal_triples_source API version
1985 #define RASQAL_TRIPLES_SOURCE_MIN_VERSION 1
1988 * RASQAL_TRIPLES_SOURCE_MAX_VERSION:
1990 * Highest accepted @rasqal_triples_source API version
1992 #define RASQAL_TRIPLES_SOURCE_MAX_VERSION 2
1996 * rasqal_triples_source_feature:
1997 * @RASQAL_TRIPLES_SOURCE_FEATURE_NONE: No feature
1998 * @RASQAL_TRIPLES_SOURCE_FEATURE_IOSTREAM_DATA_GRAPH: Support raptor_iostream data graphs
2000 * Optional features that may be supported by a triple source factory
2003 RASQAL_TRIPLES_SOURCE_FEATURE_NONE
,
2004 RASQAL_TRIPLES_SOURCE_FEATURE_IOSTREAM_DATA_GRAPH
2005 } rasqal_triples_source_feature
;
2009 * rasqal_triples_source:
2010 * @version: API version - only V1 is defined for now
2011 * @query: Source for this query.
2012 * @user_data: Context user data passed into the factory methods.
2013 * @init_triples_match: Factory method to initialize a new #rasqal_triples_match.
2014 * @triple_present: Factory method to return presence or absence of a complete triple.
2015 * @free_triples_source: Factory method to deallocate resources.
2016 * @support_feature: Factory method to test support for a feature, returning non-0 if supported
2018 * Triples source as initialised by a #rasqal_triples_source_factory.
2020 struct rasqal_triples_source_s
{
2023 rasqal_query
* query
;
2028 int (*init_triples_match
)(rasqal_triples_match
* rtm
, struct rasqal_triples_source_s
* rts
, void *user_data
, rasqal_triple_meta
*m
, rasqal_triple
*t
);
2030 int (*triple_present
)(struct rasqal_triples_source_s
* rts
, void *user_data
, rasqal_triple
*t
);
2032 void (*free_triples_source
)(void *user_data
);
2034 /* API v2 onwards */
2035 int (*support_feature
)(void *user_data
, rasqal_triples_source_feature feature
);
2037 typedef struct rasqal_triples_source_s rasqal_triples_source
;
2041 * RASQAL_TRIPLES_SOURCE_FACTORY_MIN_VERSION:
2043 * Lowest accepted @rasqal_triples_source_factory API version
2045 #define RASQAL_TRIPLES_SOURCE_FACTORY_MIN_VERSION 1
2048 * RASQAL_TRIPLES_SOURCE_FACTORY_MAX_VERSION:
2050 * Highest accepted @rasqal_triples_source_factory API version
2052 #define RASQAL_TRIPLES_SOURCE_FACTORY_MAX_VERSION 3
2056 * rasqal_triples_error_handler:
2057 * @query: query object
2058 * @locator: error locator (or NULL)
2059 * @message: error message
2061 * Triples source factory error handler callback.
2063 typedef void (*rasqal_triples_error_handler
)(rasqal_query
* query
, raptor_locator
* locator
, const char* message
);
2067 * rasqal_triples_error_handler2:
2068 * @world: world object
2069 * @locator: error locator (or NULL)
2070 * @message: error message
2072 * Triples source factory error handler callback.
2074 typedef void (*rasqal_triples_error_handler2
)(rasqal_world
* world
, raptor_locator
* locator
, const char* message
);
2078 * rasqal_triples_source_factory:
2079 * @version: API factory version from 1 to 3
2080 * @user_data: User data for triples_source_factory.
2081 * @user_data_size: Size of @user_data for new_triples_source.
2082 * @new_triples_source: Create a new triples source - returns non-zero on failure < 0 is a 'no rdf data error', > 0 is an unspecified error. Error messages are generated by rasqal internally. (V1)
2083 * @init_triples_source: Initialise a new triples source V2 for a particular source URI/base URI and syntax. Returns non-zero on failure with errors reported via the handler callback by the implementation. (V2)
2084 * @init_triples_source2: Initialise a new triples source V3 for a particular source URI/base URI and syntax and given data graphs. Returns non-zero on failure with errors reported via the handler callback by the implementation. If bit 0 of flags is 1, enforce RAPTOR_FEATURE_NO_NET (V3)
2086 * A factory that initialises #rasqal_triples_source structures to
2087 * returning matches to a triple pattern across the dataset formed
2088 * from the data graphs recorded in the @query object.
2094 size_t user_data_size
;
2097 int (*new_triples_source
)(rasqal_query
* query
, void *factory_user_data
, void *user_data
, rasqal_triples_source
* rts
);
2098 /* API v2 onwards */
2099 int (*init_triples_source
)(rasqal_query
* query
, void *factory_user_data
, void *user_data
, rasqal_triples_source
* rts
, rasqal_triples_error_handler handler
);
2100 /* API v3 onwards */
2101 int (*init_triples_source2
)(rasqal_world
* world
, raptor_sequence
* data_graphs
, void *factory_user_data
, void *user_data
, rasqal_triples_source
*rts
, rasqal_triples_error_handler2 handler
, unsigned int flags
);
2102 } rasqal_triples_source_factory
;
2106 * rasqal_triples_source_factory_register_fn:
2107 * @factory: factory to register
2109 * Register a factory for generating triples sources #rasqal_triples_source
2111 * Return value: non-0 on failure
2113 typedef int (*rasqal_triples_source_factory_register_fn
)(rasqal_triples_source_factory
*factory
);
2116 /* set the triples_source_factory */
2118 int rasqal_set_triples_source_factory(rasqal_world
* world
, rasqal_triples_source_factory_register_fn register_fn
, void* user_data
);
2122 /* The info below is solely for gtk-doc - ignore it */
2131 * RASQAL_QUERY_RESULTS_FORMATTER_DECLARED:
2137 * RASQAL_WORLD_DECLARED:
2144 * RASQAL_LITERAL_UDT_DEFINED
2150 * rasqal_expression_s:
2157 * @literal: Internal
2165 * Internal - see #rasqal_expression.
2171 * @rtm: triples match context
2172 * @user_data: user data
2173 * @bindings: variable binding for parts of triple (s, p, o, g)
2174 * @parts: parts of triple to match
2176 * Internal - see #rasqal_triples_match
2178 * Return value: match parts
2183 * @rtm: triples match context
2184 * @user_data: user data
2186 * Internal - see #rasqal_triples_match
2191 * @rtm: triples match context
2192 * @user_data: user data
2194 * Internal - see #rasqal_triples_match
2196 * Return value: non-0 if end of match
2201 * @rtm: triples match context
2202 * @user_data: user data
2204 * Internal - see #rasqal_triples_match
2208 * init_triples_match:
2209 * @rtm: triples match context
2210 * @rts: triples match source
2211 * @user_data: user data
2215 * Internal - see #rasqal_triples_source
2217 * Return value: non-0 on failure
2222 * @rts: triples match source
2223 * @user_data: user data
2224 * @t: triple to test for presence
2226 * Internal - see #rasqal_triples_source
2228 * Return value: non-0 on failure
2232 * free_triples_source:
2233 * @user_data: user data
2235 * Internal - see #rasqal_triples_source
2240 * @user_data: user data
2241 * @feature: feature to test
2243 * Internal - see #rasqal_triples_source
2245 * Return value: non-0 if supported
2249 * rasqal_variables_table:
2251 * Internal - for now