Provide a destination for the serialized syntax

The operation of turning RDF triples into a syntax has several alternatives from functions that do most of the work writing to a file or string to functions that allow passing in a raptor_iostream which can be entirely user-constructed.

Serialize to a filename (raptor_serialize_start_to_filename())

Serialize to a new filename (using raptor_new_iostream_to_filename() internally) and uses asf base URI, the file's URI.

  const char *filename="raptor.rdf";
  raptor_serialize_start_to_filename(rdf_serializer, filename);

Serialize to a string (raptor_serialize_start_to_string())

Serialize to a string that is allocated by the serializer (using raptor_new_iostream_to_string() internally). The resulting string is only constructed after raptor_serialize_end() is called and at that point it is assigned to the string pointer passed in, with the length written to the optional length pointer. This function takes an optional base URI but may be required by some serializers.

  raptor_uri* uri=raptor_new_uri("http://example.org/base");
  void *string;  /* destination for string */
  size_t length; /* length of constructed string */

  raptor_serialize_start_to_string(rdf_serializer, uri,
                                   &string, &length);

Serialize to a FILE* file handle (raptor_serialize_start_to_file_handle())

Serialize to an existing open C FILE* file handle (using raptor_new_iostream_to_file_handle() internally). The handle is not closed after serializing is finished. This function takes an optional base URI but may be required by some serializers.

  raptor_uri* uri=raptor_new_uri("http://example.org/base");
  FILE* fh=fopen("raptor.rdf", "wb");
  raptor_serialize_start_to_file_handle(rdf_serializer, uri, fh);

This is the most flexible serializing method as it allows writing to any raptor_iostream which can be constructed to build any form of user-generated structure via callbacks.

  raptor_uri* uri=raptor_new_uri("http://example.org/base");
  raptor_iostream* iostream;

  /* iostream initialized by some means */

  raptor_serialize_start(rdf_serializer, uri, iostream);