Serializers 3 REDLAND Library
Serializers RDF serializers from triples to syntax.

## Synopsis

    typedef             librdf_serializer;
    typedef             librdf_serializer_factory;
    int                 librdf_serializer_enumerate         (librdf_world *world,
                                                             unsigned int counter,
                                                             const char **name,
                                                             const char **label);
    void                librdf_serializer_register_factory  (librdf_world *world,
                                                             const char *name,
                                                             const char *label,
                                                             const char *mime_type,
                                                             unsigned char *uri_string,
                                                             void (factorylibrdf_serializer_factory*) ());
    librdf_serializer*  librdf_new_serializer               (librdf_world *world,
                                                             const char *name,
                                                             const char *mime_type,
                                                             librdf_uri *type_uri);
    librdf_serializer*  librdf_new_serializer_from_factory  (librdf_world *world,
                                                             librdf_serializer_factory *factory);
    void                librdf_free_serializer              (librdf_serializer *serializer);
    int                 librdf_serializer_check_name        (librdf_world *world,
                                                             const char *name);
    int                 librdf_serializer_serialize_model   (librdf_serializer *serializer,
                                                             FILE *handle,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model);
    int                 librdf_serializer_serialize_model_to_file_handle
                                                            (librdf_serializer *serializer,
                                                             FILE *handle,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model);
    int                 librdf_serializer_serialize_model_to_file
                                                            (librdf_serializer *serializer,
                                                             const char *name,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model);
    unsigned char*      librdf_serializer_serialize_model_to_string
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model);
    unsigned char*      librdf_serializer_serialize_model_to_counted_string
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model,
                                                             size_t *length_p);
    int                 librdf_serializer_serialize_model_to_iostream
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model,
                                                             raptor_iostream *iostr);
    unsigned char*      librdf_serializer_serialize_stream_to_counted_string
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream,
                                                             size_t *length_p);
    int                 librdf_serializer_serialize_stream_to_file
                                                            (librdf_serializer *serializer,
                                                             const char *name,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream);
    int                 librdf_serializer_serialize_stream_to_file_handle
                                                            (librdf_serializer *serializer,
                                                             FILE *handle,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream);
    int                 librdf_serializer_serialize_stream_to_iostream
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream,
                                                             raptor_iostream *iostr);
    unsigned char*      librdf_serializer_serialize_stream_to_string
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream);
    void                librdf_serializer_set_error         (librdf_serializer *serializer,
                                                             void *user_data,
                                                             void (error_fnvoid *user_data, const char *msg, ...) ());
    void                librdf_serializer_set_warning       (librdf_serializer *serializer,
                                                             void *user_data,
                                                             void (warning_fnvoid *user_data, const char *msg, ...) ());
    librdf_node*        librdf_serializer_get_feature       (librdf_serializer *serializer,
                                                             librdf_uri *feature);
    int                 librdf_serializer_set_feature       (librdf_serializer *serializer,
                                                             librdf_uri *feature,
                                                             librdf_node *value);
    int                 librdf_serializer_set_namespace     (librdf_serializer *serializer,
                                                             librdf_uri *uri,
                                                             const char *prefix);

## Description

Provides class to create serializers to turn RDF graphs into syntax in either files or strings. Serializer features can be set, which are passed down to Raptor and errors and warnings that are returned can be retrieved by callbacks.

## Details

### librdf_serializer

    typedef struct librdf_serializer_s librdf_serializer;

Redland serializer class.

librdf_serializer

### librdf_serializer_factory

    typedef struct librdf_serializer_factory_s librdf_serializer_factory;

Redland serializer factory class.

librdf_serializer_factory

### librdf_serializer_enumerate ()

    int                 librdf_serializer_enumerate         (librdf_world *world,
                                                             unsigned int counter,
                                                             const char **name,
                                                             const char **label);

Get information on serializers.

world :

  redland world object

counter :

  index into the list of serializers

name :

  pointer to store the name of the serializer (or NULL)

label :

  pointer to store syntax readable label (or NULL)

Returns :

  non 0 on failure of if counter is out of range

librdf_serializer_enumerate

### librdf_serializer_register_factory ()

    void                librdf_serializer_register_factory  (librdf_world *world,
                                                             const char *name,
                                                             const char *label,
                                                             const char *mime_type,
                                                             unsigned char *uri_string,
                                                             void (factorylibrdf_serializer_factory*) ());

