rasqal.h | rasqal.h | |||
---|---|---|---|---|
/* -*- Mode: c; c-basic-offset: 2 -*- | /* -*- Mode: c; c-basic-offset: 2 -*- | |||
* | * | |||
* rdql.h - Rasqal RDF Query library interfaces and definition | * rdql.h - Rasqal RDF Query library interfaces and definition | |||
* | * | |||
* $Id: rasqal.h,v 1.55 2004/08/03 14:05:09 cmdjb Exp $ | * $Id: rasqal.h,v 1.65 2004/10/25 14:00:36 cmdjb Exp $ | |||
* | * | |||
* Copyright (C) 2003-2004 David Beckett - http://purl.org/net/dajobe/ | * Copyright (C) 2003-2004, David Beckett http://purl.org/net/dajobe/ | |||
* Institute for Learning and Research Technology - http://www.ilrt.bris.ac | * Institute for Learning and Research Technology http://www.ilrt.bristol.a | |||
.uk/ | c.uk/ | |||
* University of Bristol - http://www.bristol.ac.uk/ | * University of Bristol, UK http://www.bristol.ac.uk/ | |||
* | * | |||
* This package is Free Software or Open Source available under the | * This package is Free Software and part of Redland http://librdf.org/ | |||
* following licenses (these are alternatives): | * | |||
* 1. GNU Lesser General Public License (LGPL) | * It is licensed under the following three licenses as alternatives: | |||
* 2. GNU General Public License (GPL) | * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version | |||
* 3. Mozilla Public License (MPL) | * 2. GNU General Public License (GPL) V2 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 | ||||
* the above three licenses. | ||||
* | * | |||
* See LICENSE.html or LICENSE.txt at the top of this package for the | * See LICENSE.html or LICENSE.txt at the top of this package for the | |||
* full license terms. | * complete terms and further detail along with the license texts for | |||
* the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. | ||||
* | * | |||
*/ | */ | |||
#ifndef RDQL_H | #ifndef RDQL_H | |||
#define RDQL_H | #define RDQL_H | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
skipping to change at line 62 | skipping to change at line 67 | |||
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; | |||
typedef enum { | typedef enum { | |||
RASQAL_FEATURE_LAST | RASQAL_FEATURE_LAST | |||
} rasqal_feature; | } rasqal_feature; | |||
typedef struct { | typedef struct { | |||
const unsigned char *prefix; | const unsigned char *prefix; | |||
raptor_uri* uri; | raptor_uri* uri; | |||
} rasqal_prefix ; | int declared; | |||
int depth; | ||||
} rasqal_prefix; | ||||
/* variable binding */ | /* variable binding */ | |||
typedef struct { | typedef struct { | |||
const unsigned char *name; | const unsigned char *name; | |||
struct rasqal_literal_s *value; | struct rasqal_literal_s *value; | |||
int offset; /* offset in the rasqal_query variables array */ | int offset; /* offset in the rasqal_query variables array */ | |||
} rasqal_variable; | } rasqal_variable; | |||
typedef enum { | typedef enum { | |||
RASQAL_LITERAL_UNKNOWN, | RASQAL_LITERAL_UNKNOWN, | |||
skipping to change at line 88 | skipping to change at line 95 | |||
RASQAL_LITERAL_BOOLEAN, | RASQAL_LITERAL_BOOLEAN, | |||
RASQAL_LITERAL_INTEGER, | RASQAL_LITERAL_INTEGER, | |||
RASQAL_LITERAL_FLOATING, | RASQAL_LITERAL_FLOATING, | |||
RASQAL_LITERAL_VARIABLE, | RASQAL_LITERAL_VARIABLE, | |||
RASQAL_LITERAL_LAST= RASQAL_LITERAL_VARIABLE | RASQAL_LITERAL_LAST= RASQAL_LITERAL_VARIABLE | |||
} rasqal_literal_type; | } rasqal_literal_type; | |||
struct rasqal_literal_s { | struct rasqal_literal_s { | |||
int usage; | int usage; | |||
rasqal_literal_type type; | rasqal_literal_type type; | |||
const unsigned char *string; /* UTF-8 string, pattern, qname, blank, floa | /* UTF-8 string, pattern, qname, blank, float types */ | |||
t types */ | const unsigned char *string; | |||
union { | union { | |||
int integer; /* integer and boolean types */ | /* integer and boolean types */ | |||
double floating; /* floating */ | int integer; | |||
raptor_uri* uri; /* uri */ | /* floating */ | |||
rasqal_variable* variable; /* variable */ | double floating; | |||
/* uri (can be temporarily NULL if a qname, see flags below) */ | ||||
raptor_uri* uri; | ||||
/* variable */ | ||||
rasqal_variable* variable; | ||||
} value; | } value; | |||
const char *language; /* for string */ | ||||
raptor_uri *datatype; /* for string */ | /* for string */ | |||
const unsigned char *flags; /* for pattern; used as datatype qname for | const char *language; | |||
string */ | raptor_uri *datatype; | |||
/* various flags for literal types: | ||||
* pattern regex flags | ||||
* string datatype of qname | ||||
* uri qname of URI not yet expanded (temporary) | ||||
*/ | ||||
const unsigned char *flags; | ||||
}; | }; | |||
typedef enum { | typedef enum { | |||
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, | |||
skipping to change at line 146 | skipping to change at line 166 | |||
rasqal_variable* variable; | rasqal_variable* variable; | |||
unsigned char *value; /* UTF-8 value */ | unsigned char *value; /* UTF-8 value */ | |||
}; | }; | |||
typedef struct rasqal_expression_s rasqal_expression; | typedef struct rasqal_expression_s rasqal_expression; | |||
/* three expressions */ | /* three expressions */ | |||
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_triple ; | } rasqal_triple ; | |||
/* RASQAL API */ | /* RASQAL API */ | |||
/* Public functions */ | /* Public functions */ | |||
RASQAL_API void rasqal_init(void); | RASQAL_API void rasqal_init(void); | |||
RASQAL_API void rasqal_finish(void); | RASQAL_API void rasqal_finish(void); | |||
RASQAL_API int rasqal_languages_enumerate(const unsigned int counter, const char **name, const char **label, const unsigned char **uri_string); | RASQAL_API int rasqal_languages_enumerate(const unsigned int counter, const char **name, const char **label, const unsigned char **uri_string); | |||
skipping to change at line 240 | skipping to change at line 261 | |||
RASQAL_API rasqal_literal* rasqal_new_uri_literal(raptor_uri* uri); | RASQAL_API rasqal_literal* rasqal_new_uri_literal(raptor_uri* uri); | |||
RASQAL_API rasqal_literal* rasqal_new_pattern_literal(const unsigned char * pattern, const char *flags); | RASQAL_API rasqal_literal* rasqal_new_pattern_literal(const unsigned char * pattern, const char *flags); | |||
RASQAL_API rasqal_literal* rasqal_new_string_literal(const unsigned char *s tring, const char *language, raptor_uri *datatype, const unsigned char *dat atype_qname); | RASQAL_API rasqal_literal* rasqal_new_string_literal(const unsigned char *s tring, const char *language, raptor_uri *datatype, const unsigned char *dat atype_qname); | |||
RASQAL_API rasqal_literal* rasqal_new_simple_literal(rasqal_literal_type ty pe, const unsigned char *string); | RASQAL_API rasqal_literal* rasqal_new_simple_literal(rasqal_literal_type ty pe, const unsigned char *string); | |||
RASQAL_API rasqal_literal* rasqal_new_boolean_literal(int value); | RASQAL_API rasqal_literal* rasqal_new_boolean_literal(int value); | |||
RASQAL_API rasqal_literal* rasqal_new_variable_literal(rasqal_variable *var iable); | RASQAL_API rasqal_literal* rasqal_new_variable_literal(rasqal_variable *var iable); | |||
RASQAL_API rasqal_literal* rasqal_new_literal_from_literal(rasqal_literal* literal); | RASQAL_API rasqal_literal* rasqal_new_literal_from_literal(rasqal_literal* literal); | |||
RASQAL_API void rasqal_free_literal(rasqal_literal* literal); | RASQAL_API void rasqal_free_literal(rasqal_literal* literal); | |||
RASQAL_API void rasqal_literal_print(rasqal_literal* literal, FILE* fh); | RASQAL_API void rasqal_literal_print(rasqal_literal* literal, FILE* fh); | |||
RASQAL_API void rasqal_literal_print_type(rasqal_literal* literal, FILE* fh ); | ||||
RASQAL_API rasqal_variable* rasqal_literal_as_variable(rasqal_literal* lite ral); | RASQAL_API rasqal_variable* rasqal_literal_as_variable(rasqal_literal* lite ral); | |||
RASQAL_API const unsigned char* rasqal_literal_as_string(rasqal_literal* li teral); | RASQAL_API const unsigned char* rasqal_literal_as_string(rasqal_literal* li teral); | |||
RASQAL_API rasqal_literal* rasqal_literal_as_node(rasqal_literal* literal); | RASQAL_API rasqal_literal* rasqal_literal_as_node(rasqal_literal* literal); | |||
#define RASQAL_COMPARE_NOCASE 1 | #define RASQAL_COMPARE_NOCASE 1 | |||
RASQAL_API int rasqal_literal_compare(rasqal_literal* l1, rasqal_literal* l 2, int flags, int *error); | RASQAL_API int rasqal_literal_compare(rasqal_literal* l1, rasqal_literal* l 2, int flags, 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 ptor_uri* uri); | RASQAL_API rasqal_prefix* rasqal_new_prefix(const unsigned char* prefix, ra ptor_uri* uri); | |||
RASQAL_API void rasqal_free_prefix(rasqal_prefix* prefix); | RASQAL_API void rasqal_free_prefix(rasqal_prefix* prefix); | |||
RASQAL_API void rasqal_prefix_print(rasqal_prefix* p, FILE* fh); | 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 _literal* predicate, rasqal_literal* object); | RASQAL_API rasqal_triple* rasqal_new_triple(rasqal_literal* subject, rasqal _literal* predicate, rasqal_literal* object); | |||
RASQAL_API void rasqal_free_triple(rasqal_triple* t); | RASQAL_API void rasqal_free_triple(rasqal_triple* t); | |||
RASQAL_API void rasqal_triple_print(rasqal_triple* t, FILE* fh); | 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(rasqal_query* query, const unsigned char *name, rasqal_literal *value); | RASQAL_API rasqal_variable* rasqal_new_variable(rasqal_query* query, const unsigned char *name, rasqal_literal *value); | |||
RASQAL_API void rasqal_free_variable(rasqal_variable* variable); | RASQAL_API void rasqal_free_variable(rasqal_variable* variable); | |||
RASQAL_API void rasqal_variable_print(rasqal_variable* t, FILE* fh); | RASQAL_API void rasqal_variable_print(rasqal_variable* t, FILE* fh); | |||
RASQAL_API void rasqal_variable_set_value(rasqal_variable* v, rasqal_litera l *l); | RASQAL_API void rasqal_variable_set_value(rasqal_variable* v, rasqal_litera l *l); | |||
/* rasqal_engine.c */ | /* rasqal_engine.c */ | |||
struct rasqal_triples_match_s { | struct rasqal_triples_match_s { | |||
void *user_data; | void *user_data; | |||
int (*bind_match)(struct rasqal_triples_match_s*, void *user_data, rasqal _variable *bindings[3]); | int (*bind_match)(struct rasqal_triples_match_s*, void *user_data, rasqal _variable *bindings[4]); | |||
void (*next_match)(struct rasqal_triples_match_s*, void *user_data); | void (*next_match)(struct rasqal_triples_match_s*, void *user_data); | |||
int (*is_end)(struct rasqal_triples_match_s*, void *user_data); | int (*is_end)(struct rasqal_triples_match_s*, void *user_data); | |||
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; | |||
typedef struct | typedef struct | |||
{ | { | |||
/* All the parts of this triple are nodes - no variables */ | /* All the parts of this triple are nodes - no variables */ | |||
int is_exact; | int is_exact; | |||
rasqal_variable* bindings[3]; | /* triple (subject, predicate, object) and origin (SOURCE in BRQL) */ | |||
rasqal_variable* bindings[4]; | ||||
rasqal_triples_match *triples_match; | rasqal_triples_match *triples_match; | |||
void *context; | void *context; | |||
} rasqal_triple_meta; | } rasqal_triple_meta; | |||
struct rasqal_triples_source_s { | struct rasqal_triples_source_s { | |||
/* A source for this query */ | /* A source for this query */ | |||
rasqal_query *query; | rasqal_query *query; | |||
skipping to change at line 308 | skipping to change at line 333 | |||
}; | }; | |||
typedef struct rasqal_triples_source_s rasqal_triples_source; | typedef struct rasqal_triples_source_s rasqal_triples_source; | |||
typedef struct { | typedef struct { | |||
void *user_data; /* user data for triples_source_factory */ | void *user_data; /* user data for triples_source_factory */ | |||
size_t user_data_size; /* size of user data for new_triples_source */ | size_t user_data_size; /* size of user data for new_triples_source */ | |||
int (*new_triples_source)(rasqal_query *query, void *factory_user_data, v oid *user_data, rasqal_triples_source* rts); | 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 */ | |||
void rasqal_set_triples_source_factory(void (*register_fn)(rasqal_triples_s ource_factory *factory), void* user_data); | RASQAL_API void rasqal_set_triples_source_factory(void (*register_fn)(rasqa l_triples_source_factory *factory), void* user_data); | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif | #endif | |||
End of changes. 14 change blocks. | ||||
25 lines changed or deleted | 49 lines changed or added | |||