Soprano 2.9.4
Soprano::Parser Class Referenceabstract

Soprano::Parser defines the interface for a Soprano RDF parser plugin. More...

#include <Soprano/Parser>

+ Inheritance diagram for Soprano::Parser:

Public Member Functions

virtual ~Parser ()
 
virtual RdfSerializations supportedSerializations () const =0
 
virtual QStringList supportedUserSerializations () const
 
bool supportsSerialization (RdfSerialization s, const QString &userSerialization=QString()) const
 
virtual StatementIterator parseFile (const QString &filename, const QUrl &baseUri, RdfSerialization serialization, const QString &userSerialization=QString()) const
 
virtual StatementIterator parseString (const QString &data, const QUrl &baseUri, RdfSerialization serialization, const QString &userSerialization=QString()) const
 
virtual StatementIterator parseStream (QTextStream &stream, const QUrl &baseUri, RdfSerialization serialization, const QString &userSerialization=QString()) const =0
 
- Public Member Functions inherited from Soprano::Plugin
virtual ~Plugin ()
 
QString pluginName () const
 
virtual bool isAvailable () const
 
- Public Member Functions inherited from Soprano::Error::ErrorCache
virtual ~ErrorCache ()
 
virtual Error lastError () const
 

Protected Member Functions

 Parser (const QString &name)
 
- Protected Member Functions inherited from Soprano::Plugin
 Plugin (const QString &name)
 
- Protected Member Functions inherited from Soprano::Error::ErrorCache
 ErrorCache ()
 
void clearError () const
 
void setError (const Error &) const
 
void setError (const QString &errorMessage, int code=ErrorUnknown) const
 

Detailed Description

Soprano::Parser defines the interface for a Soprano RDF parser plugin.

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

Usage

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

Soprano::Parser defines the interface for a Soprano RDF parser plugin.
Definition parser.h:70
const Parser * discoverParserForSerialization(RdfSerialization serialization, const QString &userSerialization=QString())
static PluginManager * instance()
@ SerializationRdfXml

Then parsing RDF data is done in a single method call resulting in a StatementIterator over the resulting graph (since parsers may support multiple serializations one always needs to provide the serialization type unless a parser plugin support autodetection).

virtual StatementIterator parseFile(const QString &filename, const QUrl &baseUri, RdfSerialization serialization, const QString &userSerialization=QString()) const
An iterator that provides a stream of Statements.
See also
Writing Soprano Plugins
Author
Daniele Galdi danie.nosp@m.le.g.nosp@m.aldi@.nosp@m.gmai.nosp@m.l.com
Sebastian Trueg trueg.nosp@m.@kde.nosp@m..org

Definition at line 69 of file parser.h.

Constructor & Destructor Documentation

◆ ~Parser()

virtual Soprano::Parser::~Parser ( )
virtual

◆ Parser()

Soprano::Parser::Parser ( const QString & name)
protected

Member Function Documentation

◆ supportedSerializations()

virtual RdfSerializations Soprano::Parser::supportedSerializations ( ) const
pure virtual

The serialiazation types supported by this parser.

Returns
A combination of Soprano::RdfSerialization types. If the list contains Soprano::SerializationUser the parser supports additional RDF serializations not officially supported by Soprano.

◆ supportedUserSerializations()

virtual QStringList Soprano::Parser::supportedUserSerializations ( ) const
virtual

A parser 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()

bool Soprano::Parser::supportsSerialization ( RdfSerialization s,
const QString & userSerialization = QString() ) const

Check if a plugin supports a specific serialization.

Parameters
sThe requested serialization.
userSerializationIf serialization is set to Soprano::SerializationUser this parameter specifies the requested serialization. It allows the extension of the Soprano Parser interface with new RDF serializations that are not officially supported by Soprano.
Returns
true if the parser is able to parse RDF data encoded in serialization s, false otherwise.

◆ parseFile()

virtual StatementIterator Soprano::Parser::parseFile ( const QString & filename,
const QUrl & baseUri,
RdfSerialization serialization,
const QString & userSerialization = QString() ) const
virtual

Parse an RDF model which has been serialized in a file, using the supplied baseURI to resolve any relative URI references.

The default implementation simply calls parseStream() on an opened QFile instance.

Parameters
filenameThe name (path) of the file to parse
baseUriThe base URI to be used for relative references.
serializationThe serialization used in the file.
userSerializationIf serialization is set to Soprano::SerializationUser this parameter specifies the serialization to use. It allows the extension of the Soprano Parser interface with new RDF serializations that are not officially supported by Soprano.
Returns
An iterator that iterates over the result statements.

◆ parseString()

virtual StatementIterator Soprano::Parser::parseString ( const QString & data,
const QUrl & baseUri,
RdfSerialization serialization,
const QString & userSerialization = QString() ) const
virtual

Parse an RDF model which has been serialized into a string, using the supplied baseURI to resolve any relative URI references.

The default implementation simply calls parseStream().

Parameters
dataThe serialized RDF string.
baseUriThe base URI to be used for relative references.
serializationThe serialization used for the string data.
userSerializationIf serialization is set to Soprano::SerializationUser this parameter specifies the serialization to use. It allows the extension of the Soprano Parser interface with new RDF serializations that are not officially supported by Soprano.
Returns
An iterator that iterates over the result statements.

◆ parseStream()

virtual StatementIterator Soprano::Parser::parseStream ( QTextStream & stream,
const QUrl & baseUri,
RdfSerialization serialization,
const QString & userSerialization = QString() ) const
pure virtual

Read a serialized RDF model from a test stream, using the supplied baseURI to resolve any relative URI references.

Parameters
streamThe text stream to read the serialized RDF data from.
baseUriThe base URI to be used for relative references.
serializationThe serialization used for the string data from the stream.
userSerializationIf serialization is set to Soprano::SerializationUser this parameter specifies the serialization to use. It allows the extension of the Soprano Parser interface with new RDF serializations that are not officially supported by Soprano.
Returns
An iterator that iterates over the result statements.

The documentation for this class was generated from the following file: