Top |
raptor_parser * | raptor_new_parser () |
raptor_parser * | raptor_new_parser_for_content () |
void | raptor_free_parser () |
void | (*raptor_graph_mark_handler) () |
void | (*raptor_namespace_handler) () |
void | raptor_parser_set_statement_handler () |
void | raptor_parser_set_graph_mark_handler () |
void | raptor_parser_set_namespace_handler () |
const raptor_syntax_description * | raptor_parser_get_description () |
raptor_locator * | raptor_parser_get_locator () |
void | raptor_parser_parse_abort () |
int | raptor_parser_parse_chunk () |
int | raptor_parser_parse_file () |
int | raptor_parser_parse_file_stream () |
int | raptor_parser_parse_iostream () |
int | raptor_parser_parse_start () |
int | raptor_parser_parse_uri () |
int | raptor_parser_parse_uri_with_connection () |
raptor_uri * | raptor_parser_get_graph () |
const char * | raptor_parser_get_name () |
int | raptor_parser_set_option () |
int | raptor_parser_get_option () |
const char * | raptor_parser_get_accept_header () |
void | raptor_parser_set_uri_filter () |
raptor_world * | raptor_parser_get_world () |
raptor_parser * raptor_new_parser (raptor_world *world
,const char *name
);
Constructor - create a new raptor_parser object.
raptor_parser * raptor_new_parser_for_content (raptor_world *world
,raptor_uri *uri
,const char *mime_type
,const char *buffer
,size_t len
,const unsigned char *identifier
);
Constructor - create a new raptor_parser.
Uses raptor_world_guess_parser_name()
to find a parser by scoring
recognition of the syntax by a block of characters, the content
identifier or a mime type. The content identifier is typically a
filename or URI or some other identifier.
void
raptor_free_parser (raptor_parser *parser
);
Destructor - destroy a raptor_parser object.
void (*raptor_graph_mark_handler) (void *user_data
,raptor_uri *graph
,int flags
);
Graph start/end mark handler function.
Records start and end of graphs happening in a stream of generated
raptor_statement via the statement handler. The callback starts a
graph when flags
has RAPTOR_GRAPH_MARK_START bit set.
The start and ends may be either declared in the syntax via some
keyword or mechanism such as TRiG {} syntax when flags
has bit
RAPTOR_GRAPH_MARK_DECLARED set, or be implied by the start/end of
the data in other syntaxes, and the bit will be unset.
user_data |
user data |
|
graph |
graph to report, NULL for the default graph |
|
flags |
bitmask of raptor_graph_mark_flags flags |
void (*raptor_namespace_handler) (void *user_data
,raptor_namespace *nspace
);
XML Namespace declaration reporting handler set by
raptor_parser_set_namespace_handler()
.
void raptor_parser_set_statement_handler (raptor_parser *parser
,void *user_data
,raptor_statement_handler handler
);
Set the statement handler function for the parser.
Use this to set the function to receive statements as the parsing
proceeds. The statement argument to handler
is shared and must be
copied by the caller with raptor_statement_copy()
.
parser |
raptor_parser parser object |
|
user_data |
user data pointer for callback |
|
handler |
new statement callback function |
void raptor_parser_set_graph_mark_handler (raptor_parser *parser
,void *user_data
,raptor_graph_mark_handler handler
);
Set the graph mark handler function for the parser.
See raptor_graph_mark_handler and raptor_graph_mark_flags for the marks that may be returned by the handler.
parser |
raptor_parser parser object |
|
user_data |
user data pointer for callback |
|
handler |
new graph callback function |
void raptor_parser_set_namespace_handler (raptor_parser *parser
,void *user_data
,raptor_namespace_handler handler
);
Set the namespace handler function for the parser.
When a prefix/namespace is seen in a parser, call the given
handler
with the prefix string and the raptor_uri namespace URI.
Either can be NULL for the default prefix or default namespace.
The handler function does not deal with duplicates so any namespace may be declared multiple times.
parser |
raptor_parser parser object |
|
user_data |
user data pointer for callback |
|
handler |
new namespace callback function |
const raptor_syntax_description *
raptor_parser_get_description (raptor_parser *rdf_parser
);
Get description of the syntaxes of the parser.
The returned description is static and lives as long as the raptor library (raptor world).
raptor_locator *
raptor_parser_get_locator (raptor_parser *rdf_parser
);
Get the current raptor locator object.
void
raptor_parser_parse_abort (raptor_parser *rdf_parser
);
Abort an ongoing parsing.
Causes any ongoing generation of statements by a parser to be terminated and the parser to return controlto the application as soon as draining any existing buffers.
Most useful inside raptor_parser_parse_file()
or
raptor_parser_parse_uri()
when the Raptor library is directing the
parsing and when one of the callback handlers such as as set by
raptor_parser_set_statement_handler()
requires to return to the main
application code.
int raptor_parser_parse_chunk (raptor_parser *rdf_parser
,const char *buffer
,size_t len
,int is_end
);
Parse a block of content into triples.
This method can only be called after raptor_parser_parse_start()
has
initialised the parser.
int raptor_parser_parse_file (raptor_parser *rdf_parser
,raptor_uri *uri
,raptor_uri *base_uri
);
Parse RDF content at a file URI.
If uri
is NULL (source is stdin), then the base_uri
is required.
int raptor_parser_parse_file_stream (raptor_parser *rdf_parser
,FILE *stream
,const char *filename
,raptor_uri *base_uri
);
Parse RDF content from a FILE*.
After draining the FILE* stream (EOF), fclose is not called on it.
int raptor_parser_parse_iostream (raptor_parser *rdf_parser
,raptor_iostream *iostr
,raptor_uri *base_uri
);
Parse content from an iostream
If the parser requires a base URI and base_uri
is NULL, an error
will be generated and the function will fail.
int raptor_parser_parse_start (raptor_parser *rdf_parser
,raptor_uri *uri
);
Start a parse of content with base URI.
Parsers that need a base URI can be identified using a syntax
description returned by raptor_world_get_parser_description()
statically or raptor_parser_get_description()
on a constructed
parser.
int raptor_parser_parse_uri (raptor_parser *rdf_parser
,raptor_uri *uri
,raptor_uri *base_uri
);
Parse the RDF content at URI.
Sends an HTTP Accept: header whent the URI is of the HTTP protocol,
see raptor_parser_parse_uri_with_connection()
for details including
how the base_uri
is used.
int raptor_parser_parse_uri_with_connection (raptor_parser *rdf_parser
,raptor_uri *uri
,raptor_uri *base_uri
,void *connection
);
Parse RDF content at URI using existing WWW connection.
If base_uri
is not given and during resolution of the URI, a
protocol redirection occurs, the final resolved URI will be
used as the base URI. If redirection does not occur, the
base URI will be uri
.
If base_uri
is given, it overrides the process above.
When connection
is NULL and a MIME Type exists for the parser
type, this type is sent in an HTTP Accept: header in the form
Accept: MIME-TYPE along with a wildcard of 0.1 quality, so MIME-TYPE is
prefered rather than the sole answer. The latter part may not be
necessary but should ensure an HTTP 200 response.
raptor_uri *
raptor_parser_get_graph (raptor_parser *rdf_parser
);
Get the current graph for the parser
The returned URI is owned by the caller and must be freed with
raptor_free_uri()
const char *
raptor_parser_get_name (raptor_parser *rdf_parser
);
Get the name of a parser.
Use raptor_parser_get_description()
to get the alternate names and
aliases as well as other descriptive values.
int raptor_parser_set_option (raptor_parser *parser
,raptor_option option
,const char *string
,int integer
);
Set parser option.
If string
is not NULL and the option type is numeric, the string
value is converted to an integer and used in preference to integer
.
If string
is NULL and the option type is not numeric, an error is
returned.
The string
values used are copied.
The allowed options are available via
raptor_world_get_option_description()
.
parser |
raptor_parser parser object |
|
option |
option to set from enumerated raptor_option values |
|
string |
string option value (or NULL) |
|
integer |
integer option value |
int raptor_parser_get_option (raptor_parser *parser
,raptor_option option
,char **string_p
,int *integer_p
);
Get parser option.
Any string value returned in *string_p
is shared and must
be copied by the caller.
The allowed options are available via
raptor_world_get_option_description()
.
parser |
raptor_parser parser object |
|
option |
option to get value |
|
string_p |
pointer to where to store string value |
|
integer_p |
pointer to where to store integer value |
const char *
raptor_parser_get_accept_header (raptor_parser *rdf_parser
);
Get an HTTP Accept value for the parser.
The returned string must be freed by the caller such as with
raptor_free_memory()
.
void raptor_parser_set_uri_filter (raptor_parser *parser
,raptor_uri_filter_func filter
,void *user_data
);
Set URI filter function for WWW retrieval.
raptor_world *
raptor_parser_get_world (raptor_parser *rdf_parser
);
Get the raptor_world object associated with a parser.