rasqal.h   rasqal.h 
/* -*- Mode: c; c-basic-offset: 2 -*- /* -*- Mode: c; c-basic-offset: 2 -*-
* *
* rasqal.h - Rasqal RDF Query library interfaces and definition * rasqal.h - Rasqal RDF Query library interfaces and definition
* *
* $Id: rasqal.h,v 1.112 2005/06/08 16:20:24 cmdjb Exp $ * $Id: rasqal.h,v 1.133 2006/01/12 05:15:52 cmdjb Exp $
* *
* Copyright (C) 2003-2005, David Beckett http://purl.org/net/dajobe/ * Copyright (C) 2003-2006, David Beckett http://purl.org/net/dajobe/
* Institute for Learning and Research Technology http://www.ilrt.bristol.a * Copyright (C) 2003-2005, University of Bristol, UK http://www.bristol.ac
c.uk/ .uk/
* University of Bristol, UK http://www.bristol.ac.uk/
* *
* This package is Free Software and part of Redland http://librdf.org/ * This package is Free Software and part of Redland http://librdf.org/
* *
* It is licensed under the following three licenses as alternatives: * It is licensed under the following three licenses as alternatives:
* 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
* 2. GNU General Public License (GPL) V2 or any newer version * 2. GNU General Public License (GPL) V2 or any newer version
* 3. Apache License, V2.0 or any newer version * 3. Apache License, V2.0 or any newer version
* *
* You may not use this file except in compliance with at least one of * You may not use this file except in compliance with at least one of
* the above three licenses. * the above three licenses.
skipping to change at line 34 skipping to change at line 33
* *
*/ */
#ifndef RASQAL_H #ifndef RASQAL_H
#define RASQAL_H #define RASQAL_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/**
* RASQAL_API:
*
* Macro for wrapping API function call declarations.
*
*/
#ifdef WIN32 #ifdef WIN32
# ifdef RASQAL_INTERNAL # ifdef RASQAL_INTERNAL
# define RASQAL_API _declspec(dllexport) # define RASQAL_API _declspec(dllexport)
# else # else
# define RASQAL_API _declspec(dllimport) # define RASQAL_API _declspec(dllimport)
# endif # endif
#else #else
# define RASQAL_API # define RASQAL_API
#endif #endif
skipping to change at line 65 skipping to change at line 70
#define RASQAL_DEPRECATED #define RASQAL_DEPRECATED
#endif #endif
#ifndef LIBRDF_OBJC_FRAMEWORK #ifndef LIBRDF_OBJC_FRAMEWORK
#include <raptor.h> #include <raptor.h>
#else #else
#include <Redland/raptor.h> #include <Redland/raptor.h>
#endif #endif
/* Public statics */ /* Public statics */
RASQAL_API extern const char * const rasqal_short_copyright_string; RASQAL_API
RASQAL_API extern const char * const rasqal_copyright_string; extern const char * const rasqal_short_copyright_string;
RASQAL_API extern const char * const rasqal_version_string; RASQAL_API
RASQAL_API extern const unsigned int rasqal_version_major; extern const char * const rasqal_copyright_string;
RASQAL_API extern const unsigned int rasqal_version_minor; RASQAL_API
RASQAL_API extern const unsigned int rasqal_version_release; extern const char * const rasqal_version_string;
RASQAL_API extern const unsigned int rasqal_version_decimal; RASQAL_API
extern const unsigned int rasqal_version_major;
RASQAL_API
extern const unsigned int rasqal_version_minor;
RASQAL_API
extern const unsigned int rasqal_version_release;
RASQAL_API
extern const unsigned int rasqal_version_decimal;
/* Public structure */ /* Public structures */
/**
* rasqal_query:
*
* Rasqal query class.
*/
typedef struct rasqal_query_s rasqal_query; typedef struct rasqal_query_s rasqal_query;
/**
* rasqal_query_results:
*
* Rasqal query results class.
*/
typedef struct rasqal_query_results_s rasqal_query_results; typedef struct rasqal_query_results_s rasqal_query_results;
typedef struct rasqal_literal_s rasqal_literal; typedef struct rasqal_literal_s rasqal_literal;
/**
* rasqal_graph_pattern:
*
* Rasqal graph pattern class.
*/
typedef struct rasqal_graph_pattern_s rasqal_graph_pattern; typedef struct rasqal_graph_pattern_s rasqal_graph_pattern;
/**
* rasqal_feature:
* @RASQAL_FEATURE_LAST: Internal.
*
* Query features.
*
* None currently defined.
*/
typedef enum { typedef enum {
RASQAL_FEATURE_LAST RASQAL_FEATURE_LAST
} rasqal_feature; } rasqal_feature;
/**
* rasqal_prefix:
* @prefix: short prefix string
* @uri: URI associated with the prefix.
* @declared: Internal flag.
* @depth: Internal flag.
*
* Namespace (prefix, uri) pair.
*
* Includes internal flags used for marking when prefixes are
* declared and at what XML element depth when used in XML formats.
*/
typedef struct { typedef struct {
const unsigned char *prefix; const unsigned char *prefix;
raptor_uri* uri; raptor_uri* uri;
int declared; int declared;
int depth; int depth;
} rasqal_prefix; } rasqal_prefix;
/**
* rasqal_variable_type:
* @RASQAL_VARIABLE_TYPE_NORMAL: The regular variable type.
* @RASQAL_VARIABLE_TYPE_ANONYMOUS: Anonymous variable type.
* @RASQAL_VARIABLE_TYPE_UNKNOWN: Internal.
*
* Rasqal variable types.
*
* ANONYMOUS can be used in queries but cannot be returned in a
* result.
*/
typedef enum { typedef enum {
RASQAL_VARIABLE_TYPE_UNKNOWN = 0, RASQAL_VARIABLE_TYPE_UNKNOWN = 0,
RASQAL_VARIABLE_TYPE_NORMAL = 1, RASQAL_VARIABLE_TYPE_NORMAL = 1,
RASQAL_VARIABLE_TYPE_ANONYMOUS = 2 RASQAL_VARIABLE_TYPE_ANONYMOUS = 2
} rasqal_variable_type; } rasqal_variable_type;
/* variable binding */ /**
* rasqal_variable:
* @name: Variable name.
* @value: Variable value or NULL if unbound.
* @offset: Internal.
* @type: Variable type.
*
* Binding between a variable name and a value.
*
* Includes internal field @offset for recording the offset into the
* (internal) rasqal_query variables array.
*/
typedef struct { typedef struct {
const unsigned char *name; const unsigned char *name;
struct rasqal_literal_s *value; rasqal_literal* value;
int offset; /* offset in the rasqal_query variables array */ int offset;
rasqal_variable_type type; /* variable type */ rasqal_variable_type type;
} rasqal_variable; } rasqal_variable;
/**
* rasqal_data_graph_flags:
* @RASQAL_DATA_GRAPH_NONE: Internal.
* @RASQAL_DATA_GRAPH_NAMED: Graphs with a source and name.
* @RASQAL_DATA_GRAPH_BACKGROUND: Graphs with a source only.
*
* Flags for the type of #rasqal_data_graph.
*
* These are used by rasqal_query_add_data_graph(). See #rasqal_data_graph.
*/
typedef enum { typedef enum {
RASQAL_DATA_GRAPH_NONE = 0, RASQAL_DATA_GRAPH_NONE = 0,
RASQAL_DATA_GRAPH_NAMED = 1, RASQAL_DATA_GRAPH_NAMED = 1,
RASQAL_DATA_GRAPH_BACKGROUND = 2, RASQAL_DATA_GRAPH_BACKGROUND = 2,
} rasqal_data_graph_flags; } rasqal_data_graph_flags;
/**
* rasqal_data_graph:
* @uri: source URI
* @name_uri: name of graph for %RASQAL_DATA_NAMED
* @flags: %RASQAL_DATA_GRAPH_NAMED or %RASQAL_DATA_GRAPH_BACKGROUND
*
* A source of RDF data for querying.
*
* The #uri is the original source (base URI) of the content. It may
* also have an additional name @name_uri as long as @flags is
* %RASQAL_DATA_NAMED
*/
typedef struct { typedef struct {
raptor_uri* uri; raptor_uri* uri;
raptor_uri* name_uri; raptor_uri* name_uri;
int flags; int flags;
} rasqal_data_graph; } rasqal_data_graph;
/**
* rasqal_literal_type:
* @RASQAL_LITERAL_BLANK: RDF blank node literal (SPARQL r:bNode)
* @RASQAL_LITERAL_URI: RDF URI Literal (SPARQL r:URI)
* @RASQAL_LITERAL_STRING: RDF Literal / xsd:string (SPARQL r:Literal)
* @RASQAL_LITERAL_BOOLEAN: Boolean literal xsd:boolean.
* @RASQAL_LITERAL_INTEGER: Integer literal xsd:integer.
* @RASQAL_LITERAL_DOUBLE: Double floating point literal xsd:double.
* @RASQAL_LITERAL_FLOATING: Deprecated %RASQAL_LITERAL_DOUBLE.
* @RASQAL_LITERAL_FLOAT: Floating point literal xsd:float.
* @RASQAL_LITERAL_DECIMAL: Decimal integer xsd:decimal.
* @RASQAL_LITERAL_DATETIME: Date/Time literal xsd:dateTime.
* @RASQAL_LITERAL_PATTERN: Pattern literal for a regex.
* @RASQAL_LITERAL_QNAME: XML Qname literal.
* @RASQAL_LITERAL_VARIABLE: Variable literal.
* @RASQAL_LITERAL_UNKNOWN: Internal.
* @RASQAL_LITERAL_FIRST_XSD: Internal.
* @RASQAL_LITERAL_LAST_XSD: Internal.
* @RASQAL_LITERAL_LAST: Internal.
*
* Types of literal.
*
* The order in the enumeration is significant as it encodes
* the SPARQL term ordering conditions:
*
* Blank Nodes << IRIS << RDF literals << typed literals
*
* which coresponds to in enum values
*
* BLANK << URI << STRING <<
* (BOOLEAN | INTEGER | DOUBLE | FLOAT | DECIMAL | DATETIME)
* (RASQAL_LITERAL_FIRST_XSD ... RASQAL_LITERAL_LAST_XSD)
*
* Not used (internal): PATTERN, QNAME, VARIABLE
*
* See rasqal_literal_compare() when used with flags
* %RASQAL_COMPARE_XQUERY
*/
typedef enum { typedef enum {
/* internal */
RASQAL_LITERAL_UNKNOWN, RASQAL_LITERAL_UNKNOWN,
RASQAL_LITERAL_BLANK,
RASQAL_LITERAL_URI, RASQAL_LITERAL_URI,
RASQAL_LITERAL_QNAME,
RASQAL_LITERAL_STRING, RASQAL_LITERAL_STRING,
RASQAL_LITERAL_BLANK,
RASQAL_LITERAL_PATTERN,
RASQAL_LITERAL_BOOLEAN, RASQAL_LITERAL_BOOLEAN,
RASQAL_LITERAL_INTEGER, RASQAL_LITERAL_INTEGER,
RASQAL_LITERAL_FLOATING, RASQAL_LITERAL_DOUBLE,
/* deprecated */
RASQAL_LITERAL_FLOATING = RASQAL_LITERAL_DOUBLE,
RASQAL_LITERAL_FLOAT,
RASQAL_LITERAL_DECIMAL,
RASQAL_LITERAL_DATETIME,
/* internal */
RASQAL_LITERAL_FIRST_XSD = RASQAL_LITERAL_BOOLEAN,
/* internal */
RASQAL_LITERAL_LAST_XSD = RASQAL_LITERAL_DATETIME,
RASQAL_LITERAL_PATTERN,
RASQAL_LITERAL_QNAME,
RASQAL_LITERAL_VARIABLE, RASQAL_LITERAL_VARIABLE,
/* internal */
RASQAL_LITERAL_LAST= RASQAL_LITERAL_VARIABLE RASQAL_LITERAL_LAST= RASQAL_LITERAL_VARIABLE
} rasqal_literal_type; } rasqal_literal_type;
/**
* rasqal_literal:
* @usage: Usage count.
* @type: Type of literal.
* @string: String form of literal for literal types UTF-8 string, pattern,
qname, blank, double, float, decimal, datetime.
* @string_len: Length of @string.
* @value: Alternate value content.
* @language: Language for string literal type.
* @datatype: Datatype for string literal type.
* @flags: Flags for literal types
*
* Rasqal literal class.
*
*/
struct rasqal_literal_s { struct rasqal_literal_s {
int usage; int usage;
rasqal_literal_type type; rasqal_literal_type type;
/* UTF-8 string, pattern, qname, blank, float types */ /* UTF-8 string, pattern, qname, blank, double, float, decimal, datetime */
const unsigned char *string; const unsigned char *string;
unsigned int string_len;
union { union {
/* integer and boolean types */ /* integer and boolean types */
int integer; int integer;
/* floating */ /* double and float */
double floating; double floating;
/* uri (can be temporarily NULL if a qname, see flags below) */ /* uri (can be temporarily NULL if a qname, see flags below) */
raptor_uri* uri; raptor_uri* uri;
/* variable */ /* variable */
rasqal_variable* variable; rasqal_variable* variable;
} value; } value;
/* for string */ /* for string */
const char *language; const char *language;
raptor_uri *datatype; raptor_uri *datatype;
/* various flags for literal types: /* various flags for literal types:
* pattern regex flags * pattern regex flags
* string datatype of qname * string datatype of qname
* uri qname of URI not yet expanded (temporary) * uri qname of URI not yet expanded (temporary)
*/ */
const unsigned char *flags; const unsigned char *flags;
}; };
/**
* rasqal_op:
* @RASQAL_EXPR_AND: Expression for AND(A, B)
* @RASQAL_EXPR_OR: Expression for OR(A, B)
* @RASQAL_EXPR_EQ: Expression for A equals B
* @RASQAL_EXPR_NEQ: Expression for A not equals B.
* @RASQAL_EXPR_LT: Expression for A less than B.
* @RASQAL_EXPR_GT: Expression for A greather than B.
* @RASQAL_EXPR_LE: Expression for A less than or equal to B.
* @RASQAL_EXPR_GE: Expression for A greater than or equal to B.
* @RASQAL_EXPR_UMINUS: Expression for -A.
* @RASQAL_EXPR_PLUS: Expression for +A.
* @RASQAL_EXPR_MINUS: Expression for A-B.
* @RASQAL_EXPR_STAR: Expression for A*B.
* @RASQAL_EXPR_SLASH: Expression for A/B.
* @RASQAL_EXPR_REM: Expression for A/B remainder.
* @RASQAL_EXPR_STR_EQ: Expression for A string equals B.
* @RASQAL_EXPR_STR_NEQ: Expression for A string not-equals B.
* @RASQAL_EXPR_STR_MATCH: Expression for string A matches regex B with fla
gs.
* @RASQAL_EXPR_STR_NMATCH: Expression for string A not-matches regex B wit
h flags.
* @RASQAL_EXPR_TILDE: Expression for binary not A.
* @RASQAL_EXPR_BANG: Expression for logical not A.
* @RASQAL_EXPR_LITERAL: Expression for a #rasqal_literal.
* @RASQAL_EXPR_FUNCTION: Expression for a function A with arguments (B...)
.
* @RASQAL_EXPR_BOUND: Expression for SPARQL ISBOUND(A).
* @RASQAL_EXPR_STR: Expression for SPARQL STR(A).
* @RASQAL_EXPR_LANG: Expression for SPARQL LANG(A).
* @RASQAL_EXPR_LANGMATCHES: Expression for SPARQL LANGMATCHES(A, B).
* @RASQAL_EXPR_DATATYPE: Expression for SPARQL DATATYPE(A).
* @RASQAL_EXPR_ISURI: Expression for SPARQL ISURI(A).
* @RASQAL_EXPR_ISBLANK: Expression for SPARQL ISBLANK(A).
* @RASQAL_EXPR_ISLITERAL: Expression for SPARQL ISLITERAL(A).
* @RASQAL_EXPR_CAST: Expression for cast literal A to type B.
* @RASQAL_EXPR_ORDER_COND_ASC: Expression for SPARQL order condition ascen
ding.
* @RASQAL_EXPR_ORDER_COND_DESC: Expression for SPARQL order condition desc
ending.
* @RASQAL_EXPR_UNKNOWN: Internal
* @RASQAL_EXPR_LAST: Internal
*
* Rasqal expression operators. A mixture of unary, binary and
* tertiary operators (string matches). Also includes casting and
* two ordering operators from ORDER BY in SPARQL.
*/
typedef enum { typedef enum {
/* internal */
RASQAL_EXPR_UNKNOWN, RASQAL_EXPR_UNKNOWN,
RASQAL_EXPR_AND, RASQAL_EXPR_AND,
RASQAL_EXPR_OR, RASQAL_EXPR_OR,
RASQAL_EXPR_EQ, RASQAL_EXPR_EQ,
RASQAL_EXPR_NEQ, RASQAL_EXPR_NEQ,
RASQAL_EXPR_LT, RASQAL_EXPR_LT,
RASQAL_EXPR_GT, RASQAL_EXPR_GT,
RASQAL_EXPR_LE, RASQAL_EXPR_LE,
RASQAL_EXPR_GE, RASQAL_EXPR_GE,
RASQAL_EXPR_UMINUS, RASQAL_EXPR_UMINUS,
skipping to change at line 192 skipping to change at line 395
RASQAL_EXPR_BOUND, RASQAL_EXPR_BOUND,
RASQAL_EXPR_STR, RASQAL_EXPR_STR,
RASQAL_EXPR_LANG, RASQAL_EXPR_LANG,
RASQAL_EXPR_DATATYPE, RASQAL_EXPR_DATATYPE,
RASQAL_EXPR_ISURI, RASQAL_EXPR_ISURI,
RASQAL_EXPR_ISBLANK, RASQAL_EXPR_ISBLANK,
RASQAL_EXPR_ISLITERAL, RASQAL_EXPR_ISLITERAL,
RASQAL_EXPR_CAST, RASQAL_EXPR_CAST,
RASQAL_EXPR_ORDER_COND_ASC, RASQAL_EXPR_ORDER_COND_ASC,
RASQAL_EXPR_ORDER_COND_DESC, RASQAL_EXPR_ORDER_COND_DESC,
RASQAL_EXPR_LAST= RASQAL_EXPR_ORDER_COND_DESC RASQAL_EXPR_LANGMATCHES,
/* internal */
RASQAL_EXPR_LAST= RASQAL_EXPR_LANGMATCHES
} rasqal_op; } rasqal_op;
struct rasqal_variable_s; /**
* rasqal_expression:
/* expression (arg1), unary op (arg1), binary op (arg1,arg2), *
* expression (arg1), unary op (arg1), binary op (arg1,arg2),
* literal or variable * literal or variable
*/ */
struct rasqal_expression_s { struct rasqal_expression_s {
int usage; /* reference count - 1 for itself */
rasqal_op op; rasqal_op op;
struct rasqal_expression_s* arg1; struct rasqal_expression_s* arg1;
struct rasqal_expression_s* arg2; struct rasqal_expression_s* arg2;
rasqal_literal* literal; rasqal_literal* literal;
rasqal_variable* variable; rasqal_variable* variable;
unsigned char *value; /* UTF-8 value */ unsigned char *value; /* UTF-8 value */
/* for extension function qname(args...) and cast-to-uri */ /* for extension function qname(args...) and cast-to-uri */
raptor_uri* name; raptor_uri* name;
raptor_sequence* args; raptor_sequence* args;
}; };
typedef struct rasqal_expression_s rasqal_expression; typedef struct rasqal_expression_s rasqal_expression;
/* Extra flags for triples */ /**
* rasqal_triple_flags:
* @RASQAL_TRIPLE_FLAGS_EXACT: Not used.
* @RASQAL_TRIPLE_FLAGS_OPTIONAL: Not used.
* @RASQAL_TRIPLE_FLAGS_LAST: Internal.
*
* Flags for triple patterns.
*/
typedef enum { typedef enum {
/* Not used - was only used internally in the execution engine */ /* Not used - was only used internally in the execution engine */
RASQAL_TRIPLE_FLAGS_EXACT=1, RASQAL_TRIPLE_FLAGS_EXACT=1,
/* Not used - this is now a property of a graph pattern */ /* Not used - this is now a property of a graph pattern */
RASQAL_TRIPLE_FLAGS_OPTIONAL=2, RASQAL_TRIPLE_FLAGS_OPTIONAL=2,
RASQAL_TRIPLE_FLAGS_LAST=RASQAL_TRIPLE_FLAGS_OPTIONAL RASQAL_TRIPLE_FLAGS_LAST=RASQAL_TRIPLE_FLAGS_OPTIONAL
} rasqal_triple_flags; } rasqal_triple_flags;
/* an RDF triple or a triple pattern */ /**
* rasqal_triple:
* @subject: Triple subject.
* @predicate: Triple predicate.
* @object: Triple object.
* @origin: Triple origin.
* @flags: Or of enum #rasqal_triple_flags bits.
*
* A triple pattern or RDF triple.
*
* This is used as a triple pattern in queries and
* an RDF triple when generating RDF triples such as with SPARQL CONSTRUCT.
*/
typedef struct { typedef struct {
rasqal_literal* subject; rasqal_literal* subject;
rasqal_literal* predicate; rasqal_literal* predicate;
rasqal_literal* object; rasqal_literal* object;
rasqal_literal* origin; rasqal_literal* origin;
unsigned int flags; /* | of enum rasqal_triple_flags bits */ unsigned int flags;
} rasqal_triple ; } rasqal_triple;
/* Flags for graph patterns */ /**
* rasqal_pattern_flags:
* @RASQAL_PATTERN_FLAGS_OPTIONAL: True when the graph pattern is an option
al match.
* @RASQAL_PATTERN_FLAGS_LAST: Internal
*
* Flags for #rasqal_graph_pattern.
*/
typedef enum { typedef enum {
/* true when the graph pattern is an optional match */
RASQAL_PATTERN_FLAGS_OPTIONAL=1, RASQAL_PATTERN_FLAGS_OPTIONAL=1,
RASQAL_PATTERN_FLAGS_LAST=RASQAL_PATTERN_FLAGS_OPTIONAL RASQAL_PATTERN_FLAGS_LAST=RASQAL_PATTERN_FLAGS_OPTIONAL
} rasqal_pattern_flags; } rasqal_pattern_flags;
typedef unsigned char* (*rasqal_generate_bnodeid_handler)(rasqal_query* que ry, void *user_data, unsigned char *user_bnodeid); typedef unsigned char* (*rasqal_generate_bnodeid_handler)(rasqal_query* que ry, void *user_data, unsigned char *user_bnodeid);
/* Query verbs */ /**
* rasqal_query_verb:
* @RASQAL_QUERY_VERB_SELECT: RDQL/SPARQL query select verb.
* @RASQAL_QUERY_VERB_CONSTRUCT: SPARQL query construct verb.
* @RASQAL_QUERY_VERB_DESCRIBE: SPARQL query describe verb.
* @RASQAL_QUERY_VERB_ASK: SPARQL query ask verb.
* @RASQAL_QUERY_VERB_UNKNOWN: Internal
* @RASQAL_QUERY_VERB_LAST: Internal
*
* Query main operation verbs describing the major type of query
* being performed.
*/
typedef enum { typedef enum {
/* internal */
RASQAL_QUERY_VERB_UNKNOWN = 0, RASQAL_QUERY_VERB_UNKNOWN = 0,
RASQAL_QUERY_VERB_SELECT = 1, RASQAL_QUERY_VERB_SELECT = 1,
RASQAL_QUERY_VERB_CONSTRUCT = 2, RASQAL_QUERY_VERB_CONSTRUCT = 2,
RASQAL_QUERY_VERB_DESCRIBE = 3, RASQAL_QUERY_VERB_DESCRIBE = 3,
RASQAL_QUERY_VERB_ASK = 4, RASQAL_QUERY_VERB_ASK = 4,
/* internal */
RASQAL_QUERY_VERB_LAST=RASQAL_QUERY_VERB_ASK RASQAL_QUERY_VERB_LAST=RASQAL_QUERY_VERB_ASK
} rasqal_query_verb; } rasqal_query_verb;
/* Graph pattern operators */ /**
* rasqal_graph_pattern_operator:
* @RASQAL_GRAPH_PATTERN_OPERATOR_BASIC: Just triple patterns and constrain
ts.
* @RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL: Set of graph patterns (ANDed) a
nd constraints.
* @RASQAL_GRAPH_PATTERN_OPERATOR_UNION: Set of graph patterns (UNIONed) an
d constraints.
* @RASQAL_GRAPH_PATTERN_OPERATOR_GROUP: Set of graph patterns (ANDed) and
constraints.
* @RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH: A graph term + a graph pattern and
constraints.
* @RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN: Internal.
* @RASQAL_GRAPH_PATTERN_OPERATOR_LAST: Internal.
*
* Graph pattern operators
*/
typedef enum { typedef enum {
RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN = 0, RASQAL_GRAPH_PATTERN_OPERATOR_UNKNOWN = 0,
/* Basic - just triple patterns and constraints */
RASQAL_GRAPH_PATTERN_OPERATOR_BASIC = 1, RASQAL_GRAPH_PATTERN_OPERATOR_BASIC = 1,
/* Optional - set of graph patterns (ANDed) and constraints */
RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL = 2, RASQAL_GRAPH_PATTERN_OPERATOR_OPTIONAL = 2,
/* Union - set of graph patterns (UNIONed) and constraints */
RASQAL_GRAPH_PATTERN_OPERATOR_UNION = 3, RASQAL_GRAPH_PATTERN_OPERATOR_UNION = 3,
/* Group - set of graph patterns (ANDed) and constraints */
RASQAL_GRAPH_PATTERN_OPERATOR_GROUP = 4, RASQAL_GRAPH_PATTERN_OPERATOR_GROUP = 4,
/* Graph - a graph term + a graph pattern and constraints */
RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH = 5, RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH = 5,
RASQAL_GRAPH_PATTERN_OPERATOR_LAST=RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH RASQAL_GRAPH_PATTERN_OPERATOR_LAST=RASQAL_GRAPH_PATTERN_OPERATOR_GRAPH
} rasqal_graph_pattern_operator; } rasqal_graph_pattern_operator;
/**
* rasqal_graph_pattern_visit_fn:
* @query: #rasqal_query containing the graph pattern
* @gp: current graph_pattern
* @user_data: user data passed in
*
* User function to visit an graph_pattern and operate on it with
* rasqal_graph_pattern_visit() or rasqal_query_graph_pattern_visit()
*
* Return value: 0 to truncate the visit
*/
typedef int (*rasqal_graph_pattern_visit_fn)(rasqal_query* query, rasqal_gr
aph_pattern* gp, void *user_data);
/* RASQAL API */ /* RASQAL API */
/* Public functions */ /* Public functions */
RASQAL_API void rasqal_init(void); RASQAL_API
RASQAL_API void rasqal_finish(void); void rasqal_init(void);
RASQAL_API
void rasqal_finish(void);
RASQAL_API int rasqal_languages_enumerate(const unsigned int counter, const RASQAL_API
char **name, const char **label, const unsigned char **uri_string); int rasqal_languages_enumerate(const unsigned int counter, const char **nam
RASQAL_API int rasqal_language_name_check(const char *name); e, const char **label, const unsigned char **uri_string);
RASQAL_API
int rasqal_language_name_check(const char *name);
/* Query class */ /* Query class */
/* Create */ /* Create */
RASQAL_API rasqal_query* rasqal_new_query(const char *name, const unsigned RASQAL_API
char *uri); rasqal_query* rasqal_new_query(const char *name, const unsigned char *uri);
/* Destroy */ /* Destroy */
RASQAL_API void rasqal_free_query(rasqal_query* query); RASQAL_API
void rasqal_free_query(rasqal_query* query);
/* Methods */ /* Methods */
RASQAL_API const char* rasqal_query_get_name(rasqal_query* query); RASQAL_API
RASQAL_API const char* rasqal_query_get_label(rasqal_query* query); const char* rasqal_query_get_name(rasqal_query* query);
RASQAL_API void rasqal_query_set_fatal_error_handler(rasqal_query* query, v RASQAL_API
oid *user_data, raptor_message_handler handler); const char* rasqal_query_get_label(rasqal_query* query);
RASQAL_API void rasqal_query_set_error_handler(rasqal_query* query, void *u RASQAL_API
ser_data, raptor_message_handler handler); void rasqal_query_set_fatal_error_handler(rasqal_query* query, void *user_d
RASQAL_API void rasqal_query_set_warning_handler(rasqal_query* query, void ata, raptor_message_handler handler);
*user_data, raptor_message_handler handler); RASQAL_API
RASQAL_API void rasqal_query_set_feature(rasqal_query *query, rasqal_featur void rasqal_query_set_error_handler(rasqal_query* query, void *user_data, r
e feature, int value); aptor_message_handler handler);
RASQAL_API void rasqal_query_set_default_generate_bnodeid_parameters(rasqal RASQAL_API
_query* rdf_query, char *prefix, int base); void rasqal_query_set_warning_handler(rasqal_query* query, void *user_data,
RASQAL_API void rasqal_query_set_generate_bnodeid_handler(rasqal_query* que raptor_message_handler handler);
ry, void *user_data, rasqal_generate_bnodeid_handler handler); RASQAL_API
void rasqal_query_set_feature(rasqal_query* query, rasqal_feature feature,
int value);
RASQAL_API
void rasqal_query_set_default_generate_bnodeid_parameters(rasqal_query* rdf
_query, char *prefix, int base);
RASQAL_API
void rasqal_query_set_generate_bnodeid_handler(rasqal_query* query, void *u
ser_data, rasqal_generate_bnodeid_handler handler);
RASQAL_API rasqal_query_verb rasqal_query_get_verb(rasqal_query *query); RASQAL_API
RASQAL_API int rasqal_query_get_wildcard(rasqal_query *query); rasqal_query_verb rasqal_query_get_verb(rasqal_query* query);
RASQAL_API int rasqal_query_get_distinct(rasqal_query *query); RASQAL_API
RASQAL_API void rasqal_query_set_distinct(rasqal_query *query, int is_disti int rasqal_query_get_wildcard(rasqal_query* query);
nct); RASQAL_API
RASQAL_API int rasqal_query_get_limit(rasqal_query *query); int rasqal_query_get_distinct(rasqal_query* query);
RASQAL_API void rasqal_query_set_limit(rasqal_query *query, int limit); RASQAL_API
RASQAL_API int rasqal_query_get_offset(rasqal_query *query); void rasqal_query_set_distinct(rasqal_query* query, int is_distinct);
RASQAL_API void rasqal_query_set_offset(rasqal_query *query, int limit); RASQAL_API
int rasqal_query_get_limit(rasqal_query* query);
RASQAL_API
void rasqal_query_set_limit(rasqal_query* query, int limit);
RASQAL_API
int rasqal_query_get_offset(rasqal_query* query);
RASQAL_API
void rasqal_query_set_offset(rasqal_query* query, int offset);
RASQAL_API int rasqal_query_add_data_graph(rasqal_query* query, raptor_uri* RASQAL_API
uri, raptor_uri* name_uri, int flags); int rasqal_query_add_data_graph(rasqal_query* query, raptor_uri* uri, rapto
RASQAL_API raptor_sequence* rasqal_query_get_data_graph_sequence(rasqal_que r_uri* name_uri, int flags);
ry* query); RASQAL_API
RASQAL_API rasqal_data_graph* rasqal_query_get_data_graph(rasqal_query* que raptor_sequence* rasqal_query_get_data_graph_sequence(rasqal_query* query);
ry, int idx); RASQAL_API
rasqal_data_graph* rasqal_query_get_data_graph(rasqal_query* query, int idx
);
RASQAL_API void rasqal_query_add_variable(rasqal_query* query, rasqal_varia RASQAL_API
ble* var); void rasqal_query_add_variable(rasqal_query* query, rasqal_variable* var);
RASQAL_API raptor_sequence* rasqal_query_get_bound_variable_sequence(rasqal RASQAL_API
_query* query); raptor_sequence* rasqal_query_get_bound_variable_sequence(rasqal_query* que
RASQAL_API raptor_sequence* rasqal_query_get_all_variable_sequence(rasqal_q ry);
uery* query); RASQAL_API
RASQAL_API rasqal_variable* rasqal_query_get_variable(rasqal_query* query, raptor_sequence* rasqal_query_get_all_variable_sequence(rasqal_query* query
int idx); );
RASQAL_API int rasqal_query_has_variable(rasqal_query* query, const unsigne RASQAL_API
d char *name); rasqal_variable* rasqal_query_get_variable(rasqal_query* query, int idx);
RASQAL_API int rasqal_query_set_variable(rasqal_query* query, const unsigne RASQAL_API
d char *name, rasqal_literal* value); int rasqal_query_has_variable(rasqal_query* query, const unsigned char *nam
RASQAL_API raptor_sequence* rasqal_query_get_triple_sequence(rasqal_query* e);
query); RASQAL_API
RASQAL_API rasqal_triple* rasqal_query_get_triple(rasqal_query* query, int int rasqal_query_set_variable(rasqal_query* query, const unsigned char *nam
idx); e, rasqal_literal* value);
RASQAL_API void rasqal_query_add_prefix(rasqal_query* query, rasqal_prefix* RASQAL_API
prefix); raptor_sequence* rasqal_query_get_triple_sequence(rasqal_query* query);
RASQAL_API raptor_sequence* rasqal_query_get_prefix_sequence(rasqal_query* RASQAL_API
query); rasqal_triple* rasqal_query_get_triple(rasqal_query* query, int idx);
RASQAL_API rasqal_prefix* rasqal_query_get_prefix(rasqal_query* query, int RASQAL_API
idx); void rasqal_query_add_prefix(rasqal_query* query, rasqal_prefix* prefix);
RASQAL_API raptor_sequence* rasqal_query_get_order_conditions_sequence(rasq RASQAL_API
al_query* query); raptor_sequence* rasqal_query_get_prefix_sequence(rasqal_query* query);
RASQAL_API rasqal_expression* rasqal_query_get_order_condition(rasqal_query RASQAL_API
* query, int idx); rasqal_prefix* rasqal_query_get_prefix(rasqal_query* query, int idx);
RASQAL_API
raptor_sequence* rasqal_query_get_order_conditions_sequence(rasqal_query* q
uery);
RASQAL_API
rasqal_expression* rasqal_query_get_order_condition(rasqal_query* query, in
t idx);
RASQAL_API
raptor_sequence* rasqal_query_get_construct_triples_sequence(rasqal_query*
query);
RASQAL_API
rasqal_triple* rasqal_query_get_construct_triple(rasqal_query* query, int i
dx);
RASQAL_API
void rasqal_query_graph_pattern_visit(rasqal_query* query, rasqal_graph_pat
tern_visit_fn visit_fn, void* data);
/* graph patterns */ /* graph patterns */
RASQAL_API rasqal_graph_pattern* rasqal_query_get_query_graph_pattern(rasqa RASQAL_API
l_query* query); rasqal_graph_pattern* rasqal_query_get_query_graph_pattern(rasqal_query* qu
RASQAL_API raptor_sequence* rasqal_query_get_graph_pattern_sequence(rasqal_ ery);
query* query); RASQAL_API
RASQAL_API rasqal_graph_pattern* rasqal_query_get_graph_pattern(rasqal_quer raptor_sequence* rasqal_query_get_graph_pattern_sequence(rasqal_query* quer
y* query, int idx); y);
RASQAL_API void rasqal_graph_pattern_add_sub_graph_pattern(rasqal_graph_pat RASQAL_API
tern* graph_pattern, rasqal_graph_pattern* sub_graph_pattern); rasqal_graph_pattern* rasqal_query_get_graph_pattern(rasqal_query* query, i
RASQAL_API rasqal_triple* rasqal_graph_pattern_get_triple(rasqal_graph_patt nt idx);
ern* graph_pattern, int idx); RASQAL_API
RASQAL_API raptor_sequence* rasqal_graph_pattern_get_sub_graph_pattern_sequ void rasqal_graph_pattern_add_sub_graph_pattern(rasqal_graph_pattern* graph
ence(rasqal_graph_pattern* graph_pattern); _pattern, rasqal_graph_pattern* sub_graph_pattern);
RASQAL_API rasqal_graph_pattern* rasqal_graph_pattern_get_sub_graph_pattern RASQAL_API
(rasqal_graph_pattern* graph_pattern, int idx); rasqal_triple* rasqal_graph_pattern_get_triple(rasqal_graph_pattern* graph_
RASQAL_API RASQAL_DEPRECATED int rasqal_graph_pattern_get_flags(rasqal_grap pattern, int idx);
h_pattern* graph_pattern); RASQAL_API
RASQAL_API rasqal_graph_pattern_operator rasqal_graph_pattern_get_operator( raptor_sequence* rasqal_graph_pattern_get_sub_graph_pattern_sequence(rasqal
rasqal_graph_pattern* graph_pattern); _graph_pattern* graph_pattern);
RASQAL_API const char* rasqal_graph_pattern_operator_as_string(rasqal_graph RASQAL_API
_pattern_operator verb); rasqal_graph_pattern* rasqal_graph_pattern_get_sub_graph_pattern(rasqal_gra
RASQAL_API void rasqal_graph_pattern_print(rasqal_graph_pattern* gp, FILE* ph_pattern* graph_pattern, int idx);
fh); RASQAL_API RASQAL_DEPRECATED
RASQAL_API int rasqal_graph_pattern_add_constraint(rasqal_graph_pattern* gp int rasqal_graph_pattern_get_flags(rasqal_graph_pattern* graph_pattern);
, rasqal_expression* expr); RASQAL_API
RASQAL_API raptor_sequence* rasqal_graph_pattern_get_constraint_sequence(ra rasqal_graph_pattern_operator rasqal_graph_pattern_get_operator(rasqal_grap
sqal_graph_pattern* gp); h_pattern* graph_pattern);
RASQAL_API rasqal_expression* rasqal_graph_pattern_get_constraint(rasqal_gr RASQAL_API
aph_pattern* gp, int idx); const char* rasqal_graph_pattern_operator_as_string(rasqal_graph_pattern_op
RASQAL_API raptor_sequence* rasqal_query_get_construct_triples_sequence(ras erator op);
qal_query* query); RASQAL_API
RASQAL_API rasqal_triple* rasqal_query_get_construct_triple(rasqal_query* q void rasqal_graph_pattern_print(rasqal_graph_pattern* gp, FILE* fh);
uery, int idx); RASQAL_API
int rasqal_graph_pattern_add_constraint(rasqal_graph_pattern* gp, rasqal_ex
pression* expr);
RASQAL_API
raptor_sequence* rasqal_graph_pattern_get_constraint_sequence(rasqal_graph_
pattern* gp);
RASQAL_API
rasqal_expression* rasqal_graph_pattern_get_constraint(rasqal_graph_pattern
* gp, int idx);
RASQAL_API
int rasqal_graph_pattern_visit(rasqal_query* query, rasqal_graph_pattern *g
p, rasqal_graph_pattern_visit_fn fn, void* user_data);
/* Utility methods */ /* Utility methods */
RASQAL_API const char* rasqal_query_verb_as_string(rasqal_query_verb verb); RASQAL_API
RASQAL_API void rasqal_query_print(rasqal_query* query, FILE *stream); const char* rasqal_query_verb_as_string(rasqal_query_verb verb);
RASQAL_API
void rasqal_query_print(rasqal_query* query, FILE* fh);
/* Query */ /* Query */
RASQAL_API int rasqal_query_prepare(rasqal_query* query, const unsigned cha RASQAL_API
r *query_string, raptor_uri *base_uri); int rasqal_query_prepare(rasqal_query* query, const unsigned char *query_st
RASQAL_API rasqal_query_results* rasqal_query_execute(rasqal_query* query); ring, raptor_uri *base_uri);
RASQAL_API
rasqal_query_results* rasqal_query_execute(rasqal_query* query);
RASQAL_API void* rasqal_query_get_user_data(rasqal_query *query); RASQAL_API
RASQAL_API void rasqal_query_set_user_data(rasqal_query *query, void *user_ void* rasqal_query_get_user_data(rasqal_query* query);
data); RASQAL_API
void rasqal_query_set_user_data(rasqal_query* query, void *user_data);
/* query results */ /* query results */
RASQAL_API void rasqal_free_query_results(rasqal_query_results *query_resul RASQAL_API
ts); void rasqal_free_query_results(rasqal_query_results *query_results);
/* Bindings result format */ /* Bindings result format */
RASQAL_API int rasqal_query_results_is_bindings(rasqal_query_results *query RASQAL_API
_results); int rasqal_query_results_is_bindings(rasqal_query_results *query_results);
RASQAL_API int rasqal_query_results_get_count(rasqal_query_results *query_r RASQAL_API
esults); int rasqal_query_results_get_count(rasqal_query_results *query_results);
RASQAL_API int rasqal_query_results_next(rasqal_query_results *query_result RASQAL_API
s); int rasqal_query_results_next(rasqal_query_results *query_results);
RASQAL_API int rasqal_query_results_finished(rasqal_query_results *query_re RASQAL_API
sults); int rasqal_query_results_finished(rasqal_query_results *query_results);
RASQAL_API int rasqal_query_results_get_bindings(rasqal_query_results *quer RASQAL_API
y_results, const unsigned char ***names, rasqal_literal ***values); int rasqal_query_results_get_bindings(rasqal_query_results *query_results,
RASQAL_API rasqal_literal* rasqal_query_results_get_binding_value(rasqal_qu const unsigned char ***names, rasqal_literal ***values);
ery_results *query_results, int offset); RASQAL_API
RASQAL_API const unsigned char* rasqal_query_results_get_binding_name(rasqa rasqal_literal* rasqal_query_results_get_binding_value(rasqal_query_results
l_query_results *query_results, int offset); *query_results, int offset);
RASQAL_API rasqal_literal* rasqal_query_results_get_binding_value_by_name(r RASQAL_API
asqal_query_results *query_results, const unsigned char *name); const unsigned char* rasqal_query_results_get_binding_name(rasqal_query_res
RASQAL_API int rasqal_query_results_get_bindings_count(rasqal_query_results ults *query_results, int offset);
*query_results); RASQAL_API
rasqal_literal* rasqal_query_results_get_binding_value_by_name(rasqal_query
_results *query_results, const unsigned char *name);
RASQAL_API
int rasqal_query_results_get_bindings_count(rasqal_query_results *query_res
ults);
/* Boolean result format */ /* Boolean result format */
RASQAL_API int rasqal_query_results_is_boolean(rasqal_query_results *query_ RASQAL_API
results); int rasqal_query_results_is_boolean(rasqal_query_results *query_results);
RASQAL_API int rasqal_query_results_get_boolean(rasqal_query_results *query RASQAL_API
_results); int rasqal_query_results_get_boolean(rasqal_query_results *query_results);
/* Graph result format */ /* Graph result format */
RASQAL_API int rasqal_query_results_is_graph(rasqal_query_results *query_re RASQAL_API
sults); int rasqal_query_results_is_graph(rasqal_query_results *query_results);
RASQAL_API raptor_statement* rasqal_query_results_get_triple(rasqal_query_r RASQAL_API
esults *query_results); raptor_statement* rasqal_query_results_get_triple(rasqal_query_results *que
RASQAL_API int rasqal_query_results_next_triple(rasqal_query_results *query ry_results);
_results); RASQAL_API
int rasqal_query_results_next_triple(rasqal_query_results *query_results);
RASQAL_API int rasqal_query_results_write(raptor_iostream *iostr, rasqal_qu RASQAL_API
ery_results *results, raptor_uri *format_uri, raptor_uri *base_uri); int rasqal_query_results_write(raptor_iostream *iostr, rasqal_query_results
*results, raptor_uri *format_uri, raptor_uri *base_uri);
/* Data graph class */ /* Data graph class */
RASQAL_API rasqal_data_graph* rasqal_new_data_graph(raptor_uri* uri, raptor RASQAL_API
_uri* name_uri, int flags); rasqal_data_graph* rasqal_new_data_graph(raptor_uri* uri, raptor_uri* name_
RASQAL_API void rasqal_free_data_graph(rasqal_data_graph* dg); uri, int flags);
RASQAL_API void rasqal_data_graph_print(rasqal_data_graph* dg, FILE* fh); RASQAL_API
void rasqal_free_data_graph(rasqal_data_graph* dg);
RASQAL_API
void rasqal_data_graph_print(rasqal_data_graph* dg, FILE* fh);
/**
* rasqal_compare_flags:
* @RASQAL_COMPARE_NOCASE: String comparisons are case independent.
* @RASQAL_COMPARE_XQUERY: XQuery comparsion rules apply.
*
* Flags for rasqal_expression_evaluate() or rasqal_literal_compare().
*/
typedef enum {
RASQAL_COMPARE_NOCASE = 1,
RASQAL_COMPARE_XQUERY = 2
} rasqal_compare_flags;
/* Expression class */ /* Expression class */
RASQAL_API rasqal_expression* rasqal_new_1op_expression(rasqal_op op, rasqa RASQAL_API
l_expression* arg); rasqal_expression* rasqal_new_1op_expression(rasqal_op op, rasqal_expressio
RASQAL_API rasqal_expression* rasqal_new_2op_expression(rasqal_op op, rasqa n* arg);
l_expression* arg1, rasqal_expression* arg2); RASQAL_API
RASQAL_API rasqal_expression* rasqal_new_string_op_expression(rasqal_op op, rasqal_expression* rasqal_new_2op_expression(rasqal_op op, rasqal_expressio
rasqal_expression* arg1, rasqal_literal* literal); n* arg1, rasqal_expression* arg2);
RASQAL_API rasqal_expression* rasqal_new_literal_expression(rasqal_literal* RASQAL_API
literal); rasqal_expression* rasqal_new_string_op_expression(rasqal_op op, rasqal_exp
RASQAL_API rasqal_expression* rasqal_new_variable_expression(rasqal_variabl ression* arg1, rasqal_literal* literal);
e *variable); RASQAL_API
RASQAL_API rasqal_expression* rasqal_new_function_expression(raptor_uri* na rasqal_expression* rasqal_new_literal_expression(rasqal_literal* literal);
me, raptor_sequence* args); RASQAL_API
RASQAL_API rasqal_expression* rasqal_new_cast_expression(raptor_uri* name, rasqal_expression* rasqal_new_function_expression(raptor_uri* name, raptor_
rasqal_expression *value); sequence* args);
RASQAL_API
rasqal_expression* rasqal_new_cast_expression(raptor_uri* name, rasqal_expr
ession *value);
RASQAL_API
rasqal_expression* rasqal_new_expression_from_expression(rasqal_expression*
e);
RASQAL_API void rasqal_free_expression(rasqal_expression* expr); RASQAL_API
RASQAL_API void rasqal_expression_print_op(rasqal_expression* expr, FILE* f void rasqal_free_expression(rasqal_expression* e);
h); RASQAL_API
RASQAL_API void rasqal_expression_print(rasqal_expression* expr, FILE* fh); void rasqal_expression_print_op(rasqal_expression* e, FILE* fh);
RASQAL_API rasqal_literal* rasqal_expression_evaluate(rasqal_query *query, RASQAL_API
rasqal_expression* expr); void rasqal_expression_print(rasqal_expression* e, FILE* fh);
RASQAL_API
rasqal_literal* rasqal_expression_evaluate(rasqal_query* query, rasqal_expr
ession* e, int flags);
/**
* rasqal_expression_foreach_fn:
* @user_data: user data passed in with rasqal_expression_foreach()
* @e: current expression
*
* User function to visit an expression and operate on it.
*
* @deprecated: Use #rasqal_expression_visit_fn and rasqal_expression_visit
()
*
* Return value: 0 to truncate the visit
*/
typedef int (*rasqal_expression_foreach_fn)(void *user_data, rasqal_express ion *e); typedef int (*rasqal_expression_foreach_fn)(void *user_data, rasqal_express ion *e);
RASQAL_API int rasqal_expression_foreach(rasqal_expression* expr, rasqal_ex
pression_foreach_fn fn, void *user_data); RASQAL_API RASQAL_DEPRECATED
int rasqal_expression_foreach(rasqal_expression* e, rasqal_expression_forea
ch_fn fn, void *user_data);
/**
* rasqal_expression_visit_fn:
* @user_data: user data passed in with rasqal_expression_visit()
* @e: current expression
*
* User function to visit an expression and operate on it with
* rasqal_expression_visit()
*
* Return value: 0 to truncate the visit
*/
typedef int (*rasqal_expression_visit_fn)(void *user_data, rasqal_expressio
n *e);
RASQAL_API
int rasqal_expression_visit(rasqal_expression* e, rasqal_expression_visit_f
n fn, void *user_data);
/* Literal class */ /* Literal class */
RASQAL_API rasqal_literal* rasqal_new_integer_literal(rasqal_literal_type t RASQAL_API
ype, int integer); rasqal_literal* rasqal_new_integer_literal(rasqal_literal_type type, int in
RASQAL_API rasqal_literal* rasqal_new_floating_literal(double f); teger);
RASQAL_API rasqal_literal* rasqal_new_uri_literal(raptor_uri* uri); RASQAL_API RASQAL_DEPRECATED
RASQAL_API rasqal_literal* rasqal_new_pattern_literal(const unsigned char * rasqal_literal* rasqal_new_floating_literal(double f);
pattern, const char *flags); RASQAL_API
RASQAL_API rasqal_literal* rasqal_new_string_literal(const unsigned char *s rasqal_literal* rasqal_new_double_literal(double d);
tring, const char *language, raptor_uri *datatype, const unsigned char *dat RASQAL_API
atype_qname); rasqal_literal* rasqal_new_uri_literal(raptor_uri* uri);
RASQAL_API rasqal_literal* rasqal_new_simple_literal(rasqal_literal_type ty RASQAL_API
pe, const unsigned char *string); rasqal_literal* rasqal_new_pattern_literal(const unsigned char *pattern, co
RASQAL_API rasqal_literal* rasqal_new_boolean_literal(int value); nst char *flags);
RASQAL_API rasqal_literal* rasqal_new_variable_literal(rasqal_variable *var RASQAL_API
iable); rasqal_literal* rasqal_new_string_literal(const unsigned char *string, cons
t char *language, raptor_uri *datatype, const unsigned char *datatype_qname
);
RASQAL_API
rasqal_literal* rasqal_new_simple_literal(rasqal_literal_type type, const u
nsigned char *string);
RASQAL_API
rasqal_literal* rasqal_new_boolean_literal(int value);
RASQAL_API
rasqal_literal* rasqal_new_variable_literal(rasqal_variable *variable);
RASQAL_API
rasqal_literal* rasqal_new_decimal_literal(const unsigned char *decimal);
RASQAL_API rasqal_literal* rasqal_new_literal_from_literal(rasqal_literal* RASQAL_API
literal); rasqal_literal* rasqal_new_literal_from_literal(rasqal_literal* l);
RASQAL_API void rasqal_free_literal(rasqal_literal* literal); RASQAL_API
RASQAL_API void rasqal_literal_print(rasqal_literal* literal, FILE* fh); void rasqal_free_literal(rasqal_literal* l);
RASQAL_API void rasqal_literal_print_type(rasqal_literal* literal, FILE* fh RASQAL_API
); void rasqal_literal_print(rasqal_literal* l, FILE* fh);
RASQAL_API rasqal_variable* rasqal_literal_as_variable(rasqal_literal* lite RASQAL_API
ral); void rasqal_literal_print_type(rasqal_literal* l, FILE* fh);
RASQAL_API const unsigned char* rasqal_literal_as_string(rasqal_literal* li RASQAL_API
teral); rasqal_variable* rasqal_literal_as_variable(rasqal_literal* l);
RASQAL_API rasqal_literal* rasqal_literal_as_node(rasqal_literal* literal); RASQAL_API
const unsigned char* rasqal_literal_as_string(rasqal_literal* l);
RASQAL_API
rasqal_literal* rasqal_literal_as_node(rasqal_literal* l);
#define RASQAL_COMPARE_NOCASE 1 RASQAL_API
RASQAL_API int rasqal_literal_compare(rasqal_literal* l1, rasqal_literal* l int rasqal_literal_compare(rasqal_literal* l1, rasqal_literal* l2, int flag
2, int flags, int *error); s, int *error);
RASQAL_API int rasqal_literal_equals(rasqal_literal* l1, rasqal_literal* l2 RASQAL_API
); int rasqal_literal_equals(rasqal_literal* l1, rasqal_literal* l2);
RASQAL_API rasqal_prefix* rasqal_new_prefix(const unsigned char* prefix, ra RASQAL_API
ptor_uri* uri); rasqal_prefix* rasqal_new_prefix(const unsigned char* prefix, raptor_uri* u
RASQAL_API void rasqal_free_prefix(rasqal_prefix* prefix); ri);
RASQAL_API void rasqal_prefix_print(rasqal_prefix* p, FILE* fh); RASQAL_API
void rasqal_free_prefix(rasqal_prefix* p);
RASQAL_API
void rasqal_prefix_print(rasqal_prefix* p, FILE* fh);
/* Triple class */ /* Triple class */
RASQAL_API rasqal_triple* rasqal_new_triple(rasqal_literal* subject, rasqal RASQAL_API
_literal* predicate, rasqal_literal* object); rasqal_triple* rasqal_new_triple(rasqal_literal* subject, rasqal_literal* p
RASQAL_API rasqal_triple* rasqal_new_triple_from_triple(rasqal_triple* t); redicate, rasqal_literal* object);
RASQAL_API void rasqal_free_triple(rasqal_triple* t); RASQAL_API
RASQAL_API void rasqal_triple_print(rasqal_triple* t, FILE* fh); rasqal_triple* rasqal_new_triple_from_triple(rasqal_triple* t);
RASQAL_API void rasqal_triple_set_origin(rasqal_triple* t, rasqal_literal * RASQAL_API
l); void rasqal_free_triple(rasqal_triple* t);
RASQAL_API rasqal_literal* rasqal_triple_get_origin(rasqal_triple* t); RASQAL_API
void rasqal_triple_print(rasqal_triple* t, FILE* fh);
RASQAL_API
void rasqal_triple_set_origin(rasqal_triple* t, rasqal_literal *l);
RASQAL_API
rasqal_literal* rasqal_triple_get_origin(rasqal_triple* t);
/* Variable class */ /* Variable class */
RASQAL_API rasqal_variable* rasqal_new_variable_typed(rasqal_query* rq, ras RASQAL_API
qal_variable_type type, unsigned char *name, rasqal_literal *value); rasqal_variable* rasqal_new_variable_typed(rasqal_query* rq, rasqal_variabl
RASQAL_API rasqal_variable* rasqal_new_variable(rasqal_query* query, unsign e_type type, unsigned char *name, rasqal_literal *value);
ed char *name, rasqal_literal *value); RASQAL_API
RASQAL_API void rasqal_free_variable(rasqal_variable* variable); rasqal_variable* rasqal_new_variable(rasqal_query* rq, unsigned char *name,
RASQAL_API void rasqal_variable_print(rasqal_variable* t, FILE* fh); rasqal_literal *value);
RASQAL_API void rasqal_variable_set_value(rasqal_variable* v, rasqal_litera RASQAL_API
l *l); void rasqal_free_variable(rasqal_variable* v);
RASQAL_API
void rasqal_variable_print(rasqal_variable* v, FILE* fh);
RASQAL_API
void rasqal_variable_set_value(rasqal_variable* v, rasqal_literal* l);
/* memory functions */ /* memory functions */
RASQAL_API void rasqal_free_memory(void *ptr); RASQAL_API
RASQAL_API void* rasqal_alloc_memory(size_t size); void rasqal_free_memory(void *ptr);
RASQAL_API void* rasqal_calloc_memory(size_t nmemb, size_t size); RASQAL_API
void* rasqal_alloc_memory(size_t size);
RASQAL_API
void* rasqal_calloc_memory(size_t nmemb, size_t size);
/* rasqal_engine.c */ /* rasqal_engine.c */
/**
* rasqal_triple_parts:
* @RASQAL_TRIPLE_SUBJECT: Subject present in a triple.
* @RASQAL_TRIPLE_PREDICATE: Predicate present in a triple.
* @RASQAL_TRIPLE_OBJECT: Object present in a triple.
* @RASQAL_TRIPLE_ORIGIN: Origin present in a triple.
*
* Flags for parts of a triple.
*/
typedef enum { typedef enum {
RASQAL_TRIPLE_SUBJECT = 1, RASQAL_TRIPLE_SUBJECT = 1,
RASQAL_TRIPLE_PREDICATE= 2, RASQAL_TRIPLE_PREDICATE= 2,
RASQAL_TRIPLE_OBJECT = 4, RASQAL_TRIPLE_OBJECT = 4,
RASQAL_TRIPLE_ORIGIN = 8 RASQAL_TRIPLE_ORIGIN = 8
} rasqal_triple_parts; } rasqal_triple_parts;
/**
* rasqal_triples_match:
* @user_data: User data pointer for factory methods.
* @bind_match: The [4]array (s,p,o,origin) bindings against the current tr
iple match only touching triple parts given. Returns parts that were bound
or 0 on failure.
* @next_match: Move to next match.
* @is_end: Check for end of triple match - return non-0 if is end.
* @finish: Finish triples match and destroy any allocated memory.
*
* Triples match structure as initialised by #rasqal_triples_source
* method init_triples_match.
*/
struct rasqal_triples_match_s { struct rasqal_triples_match_s {
void *user_data; void *user_data;
/* 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
*/
rasqal_triple_parts (*bind_match)(struct rasqal_triples_match_s*, void *u ser_data, rasqal_variable *bindings[4], rasqal_triple_parts parts); rasqal_triple_parts (*bind_match)(struct rasqal_triples_match_s*, void *u ser_data, rasqal_variable *bindings[4], rasqal_triple_parts parts);
/* move to next match */
void (*next_match)(struct rasqal_triples_match_s*, void *user_data); void (*next_match)(struct rasqal_triples_match_s*, void *user_data);
/* check for end of triple match - return non-0 if is end */
int (*is_end)(struct rasqal_triples_match_s*, void *user_data); int (*is_end)(struct rasqal_triples_match_s*, void *user_data);
/* finish triples match and destroy any allocated memory */
void (*finish)(struct rasqal_triples_match_s*, void *user_data); void (*finish)(struct rasqal_triples_match_s*, void *user_data);
}; };
typedef struct rasqal_triples_match_s rasqal_triples_match; typedef struct rasqal_triples_match_s rasqal_triples_match;
/**
* rasqal_triple_meta:
* @bindings: Variable bindings for this triple+origin to set.
* @triples_match: The matcher that is setting these bindings.
* @context: Context data used by the matcher.
* @parts: Parts of the triple to match/bindings to set.
* @is_exact: non-0 if all parts of the triple are given
*
* Triple matching metadata for one triple pattern.
*/
typedef struct typedef struct
{ {
/* triple (subject, predicate, object) and origin */ /* triple (subject, predicate, object) and origin */
rasqal_variable* bindings[4]; rasqal_variable* bindings[4];
rasqal_triples_match *triples_match; rasqal_triples_match *triples_match;
void *context; void *context;
/* parts of the triple*/
rasqal_triple_parts parts; rasqal_triple_parts parts;
/* non-0 if all parts of the triple are given */
int is_exact; int is_exact;
} rasqal_triple_meta; } rasqal_triple_meta;
/**
* rasqal_triples_source:
* @query: Source for this query.
* @user_data: Context user data passed into the factory methods.
* @init_triples_match: Factory method to initalise a new #rasqal_triples_m
atch.
* @triple_present: Factory method to return presence or absence of a compl
ete triple.
* @free_triples_source: Factory method to deallocate resources.
*
* Triples source as initialised by a #rasqal_triples_source_factory.
*/
struct rasqal_triples_source_s { struct rasqal_triples_source_s {
/* A source for this query */ rasqal_query* query;
rasqal_query *query;
void *user_data; void *user_data;
/* the triples_source_factory initialises these method */
int (*init_triples_match)(rasqal_triples_match* rtm, struct rasqal_triple s_source_s* rts, void *user_data, rasqal_triple_meta *m, rasqal_triple *t); int (*init_triples_match)(rasqal_triples_match* rtm, struct rasqal_triple s_source_s* rts, void *user_data, rasqal_triple_meta *m, rasqal_triple *t);
int (*triple_present)(struct rasqal_triples_source_s* rts, void *user_dat a, rasqal_triple *t); int (*triple_present)(struct rasqal_triples_source_s* rts, void *user_dat a, rasqal_triple *t);
void (*free_triples_source)(void *user_data); void (*free_triples_source)(void *user_data);
}; };
typedef struct rasqal_triples_source_s rasqal_triples_source; typedef struct rasqal_triples_source_s rasqal_triples_source;
/**
* rasqal_triples_source_factory:
* @user_data: User data for triples_source_factory.
* @user_data_size: Size Of @user_data for new_triples_source.
* @new_triples_source: Create a new triples source - returns non-zero on f
ailure &lt; 0 is a 'no rdf data error', &gt; 0 is an unspecified error..
*
* A factory that initialises #rasqal_triples_source structures
* to returning matches to a triple pattern.
*/
typedef struct { typedef struct {
void *user_data; /* user data for triples_source_factory */ void *user_data;
size_t user_data_size; /* size of user data for new_triples_source */ size_t user_data_size;
/** int (*new_triples_source)(rasqal_query* query, void *factory_user_data, v
* create a new triples source - returns non-zero on failure oid *user_data, rasqal_triples_source* rts);
* < 0 is a 'no rdf data error', > 0 is an unspecified error
*/
int (*new_triples_source)(rasqal_query *query, void *factory_user_data, v
oid *user_data, rasqal_triples_source* rts);
} rasqal_triples_source_factory; } rasqal_triples_source_factory;
/* set the triples_source_factory */ /* set the triples_source_factory */
RASQAL_API void rasqal_set_triples_source_factory(void (*register_fn)(rasqa RASQAL_API
l_triples_source_factory *factory), void* user_data); void rasqal_set_triples_source_factory(void (*register_fn)(rasqal_triples_s
ource_factory *factory), void* user_data);
/* The info below is solely for gtk-doc - ignore it */
/**
* rasqal_expression_s:
* @usage: Internal
* @op: Internal
* @arg1: Internal
* @arg2: Internal
* @literal: Internal
* @variable: Internal
* @value: Internal
* @name: Internal
* @args: Internal
*
* Internal - see #rasqal_expression.
*
*/
/**
* rasqal_literal_s:
* @usage: Internal
* @type: Internal
* @string: Internal
* @string_len: Internal
*
* Internal - see #rasqal_literal.
*
*/
/**
* rasqal_triples_match_s:
* @user_data: Internal
* @bind_match: Internal
* @next_match: Internal
* @is_end: Internal
* @finish: Internal
*
* Internal - see #rasqal_triples_match.
*
*/
/**
* rasqal_triples_source_s:
* @query: Internal
* @user_data: Internal
* @init_triples_match: Internal
* @triple_present: Internal
* @free_triples_source: Internal
*
* Internal - see #rasqal_triples_source.
*
*/
/**
* rasqal_variable_s:
*
* Internal.
*
*/
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
 End of changes. 91 change blocks. 
277 lines changed or deleted 798 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/