![]() |
![]() |
![]() |
Raptor RDF Syntax Parsing and Serializing Library Manual | ![]() |
---|---|---|---|---|
extern const unsigned int raptor_version_major; extern const unsigned int raptor_version_minor; extern const unsigned int raptor_version_release; extern const unsigned int raptor_version_decimal; void raptor_init (void); void raptor_finish (void); void (*raptor_simple_message_handler) (void *user_data, const char *message, ...); void (*raptor_message_handler) (void *user_data, raptor_locator *locator, const char *message); void (*raptor_statement_handler) (void *user_data, const raptor_statement *statement); int raptor_parsers_enumerate (unsigned int counter, const char **name, const char **label); int raptor_syntaxes_enumerate (unsigned int counter, const char **name, const char **label, const char **mime_type, unsigned char **uri_string); int raptor_syntax_name_check (const char *name); const char* raptor_guess_parser_name (raptor_uri *uri, const char *mime_type, unsigned char *buffer, size_t len, unsigned char *identifier); int raptor_serializers_enumerate (unsigned int counter, const char **name, const char **label, const char **mime_type, unsigned char **uri_string); int raptor_serializer_syntax_name_check (const char *name); int raptor_print_ntriples_string (FILE *stream, unsigned char *string, const char delim); unsigned char* raptor_ntriples_string_as_utf8_string (raptor_parser *rdf_parser, unsigned char *src, int len, size_t *dest_lenp); const char* raptor_ntriples_term_as_string (raptor_ntriples_term_type term); char* raptor_vsnprintf (const char *message); enum raptor_log_level; raptor_message_handler_closure; raptor_error_handlers; void raptor_error_handlers_init (raptor_error_handlers *error_handlers);
How to initialise and terminate the library, get access to version numbers, set message and error handlers, list the parsed and serialized syntaxes provided in the library and various other utility functions.
extern const unsigned int raptor_version_major;
Library major version number as a decimal integer.
extern const unsigned int raptor_version_minor;
Library minor version number as a decimal integer.
extern const unsigned int raptor_version_release;
Library release version number as a decimal integer.
extern const unsigned int raptor_version_decimal;
Library full version as a decimal integer.
See also raptor_version_string.
void raptor_init (void);
Initialise the raptor library.
This function MUST be called before using any of the raptor APIs.
void raptor_finish (void);
Terminate the raptor library.
Cleans up state of the library. If called, must be used after all other objects are destroyed with their destructor.
void (*raptor_simple_message_handler) (void *user_data, const char *message, ...);
Simple message handler function.
Used by multiple functions including raptor_xml_escape_string()
,
raptor_iostream_write_xml_escaped_string()
, raptor_new_qname()
,
raptor_qname_string_to_uri()
, raptor_new_namespaces()
,
raptor_namespaces_init()
, raptor_iostream_write_xml_element()
,
raptor_new_xml_writer()
.
|
user data |
|
message to report |
|
arguments for message |
void (*raptor_message_handler) (void *user_data, raptor_locator *locator, const char *message);
Message with location handler function.
Used during parsing and serializing for errors and warnings that
may include location information. Multiple handlers may be set for
parsers and serializers by raptor_set_fatal_error_handler()
,
raptor_set_error_handler()
, raptor_set_warning_handler()
,
raptor_serializer_set_error_handler()
and
raptor_serializer_set_warning_handler()
.
Also used by raptor_www_set_error_handler()
for location-based errors
in WWW retrieval.
|
user data |
|
location associated with message or NULL |
|
message to report |
void (*raptor_statement_handler) (void *user_data, const raptor_statement *statement);
Statement (triple) reporting handler function.
|
user data |
|
statement to report |
int raptor_parsers_enumerate (unsigned int counter, const char **name, const char **label);
Get list of syntax parsers.
|
index to list of parsers |
|
pointer to store syntax name (or NULL) |
|
pointer to store syntax label (or NULL) |
Returns : |
non 0 on failure of if counter is out of range |
int raptor_syntaxes_enumerate (unsigned int counter, const char **name, const char **label, const char **mime_type, unsigned char **uri_string);
Get information on syntaxes.
|
index into the list of syntaxes |
|
pointer to store the name of the syntax (or NULL) |
|
pointer to store syntax readable label (or NULL) |
|
pointer to store syntax MIME Type (or NULL) |
|
pointer to store syntax URI string (or NULL) |
Returns : |
non 0 on failure of if counter is out of range |
int raptor_syntax_name_check (const char *name);
Check name of a parser.
|
the syntax name |
Returns : |
non 0 if name is a known syntax name |
const char* raptor_guess_parser_name (raptor_uri *uri, const char *mime_type, unsigned char *buffer, size_t len, unsigned char *identifier);
Guess a parser name for content.
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.
|
URI identifying the syntax (or NULL) |
|
mime type identifying the content (or NULL) |
|
buffer of content to guess (or NULL) |
|
length of buffer |
|
identifier of content (or NULL) |
Returns : |
a parser name or NULL if no guess could be made |
int raptor_serializers_enumerate (unsigned int counter, const char **name, const char **label, const char **mime_type, unsigned char **uri_string);
Get information on syntax serializers.
|
index into the list of syntaxes |
|
pointer to store the name of the syntax (or NULL) |
|
pointer to store syntax readable label (or NULL) |
|
pointer to store syntax MIME Type (or NULL) |
|
pointer to store syntax URI string (or NULL) |
Returns : |
non 0 on failure of if counter is out of range |
int raptor_serializer_syntax_name_check (const char *name);
Check name of a serializer.
|
the syntax name |
Returns : |
non 0 if name is a known syntax name |
int raptor_print_ntriples_string (FILE *stream, unsigned char *string, const char delim);
Print an UTF-8 string using N-Triples escapes.
|
FILE* stream to print to |
|
UTF-8 string to print |
|
Delimiter character for string (such as ") or \0 for no delim escaping. |
Returns : |
non-0 on failure such as bad UTF-8 encoding. |
unsigned char* raptor_ntriples_string_as_utf8_string (raptor_parser *rdf_parser, unsigned char *src, int len, size_t *dest_lenp);
Turn an N-Triples string with escapes into a UTF-8 string.
Deprecated
: This requires use of parser internals and was never in the public API header.
|
parser object |
|
data to read from |
|
size of data |
|
pointer to length of destination (out) or NULL |
Returns : |
a new UTF-8 string |
const char* raptor_ntriples_term_as_string (raptor_ntriples_term_type term);
Deprecated
: an internal debug function, do not use.
Get a label for a raptor_ntriples_term_type.
|
N-Triples term. |
Returns : |
a pointer to a constant string. |
char* raptor_vsnprintf (const char *message);
Format output for a variable arguments list.
This is a wrapper around system versions of vsnprintf with different call and return conventions.
|
printf-style format string |
Returns : |
a newly allocated string as the format result or NULL on failure |
typedef enum { RAPTOR_LOG_LEVEL_NONE, RAPTOR_LOG_LEVEL_FATAL, RAPTOR_LOG_LEVEL_ERROR, RAPTOR_LOG_LEVEL_WARNING, RAPTOR_LOG_LEVEL_LAST=RAPTOR_LOG_LEVEL_WARNING } raptor_log_level;
Log levels
typedef struct { void *user_data; raptor_message_handler handler; } raptor_message_handler_closure;
The combination of a message handler and the user data to send to it.
void * |
user data for handler invocation |
raptor_message_handler |
handler function |
typedef struct { unsigned int magic; raptor_locator* locator; /* size of handlers array */ raptor_log_level last_log_level; raptor_message_handler_closure handlers[RAPTOR_LOG_LEVEL_LAST+1]; } raptor_error_handlers;
Error handlers structure
unsigned int |
magic value - must use raptor_error_handlers_init() to set this
|
raptor_locator * |
raptor locator of the error |
raptor_log_level |
number of log levels; size of handlers arrays
|
raptor_message_handler_closure |
user handlers per log level |
void raptor_error_handlers_init (raptor_error_handlers *error_handlers);
Initialize raptor_error_handlers object statically.
|
error handlers object |