Register a serializer factory .

world :

  redland world object

name :

  the name of the serializer

label :

  the label of the serializer (optional)

mime_type :

  MIME type of the syntax (optional)

uri_string :

  URI of the syntax (optional)

factory :

  function to be called to register the factor parameters

librdf_serializer_register_factory

### librdf_new_serializer ()

    librdf_serializer*  librdf_new_serializer               (librdf_world *world,
                                                             const char *name,
                                                             const char *mime_type,
                                                             librdf_uri *type_uri);

Constructor - create a new librdf_serializer object.

world :

  redland world object

name :

  the serializer factory name

mime_type :

  the MIME type of the syntax (NULL if not used)

type_uri :

  URI of syntax (NULL if not used)

Returns :

  new librdf_serializer object or NULL

librdf_new_serializer

### librdf_new_serializer_from_factory ()

    librdf_serializer*  librdf_new_serializer_from_factory  (librdf_world *world,
                                                             librdf_serializer_factory *factory);

Constructor - create a new librdf_serializer object.

world :

  redland world object

factory :

  the serializer factory to use to create this serializer

Returns :

  new librdf_serializer object or NULL

librdf_new_serializer_from_factory

### librdf_free_serializer ()

    void                librdf_free_serializer              (librdf_serializer *serializer);

Destructor - destroys a librdf_serializer object.

serializer :

  the serializer

librdf_free_serializer

### librdf_serializer_check_name ()

    int                 librdf_serializer_check_name        (librdf_world *world,
                                                             const char *name);

Check if a serializer name is known

world :

  redland world object

name :

  name of serializer

Returns :

  non 0 if name is a known serializer

librdf_serializer_check_name

### librdf_serializer_serialize_model ()

    int                 librdf_serializer_serialize_model   (librdf_serializer *serializer,
                                                             FILE *handle,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model);

Deprecated: Use `librdf_serializer_serialize_model_to_file_handle()`

Write a serialized librdf_model to a FILE*.

serializer :

  the serializer

handle :

  file handle to serialize to

base_uri :

  the base URI to use (or NULL)

model :

  the librdf_model model to use

Returns :

  non 0 on failure

librdf_serializer_serialize_model

### librdf_serializer_serialize_model_to_file_handle ()

    int                 librdf_serializer_serialize_model_to_file_handle
                                                            (librdf_serializer *serializer,
                                                             FILE *handle,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model);

Write a serialized librdf_model to a FILE*.

serializer :

  the serializer

handle :

  file handle to serialize to

base_uri :

  the base URI to use (or NULL)

model :

  the librdf_model model to use

Returns :

  non 0 on failure

librdf_serializer_serialize_model_to_file_handle

### librdf_serializer_serialize_model_to_file ()

    int                 librdf_serializer_serialize_model_to_file
                                                            (librdf_serializer *serializer,
                                                             const char *name,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model);

Write a serialized librdf_model to a file.

serializer :

  the serializer

name :

  filename to serialize to

base_uri :

  the base URI to use (or NULL)

model :

  the librdf_model model to use

Returns :

  non 0 on failure

librdf_serializer_serialize_model_to_file

### librdf_serializer_serialize_model_to_string ()

    unsigned char*      librdf_serializer_serialize_model_to_string
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model);

Write a serialized librdf_model to a string.

serializer :

  the serializer

base_uri :

  the base URI to use (or NULL)

model :

  the librdf_model model to use

Returns :

  NULL on failure

librdf_serializer_serialize_model_to_string

### librdf_serializer_serialize_model_to_counted_string ()

    unsigned char*      librdf_serializer_serialize_model_to_counted_string
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model,
                                                             size_t *length_p);

Write a serialized librdf_model to a counted string.

serializer :

  the serializer

base_uri :

  the base URI to use (or NULL)

model :

  the librdf_model model to use

length_p :

  pointer to store length or NULL

Returns :

  non 0 on failure

librdf_serializer_serialize_model_to_counted_string

### librdf_serializer_serialize_model_to_iostream ()

    int                 librdf_serializer_serialize_model_to_iostream
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_model *model,
                                                             raptor_iostream *iostr);

Write a serialized librdf_model to a raptor_iostream.

serializer :

  the serializer

base_uri :

  the base URI to use (or NULL)

model :

  the librdf_model model to use

iostr :

  the raptor_iostream to write to

Returns :

  non-0 on failure

librdf_serializer_serialize_model_to_iostream

