Raptor RDF Syntax Parsing and Serializing Library Manual |
---|
Raptor can be configured and compiled with support for different
parsers and serializers. Lists of the functionality built into the
library can be interrogated by means of
enumerate functions. These take as input an
int
counter and return descriptions of the feature
at that offset in the list. The descriptions are returned stored in
the variables pointed to by the reference arguments of the
**
var form.
The return value of the function is non-zero when the counter has
gone too far.
Listing Functionality with Enumeration
List the parse syntaxes (parser names) |
int raptor_parsers_enumerate(const unsigned int counter, const char **name, const char **label); |
List the parse syntaxes (same as above but with more information) |
int raptor_syntaxes_enumerate(const unsigned int counter, const char **name, const char **label, const char **mime_type, const unsigned char **uri_string); |
List the serializer syntaxes (serializer names) |
int raptor_serializers_enumerate(const unsigned int counter, const char **name, const char **label, const char **mime_type, const unsigned char **uri_string); |
List the Parser features |
int raptor_features_enumerate(const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); |
List the Serializer features |
int raptor_serializer_features_enumerate(const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); |
List the XML Writer features |
int raptor_xml_writer_features_enumerate(const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); |
These functions can be called directly after
raptor_init()
has been called so can be used to find name parameters for creating
parser and serializer instances. This is one way to find a parser
(name) by it's MIME Type, the other is to use the mime_type parameter
of the
raptor_new_parser_for_content()
.
Example 1. List all features of parsers with an enumerate function
int i; for(i=0; i < RAPTOR_FEATURE_LAST; i++) { const char *name; raptor_uri *uri; const char *label; if(raptor_features_enumerate((raptor_feature)i, &name, &uri, &label)) continue; /* do something with name, uri and label */ }
There are more examples of this usage in the source for the
rapper
utility in util/rapper.c
.