![]() |
![]() |
![]() |
Raptor RDF Syntax Parsing and Serializing Library Manual | ![]() |
---|---|---|---|---|
typedef raptor_serializer; raptor_serializer* raptor_new_serializer (const char *name); void raptor_free_serializer (raptor_serializer *rdf_serializer); int raptor_serialize_start (raptor_serializer *rdf_serializer, raptor_uri *uri, raptor_iostream *iostream); int raptor_serialize_start_to_filename (raptor_serializer *rdf_serializer, const char *filename); int raptor_serialize_start_to_string (raptor_serializer *rdf_serializer, raptor_uri *uri, void **string_p, size_t *length_p); int raptor_serialize_start_to_file_handle (raptor_serializer *rdf_serializer, raptor_uri *uri, FILE *fh); int raptor_serialize_set_namespace (raptor_serializer *rdf_serializer, raptor_uri *uri, unsigned char *prefix); int raptor_serialize_set_namespace_from_namespace (raptor_serializer *rdf_serializer, raptor_namespace *nspace); int raptor_serialize_statement (raptor_serializer *rdf_serializer, const raptor_statement *statement); int raptor_serialize_end (raptor_serializer *rdf_serializer); raptor_iostream* raptor_serializer_get_iostream (raptor_serializer *serializer); void raptor_serializer_set_error_handler (raptor_serializer *serializer, void *user_data, raptor_message_handler handler); void raptor_serializer_set_warning_handler (raptor_serializer *serializer, void *user_data, raptor_message_handler handler); raptor_locator* raptor_serializer_get_locator (raptor_serializer *rdf_serializer); int raptor_serializer_features_enumerate (const raptor_feature feature, const char **name, raptor_uri **uri, const char **label); int raptor_serializer_set_feature (raptor_serializer *serializer, raptor_feature feature, int value); int raptor_serializer_set_feature_string (raptor_serializer *serializer, raptor_feature feature, unsigned char *value); int raptor_serializer_get_feature (raptor_serializer *serializer, raptor_feature feature); const unsigned char* raptor_serializer_get_feature_string (raptor_serializer *serializer, raptor_feature feature);
The serializing class that allows creating a serializer for writing a particular syntax to an output string, file, file handle or user function (via raptor_iostream).
There are also methods to deal with handling errors, warnings and returned triples as well as setting options (features) that can adjust how serializing is performed.
raptor_serializer* raptor_new_serializer (const char *name);
Constructor - create a new raptor_serializer object
|
the serializer name |
Returns : |
a new raptor_serializer object or NULL on failure |
void raptor_free_serializer (raptor_serializer *rdf_serializer);
Destructor - destroy a raptor_serializer object.
|
raptor_serializer object |
int raptor_serialize_start (raptor_serializer *rdf_serializer, raptor_uri *uri, raptor_iostream *iostream);
Start serialization with given base URI
|
the raptor_serializer |
|
base URI or NULL if no base URI is required |
|
raptor_iostream to write serialization to |
Returns : |
non-0 on failure. |
int raptor_serialize_start_to_filename (raptor_serializer *rdf_serializer, const char *filename);
Start serializing to a filename.
|
the raptor_serializer |
|
filename to serialize to |
Returns : |
non-0 on failure. |
int raptor_serialize_start_to_string (raptor_serializer *rdf_serializer, raptor_uri *uri, void **string_p, size_t *length_p);
Start serializing to a string.
|
the raptor_serializer |
|
base URI or NULL if no base URI is required |
|
pointer to location to hold string |
|
pointer to location to hold length of string (or NULL) |
Returns : |
non-0 on failure. |
int raptor_serialize_start_to_file_handle (raptor_serializer *rdf_serializer, raptor_uri *uri, FILE *fh);
Start serializing to a FILE*.
NOTE: This does not fclose the handle when it is finished.
|
the raptor_serializer |
|
base URI or NULL if no base URI is required |
|
FILE* to serialize to |
Returns : |
non-0 on failure. |
int raptor_serialize_set_namespace (raptor_serializer *rdf_serializer, raptor_uri *uri, unsigned char *prefix);
set a namespace uri/prefix mapping for serializing.
|
the raptor_serializer |
|
raptor_uri of namespace or NULL |
|
prefix to use or NULL |
Returns : |
non-0 on failure. |
int raptor_serialize_set_namespace_from_namespace (raptor_serializer *rdf_serializer, raptor_namespace *nspace);
Set a namespace uri/prefix mapping for serializing from an existing namespace.
|
the raptor_serializer |
|
raptor_namespace to set |
Returns : |
non-0 on failure. |
int raptor_serialize_statement (raptor_serializer *rdf_serializer, const raptor_statement *statement);
Serialize a statement.
|
the raptor_serializer |
|
raptor_statement to serialize to a syntax |
Returns : |
non-0 on failure. |
int raptor_serialize_end (raptor_serializer *rdf_serializer);
End a serialization.
|
the raptor_serializer |
Returns : |
non-0 on failure. |
raptor_iostream* raptor_serializer_get_iostream (raptor_serializer *serializer);
Get the current serializer iostream.
|
raptor_serializer object |
Returns : |
the serializer's current iostream or NULL if |
void raptor_serializer_set_error_handler (raptor_serializer *serializer, void *user_data, raptor_message_handler handler);
Set the serializer error handling function.
The function will receive callbacks when the serializer fails.
|
the serializer |
|
user data to pass to function |
|
pointer to the function |
void raptor_serializer_set_warning_handler (raptor_serializer *serializer, void *user_data, raptor_message_handler handler);
Set the serializer warning handling function.
The function will receive callbacks when the serializer fails.
|
the serializer |
|
user data to pass to function |
|
pointer to the function |
raptor_locator* raptor_serializer_get_locator (raptor_serializer *rdf_serializer);
Get the serializer raptor locator object.
|
raptor serializer |
Returns : |
raptor locator |
int raptor_serializer_features_enumerate (const raptor_feature feature, const char **name, raptor_uri **uri, const char **label);
Get list of serializer features.
If uri is not NULL, a pointer toa new raptor_uri is returned
that must be freed by the caller with raptor_free_uri()
.
|
feature enumeration (0+) |
|
pointer to store feature short name (or NULL) |
|
pointer to store feature URI (or NULL) |
|
pointer to feature label (or NULL) |
Returns : |
0 on success, <0 on failure, >0 if feature is unknown |
int raptor_serializer_set_feature (raptor_serializer *serializer, raptor_feature feature, int value);
Set serializer features with integer values.
The allowed features are available via raptor_features_enumerate()
.
|
raptor_serializer serializer object |
|
feature to set from enumerated raptor_feature values |
|
integer feature value (0 or larger) |
Returns : |
non 0 on failure or if the feature is unknown |
int raptor_serializer_set_feature_string (raptor_serializer *serializer, raptor_feature feature, unsigned char *value);
Set serializer features with string values.
The allowed features are available via raptor_serializer_features_enumerate()
.
If the feature type is integer, the value is interpreted as an integer.
|
raptor_serializer serializer object |
|
feature to set from enumerated raptor_feature values |
|
feature value |
Returns : |
non 0 on failure or if the feature is unknown |
int raptor_serializer_get_feature (raptor_serializer *serializer, raptor_feature feature);
Get various serializer features.
The allowed features are available via raptor_features_enumerate()
.
Note: no feature value is negative
|
raptor_serializer serializer object |
|
feature to get value |
Returns : |
feature value or < 0 for an illegal feature |
const unsigned char* raptor_serializer_get_feature_string (raptor_serializer *serializer, raptor_feature feature);
Get serializer features with string values.
The allowed features are available via raptor_features_enumerate()
.
|
raptor_serializer serializer object |
|
feature to get value |
Returns : |
feature value or NULL for an illegal feature or no value |