### librdf_serializer_serialize_stream_to_counted_string ()

    unsigned char*      librdf_serializer_serialize_stream_to_counted_string
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream,
                                                             size_t *length_p);

Write a librdf_stream to a counted string.

serializer :

  the serializer

base_uri :

  the base URI to use (or NULL)

stream :

  the librdf_stream stream to use

length_p :

  pointer to store length or NULL

Returns :

  stream as string or NULL on failure

librdf_serializer_serialize_stream_to_counted_string

### librdf_serializer_serialize_stream_to_file ()

    int                 librdf_serializer_serialize_stream_to_file
                                                            (librdf_serializer *serializer,
                                                             const char *name,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream);

Write a librdf_stream to a file.

serializer :

  the serializer

name :

  filename to serialize to

base_uri :

  the base URI to use (or NULL)

stream :

  the librdf_stream stream to use

Returns :

  non 0 on failure

librdf_serializer_serialize_stream_to_file

### librdf_serializer_serialize_stream_to_file_handle ()

    int                 librdf_serializer_serialize_stream_to_file_handle
                                                            (librdf_serializer *serializer,
                                                             FILE *handle,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream);

Write a librdf_stream to a FILE*.

serializer :

  the serializer

handle :

  file handle to serialize to

base_uri :

  the base URI to use (or NULL)

stream :

  the librdf_stream model to use

Returns :

  non 0 on failure

librdf_serializer_serialize_stream_to_file_handle

### librdf_serializer_serialize_stream_to_iostream ()

    int                 librdf_serializer_serialize_stream_to_iostream
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream,
                                                             raptor_iostream *iostr);

Write a librdf_stream to a raptor_iostream.

serializer :

  the serializer

base_uri :

  the base URI to use (or NULL)

stream :

  the librdf_stream stream to use

iostr :

  the raptor_iostream to write to

Returns :

  non-0 on failure

librdf_serializer_serialize_stream_to_iostream

### librdf_serializer_serialize_stream_to_string ()

    unsigned char*      librdf_serializer_serialize_stream_to_string
                                                            (librdf_serializer *serializer,
                                                             librdf_uri *base_uri,
                                                             librdf_stream *stream);

Write a librdf_stream to a string.

serializer :

  the serializer

base_uri :

  the base URI to use (or NULL)

stream :

  the librdf_stream stream to use

Returns :

  NULL on failure

librdf_serializer_serialize_stream_to_string

### librdf_serializer_set_error ()

    void                librdf_serializer_set_error         (librdf_serializer *serializer,
                                                             void *user_data,
                                                             void (error_fnvoid *user_data, const char *msg, ...) ());

Deprecated: Does nothing

Set the serializer error handling function.

serializer :

  the serializer

user_data :

  user data to pass to function

error_fn :

  pointer to the function

librdf_serializer_set_error

### librdf_serializer_set_warning ()

    void                librdf_serializer_set_warning       (librdf_serializer *serializer,
                                                             void *user_data,
                                                             void (warning_fnvoid *user_data, const char *msg, ...) ());

Deprecated: Does nothing

Set the serializer warning handling function.

serializer :

  the serializer

user_data :

  user data to pass to function

warning_fn :

  pointer to the function

librdf_serializer_set_warning

### librdf_serializer_get_feature ()

    librdf_node*        librdf_serializer_get_feature       (librdf_serializer *serializer,
                                                             librdf_uri *feature);

Get the value of a serializer feature.

serializer :

  serializer object

feature :

  URI of feature

Returns :

  the value of the feature or NULL if no such feature exists or the value is empty.

librdf_serializer_get_feature

### librdf_serializer_set_feature ()

    int                 librdf_serializer_set_feature       (librdf_serializer *serializer,
                                                             librdf_uri *feature,
                                                             librdf_node *value);

Set the value of a serializer feature.

serializer :

  serializer object

feature :

  URI of feature

value :

  value to set

Returns :

  non 0 on failure (negative if no such feature)

librdf_serializer_set_feature

### librdf_serializer_set_namespace ()

    int                 librdf_serializer_set_namespace     (librdf_serializer *serializer,
                                                             librdf_uri *uri,
                                                             const char *prefix);

Set a namespace URI/prefix mapping.

serializer :

  serializer object

uri :

  URI of namespace or NULL

prefix :

  prefix to use or NULL

Returns :

  non 0 on failure

librdf_serializer_set_namespace