# class Serializer

### abstract

Module | soprano
Namespace | Soprano
Class | Serializer
Inherits | Soprano::Plugin,Soprano::Error::ErrorCache

\class Serializer serializer.h Soprano/Serializer

Soprano.Serializer defines the interface for a Soprano RDF serializer plugin.

Each serializer plugin may support multiple RDF serializations (supportedSerializations()).

Usage

Using a Serializer is straightforward. One starts by getting a plugin that supports the requested RDF data serialization:

    Soprano.Serializer* s = Soprano.PluginManager.instance()->discoverSerializerForSerialization( Soprano.SerializationRdfXml );

Then serializing RDF data is done in a single method call which writes the serialized data to a QTextStream:

    QTextStream stream( stdout );
    s->serialize( model->listStatements(), stream, Soprano.SerializationRdfXml );

See also soprano_writing_plugins

Author Sebastian Trueg <trueg@kde.org>

### methods

- Serializer (name)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  name | QString |

- serialize (it, stream, serialization, userSerialization)

  returns bool
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  it | Soprano.StatementIterator |
  stream | QTextStream |
  serialization | Soprano.RdfSerialization |
  userSerialization | QString | QString()

  Serialize a list of statements.

  it - An iterator containing the statements to be serialized.

  stream - The stream the serialized data should be written to.

  serialization - The encoding to be used.

  userSerialization - If serialization is set to Soprano.SerializationUser this parameter specifies the serialization to use. It allows the extension of the %Soprano Serializer interface with new RDF serializations that are not officially supported by %Soprano.

  Returns true if the %serialization was successful, false otherwise.

- supportedSerializations ( )

  returns Soprano.RdfSerializations
  pure virtual

  The serialiazation types supported by this serializer. Returns A combination of Soprano.RdfSerialization types. If the list contains Soprano.SerializationUser the serializer supports additional RDF serialiazations not officially supported by %Soprano.

- supportedUserSerializations ( )

  returns QStringList

  A serializer can support additional RDF serializations that are not defined in Soprano.RdfSerialization. In that case supportedSerializations() has to include Soprano.SerializationUser.

  The default implementation returns an empty list.

  Returns A list of supported user RDF serializations.

- supportsSerialization (s, userSerialization)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  s | Soprano.RdfSerialization |
  userSerialization | QString | QString()

  Check if a plugin supports a specific serialization.

  s - The requested serialization.

  userSerialization - If serialization is set to Soprano.SerializationUser this parameter specifies the requested serialization. It allows the extension of the %Soprano Serializer interface with new RDF serializations that are not officially supported by %Soprano.

  Returns true if the serializer is able to parse RDF data encoded in serialization s, false otherwise.