backend.h   backend.h 
/* /*
* This file is part of Soprano Project. * This file is part of Soprano Project.
* *
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org> * Copyright (C) 2007-2008 Sebastian Trueg <trueg@kde.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Library General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef _SOPRANO_BACKEND_H_ #ifndef _SOPRANO_BACKEND_H_
#define _SOPRANO_BACKEND_H_ #define _SOPRANO_BACKEND_H_
#include <soprano/soprano_export.h> #include "plugin.h"
#include "error.h"
#include "soprano_export.h"
#include "sopranotypes.h"
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtCore/QVariant>
#include <QtCore/QSharedDataPointer>
namespace Soprano namespace Soprano
{ {
class Model; class StorageModel;
class Parser;
/** /**
* Soprano::Backend defines the interface for a Soprano backend plugin. * \class BackendSetting backend.h Soprano/BackendSetting
* *
* To create a new backend simply create a class that implements this int * \brief Wraps one setting for Model creation.
erface *
* and is derived from QObject. Then use the Q_INTERFACE macro to define * A BackendSetting consists of an option type and an option value. The
that it option type can either be a predefined
* is in fact a Backend plugin and export the plugin via the Q_EXPORT_PLU * value from Soprano::BackendOption or a user defined string value tha
GIN2 macro. t depends on the Backend implementation. In the
* * latter case option has to be set to Soprano::BackendOptionUser.
* \code *
* class MyBackend : public QObject, public Soprano::Backend * \author Sebastian Trueg <trueg@kde.org>
* { *
* Q_OBJECT * \sa Backend::createModel()<br/>BackendSettings
* Q_INTERFACES(Soprano::Backend) */
* class SOPRANO_EXPORT BackendSetting
* public:
* Storage* createStorage( const QString& name, const QStringList& opti
ons = QStringList() ) const;
* Parser* createParser( const QStringList& options = QStringList() ) c
onst;
* };
* \endcode
*
* In the implementation file export the plugin so it can be picked up by
the
* plugin loading framework:
*
* \code
* Q_EXPORT_PLUGIN2(soprano_mybackend, MyBackend)
* \endcode
*/
class SOPRANO_EXPORT Backend
{ {
public: public:
Backend( const QString& name ); /**
virtual ~Backend(); * Create an empty setting.
* \sa Soprano::BackendOptionNone
*/
BackendSetting();
QString backendName() const; /**
* Create a boolean setting with a default true value.
*/
BackendSetting( BackendOption option );
/** /**
* Creates a simple memory model * Create a standard setting with option \p s and value \p value_.
* The caller takes ownership and has to care about deletion. */
*/ BackendSetting( BackendOption s, const QVariant& value_ );
virtual Model* createModel() const = 0;
/** /**
* Creates a new RDF model with options. * Create a user setting with user option name \p userOption and va
* The caller takes ownership and has to care about deletion. lue \p value_.
* */
* \param name the name of the model, can be used for storage. BackendSetting( const QString& userOption, const QVariant& value_ )
* ;
* \param options Specify optional options for the created model. Opt
ions are key/value
* pairs in the form of "key=value".
* Possible options may include (options always depend on the
implementation)
* \li storagePath Where to store the data on the local harddr
ive
* \li storageType The database backend used, i.e. berkdb or s
qlite or memory
*/
virtual Model* createModel( const QString& name, const QStringList& o
ptions = QStringList() ) const = 0;
/** /**
* Create a new RDF parser. * Copy constructor.
* The caller takes ownership and has to care about deletion. */
* BackendSetting( const BackendSetting& other );
* \param options optional options. Unused for now.
*/
virtual Parser* createParser( const QStringList& options = QStringLis
t() ) const = 0;
/** /**
* Features include: * Destructor.
* \li memory The backend supports a memory storage. */
* \li contexts The backend supports RDF contexts. ~BackendSetting();
* \li parser The backend supports Parser creation.
*
* \return the list of supported features.
*/
virtual QStringList features() const = 0;
// FIXME: make the features an enumeration /**
bool hasFeature( const QString& feature ) const; * Copy operator.
bool hasFeatures( const QStringList& feature ) const; */
BackendSetting& operator=( const BackendSetting& other );
/**
* The option that this setting sets. If Soprano::BackendOptionUser
* the option is identified by userOptionName().
*/
BackendOption option() const;
/**
* The name of the user option if option() is Soprano::BackendOptio
nUser.
*/
QString userOptionName() const;
/**
* The value of the setting.
*/
QVariant value() const;
/**
* Set the value of the Setting.
*/
void setValue( const QVariant& value );
private: private:
class Private; class Private;
Private* const d; QSharedDataPointer<Private> d;
};
/**
* List of BackendSetting.
*
* \sa isOptionInSettings, settingInSettings, valueInSettings
*/
typedef QList<BackendSetting> BackendSettings;
/**
* Check if a certain option is defined in a list of BackendSettings.
*
* \param settings The list to check.
* \param option The option to check.
* \param userOptionName If \p option is Soprano::BackendOptionUser, th
is
* defines the user option to be checked.
*
* \return \p true if the option is defined.
*
* \relates BackendSetting
*
* \since 2.2
*/
SOPRANO_EXPORT bool isOptionInSettings( const BackendSettings& settings
, BackendOption option, const QString& userOptionName = QString() );
/**
* Get a setting from the set, allowing to modify it.
*
* \param settings The list to check.
* \param option The option to extract.
* \param userOptionName If \p option is Soprano::BackendOptionUser, th
is
* defines the user option to be extracted.
*
* \return The extracted setting. An empty setting is added to \p setti
ngs in case the option is not found in \p settings.
*
* \relates BackendSetting
*
* \since 2.2
*/
SOPRANO_EXPORT BackendSetting& settingInSettings( BackendSettings& sett
ings, BackendOption option, const QString& userOptionName = QString() );
/**
* \overload
*
* \param settings The list to check.
* \param userOptionName The user option to be extracted.
*
* \return The extracted setting. An empty setting is added to \p setti
ngs in case the option is not found in \p settings.
*
* \relates BackendSetting
*
* \since 2.4
*/
SOPRANO_EXPORT BackendSetting& settingInSettings( BackendSettings& sett
ings, const QString& userOptionName );
/**
* Get a setting from the set.
*
* \param settings The list to check.
* \param option The option to extract.
* \param userOptionName If \p option is Soprano::BackendOptionUser, th
is
* defines the user option to be extracted.
*
* \return The extracted setting. If the setting is not found an empty
BackendSetting is returned.
*
* \relates BackendSetting
*
* \since 2.4
*/
SOPRANO_EXPORT BackendSetting settingInSettings( const BackendSettings&
settings, BackendOption option, const QString& userOptionName = QString()
);
/**
* \overload
*
* \param settings The list to check.
* \param userOptionName The user option to be extracted.
*
* \return The extracted setting. If the setting is not found an empty
BackendSetting is returned.
*
* \relates BackendSetting
*
* \since 2.4
*/
SOPRANO_EXPORT BackendSetting settingInSettings( const BackendSettings&
settings, const QString& userOptionName = QString() );
/**
* Retrieve the value of an option.
*
* \param settings The list to check.
* \param option The option to retrieve.
* \param userOptionName If \p option is Soprano::BackendOptionUser, th
is
* defines the user option to be retrieved.
*
* \return The value of the specified option or an invalid variant if t
he set
* does not contain the option.
*
* \relates BackendSetting
*
* \since 2.2
*/
SOPRANO_EXPORT QVariant valueInSettings( const BackendSettings& setting
s, BackendOption option, const QString& userOptionName = QString() );
/**
* \overload
*
* \param settings The list to check.
* \param userOptionName The user option to retrieve.
* \param defaultValue The default to use if \p option is not part of \
p settings
*
* \return The value of the specified option or \p default if \p settin
gs
* does not contain the option.
*
* \relates BackendSetting
*
* \since 2.4
*/
SOPRANO_EXPORT QVariant valueInSettings( const BackendSettings& setting
s, const QString& userOptionName, const QVariant& defaultValue = QVariant()
);
/**
* Retrieve the value of an option with a fallback default.
*
* \param settings The list to check.
* \param option The option to retrieve.
* \param defaultValue The default to use if \p option is not part of \
p settings
*
* \return The value of the specified option or \p default if \p settin
gs
* does not contain the option.
*
* \relates BackendSetting
*
* \since 2.4
*/
SOPRANO_EXPORT QVariant valueInSettingsWithDefault( const BackendSettin
gs& settings, BackendOption option, const QVariant& defaultValue );
/**
* \class Backend backend.h Soprano/Backend
*
* \brief Soprano::Backend defines the interface for a Soprano backend
plugin.
*
* The Backend interface defines two important methods: createModel() a
nd supportedFeatures().
* It inherits from Error::ErrorCache for error handling and subclasses
should use clearError()
* and setError() to report the status.
*
* \sa \ref soprano_writing_plugins
*
* \author Sebastian Trueg <trueg@kde.org>
*/
class SOPRANO_EXPORT Backend : public Plugin, public Error::ErrorCache
{
public:
Backend( const QString& name );
virtual ~Backend();
/**
* Creates a new RDF model with options.
* The caller takes ownership and has to care about deletion.
*
* \param settings The settings that should be used to create the M
odel. Backend implementations
* should never ignore settings but rather return 0 if an option is
not supported. Backends can,
* however, define their own default settings. Invalid settings sho
uld result in an Error with value
* Error::ErrorInvalidArgument.
*
* \sa BackendSetting
*/
virtual StorageModel* createModel( const BackendSettings& settings
= BackendSettings() ) const = 0;
/**
* Phyically delete all data for a specific model. For most backend
s this means deleting some files
* on the hard disk. With others it may mean to delete tables from
an SQL database.
*
* \param settings The settings that were used to create the model
which should be deleted.
* For most backends the Soprano::BackendOptionStor
ageDir setting is probably most important.
* If the settings do not provide enough informatio
n to uniquely identify the model
* to delete, the method should be terminated with
an Error::ErrorInvalidArgument
* error.
*
* \return \p true if the data was successfully removed, \p false o
therwise. ErrorCache::lastError()
* may provide more detailed error information in the latte
r case.
*
* \since 2.1
*/
virtual bool deleteModelData( const BackendSettings& settings ) con
st = 0;
/**
* Each backend can support a set of features. Backends without any
features do not make much sense.
* If the features include Soprano::BackendFeatureUser additional u
ser features not defined in
* Backend::BackendFeature can be supported via supportedUserFeatur
es().
*
* \return A combination of Soprano::BackendFeature values.
*/
virtual BackendFeatures supportedFeatures() const = 0;
/**
* A Backend can support additional features that are not defined i
n Backend::BackendFeature.
* These user defined features have string identifiers. If a backen
d supports additional features
* it has to include Soprano::BackendFeatureUser in supportedFeatur
es().
*
* The default implementation returns an empty list.
*
* \return the list of supported user features.
*/
virtual QStringList supportedUserFeatures() const;
/**
* Check if a backend supports certain features. If feature include
s Soprano::BackendFeatureUser
* the list if userFeatures is also compared.
*
* \return \p true if the backend does support the requested featur
es, \p false otherwise.
*/
bool supportsFeatures( BackendFeatures feature, const QStringList&
userFeatures = QStringList() ) const;
private:
class Private;
Private* const d;
}; };
} }
Q_DECLARE_INTERFACE(Soprano::Backend, "org.soprano.plugins.Backend/1.0") Q_DECLARE_INTERFACE(Soprano::Backend, "org.soprano.plugins.Backend/2.1")
#endif #endif
 End of changes. 14 change blocks. 
86 lines changed or deleted 342 lines changed or added


 error.h   error.h 
skipping to change at line 25 skipping to change at line 25
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Library General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef _SOPRANO_ERROR_H_ #ifndef _SOPRANO_ERROR_H_
#define _SOPRANO_ERROR_H_ #define _SOPRANO_ERROR_H_
#include <soprano/soprano_export.h> #include "soprano_export.h"
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QSharedDataPointer>
namespace Soprano { namespace Soprano {
enum ErrorCode { namespace Error {
ERROR_NONE = 0, /**
ERROR_INVALID_STATEMENT, * %Soprano defines a number of error codes that are
ERROR_UNKNOW * used to provide a quick success status check in methods
}; * such as Model::addStatement().
*
* \sa Error::Error::code(), Error::convertErrorCode
*/
enum ErrorCode {
ErrorNone = 0x0, /**< No error occured, i.e. succes
s. */
ErrorInvalidArgument = 0x1, /**< Error indicating that a metho
d argument was invalid. For example an invalid Statement in Model::addState
ment(). */
ErrorInvalidStatement = ErrorInvalidArgument, /**< \deprecated:
use ErrorInvalidArgument */
ErrorNotSupported = 0x2, /**< Error indicating that a certa
in functionality is not supported. */
ErrorParsingFailed = 0x3, /**< Parsing a query or an RDF ser
ialization failed. */
ErrorPermissionDenied = 0x4, /**< Permission is denied. \since
2.1 */
ErrorUnknown = 0x1000 /**< An unknown error occured. */
};
/** /**
* Translate an error code into a human-readable error message. * Translate an error code into a human-readable error message.
*/ */
SOPRANO_EXPORT QString errorMessage( ErrorCode ); SOPRANO_EXPORT QString errorMessage( ErrorCode );
/**
* Converts a plain error code (as for example used in Error::code(
))
* into an ErrorCode value.
*
* \return \p code converted to ErrorCode. If it is an unknown valu
e,
* ErrorUnknown will be returned.
*/
SOPRANO_EXPORT ErrorCode convertErrorCode( int code );
class ErrorData;
class ParserError;
/**
* \class Error error.h Soprano/Error/Error
*
* \brief Represents an error in %Soprano.
*
* \author Sebastian Trueg <trueg@kde.org>
*
* \sa \ref soprano_error_handling
*/
class SOPRANO_EXPORT Error
{
public:
/**
* Create an Error object, representing success, i.e. no error.
*/
Error();
/**
* Create an Error object.
*
* \param message A human-readable error message.
* \param code An optional machine-readable error code. Can be
one of Soprano::ErrorCode
* or a user defined value which has to be bigger than ErrorUnk
nown. The redland backend
* for example uses error codes <i>ErrorUnknown + redlandCode</
i>.
*/
Error( const QString& message, int code = ErrorUnknown );
/**
* Copy constructor
*/
Error( const Error& );
/**
* Destructor
*/
virtual ~Error();
Error& operator=( const Error& );
/**
* An %Error evalutes to a boolean, indicating if an %Error is
"set".
*
* \return \p false if code() == #ErrorNone, \p true otherwise.
*
* Thus, an Error object can easily be checked as follows:
*
* \code
* model.addStatement( s );
* if( model.lastError() ) {
* displayError( model.lastError() );
* }
* \endcode
*/
operator bool() const { return code() != ErrorNone; }
/**
* A string explaining the error in detail.
* This string is not necessarily translated (this
* depends on the plugin implementation).
*
* \return An error message describing the error or an empty st
ring
* for no-error (i.e. success) instances.
*/
QString message() const;
/**
* An error code. If the error code is #ErrorNone the
* Error instance represents success.
* The code can either be one of the values of ErrorCode
* or a value above #ErrorUnknown.
*
* Example: The redland backend defines the error code
* as:
* \code
* ErrorUnknown + librdf_log_message_code()
* \endcode
*
* \sa ErrorCode, Error::convertErrorCode
*/
int code() const;
/**
* \return \p true if this Error instance represents a parser e
rror.
* In that case the error can be converted to a ParserError.
*/
bool isParserError() const;
/**
* Converts this error into a ParserError.
* This has the same effect as
* \code
* Error e;
* ParserError p1( e );
* \endcode
*
* \return If isParserError() returns true a ParserError
* with a valid Locator value, otherwise a ParserError with
* an empty Locator.
*/
ParserError toParserError() const;
protected:
/** \cond protected_error_members */
Error( ErrorData* );
QSharedDataPointer<ErrorData> d;
/** \endcond */
};
class Locator;
/**
* \class ParserError error.h Soprano/Error/ParserError
*
* \brief Represents a parser error in %Soprano.
*
* ParserError represents an error during parsing of either a query
string (Soprano::Query::Parser::parseQuery())
* or an RDF serialization (Soprano::Parser::parseStream()).
* Error and ParserError can be used together and copied without lo
osing information.
*
* The following code is perfectly valid and works:
*
* \code
* ParserError pe( 3, 4 );
* Error e = pe;
* ParserError otherPe = e;
* qDebug() << "Parsing failed at line " << otherPe.line() << " and
column " << otherPe.column();
* \endcode
*
* \author Sebastian Trueg <trueg@kde.org>
*
* \sa \ref soprano_error_handling
*/
class SOPRANO_EXPORT ParserError : public Error
{
public:
/**
* Create an Error object, representing success, i.e. no error.
*/
ParserError();
ParserError( const Locator&, const QString& message = QString()
, int code = ErrorParsingFailed );
ParserError( const Error& );
~ParserError();
ParserError& operator=( const Error& );
Locator locator() const;
};
/**
* \class ErrorCache error.h Soprano/Error/ErrorCache
*
* \brief Core class of %Soprano's exception system.
*
* The ErrorCache caches Error instances for different threads.
* Each thread has its own last error. This mechanism tries to
* replace the missing exceptions for methods that do not return
* an error code or another value that can state the success of the
* method's operation.
*
* \author Sebastian Trueg <trueg@kde.org>
*
* \sa \ref soprano_error_handling
*/
class SOPRANO_EXPORT ErrorCache
{
public:
virtual ~ErrorCache();
/**
* Get the last error that occured in the current thread.
*/
virtual Error lastError() const;
protected:
ErrorCache();
/**
* Reset the error for the current thread to no error.
*/
void clearError() const;
/**
* Set the last occured error. This method is const to allow se
tting
* of errors in all types of methods. The last error is as such
a
* mutable property.
*/
void setError( const Error& ) const;
/**
* Convenience method to set simple string error messages with
a default
* error code ErrorUnknown.
*/
void setError( const QString& errorMessage, int code = ErrorUnk
nown ) const;
private:
class Private;
Private* const d;
};
}
} }
class QDebug;
class QTextStream;
SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Error::Error& );
SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Erro
r::Error& );
#endif #endif
 End of changes. 5 change blocks. 
10 lines changed or deleted 268 lines changed or added


 literalvalue.h   literalvalue.h 
skipping to change at line 30 skipping to change at line 30
*/ */
#ifndef LITERAL_VALUE_H #ifndef LITERAL_VALUE_H
#define LITERAL_VALUE_H #define LITERAL_VALUE_H
#include "soprano_export.h" #include "soprano_export.h"
#include <QtCore/QVariant> #include <QtCore/QVariant>
#include <QtCore/QSharedDataPointer> #include <QtCore/QSharedDataPointer>
#include "languagetag.h"
namespace Soprano namespace Soprano
{ {
/** /**
* Represents a literal value of an RDF node. * \class LiteralValue literalvalue.h Soprano/LiteralValue
* LiteralValue is derived from QVariant to support *
* \brief Represents a literal value of an RDF Node.
*
* LiteralValue is based on QVariant to support
* a subset of the XML Schema types that are compatible * a subset of the XML Schema types that are compatible
* with QT types. * with QT types.
* *
* The following types are supported natively including * The following types are supported natively including
* automatic type conversion. Other types are represented * automatic type conversion. Other types are represented
* as strings. * as strings.
* *
* \li int * \li int (Vocabulary::XMLSchema::xsdInt)
* \li qlonglong * \li qlonglong (Vocabulary::XMLSchema::xsdLong)
* \li unsigned int * \li unsigned int (Vocabulary::XMLSchema::unsignedInt)
* \li qulonglong * \li qulonglong (Vocabulary::XMLSchema::unsignedLong)
* \li bool * \li bool (Vocabulary::XMLSchema::boolean)
* \li double * \li double and float (Vocabulary::XMLSchema::xsdDouble) (float value
* \li QString s are always converted to double)
* \li QDate * \li QString (Vocabulary::XMLSchema::string or Vocabulary::RDF::XMLLi
* \li QTime teral)
* \li QDateTime * \li QDate (Vocabulary::XMLSchema::date)
* \li QTime (Vocabulary::XMLSchema::time)
* \li QDateTime (Vocabulary::XMLSchema::dateTime)
* \li QByteArray (Vocabulary::XMLSchema::base64Binary)
* *
* Literal values can be converted from strings via fromString. * Literal values can be converted from strings via fromString().
*
* \sa Vocabulary::XMLSchema
*
* \author Sebastian Trueg <trueg@kde.org>
*/ */
class SOPRANO_EXPORT LiteralValue : private QVariant class SOPRANO_EXPORT LiteralValue
{ {
public: public:
/** //@{
* Create an empty literal value /**
*/ * Create an empty literal value
LiteralValue(); */
~LiteralValue(); LiteralValue();
LiteralValue( const LiteralValue& other ); /**
* Destructor
*/
~LiteralValue();
/** /**
* Creates a new LiteralValue from a QVariant. * Default copy constructor
* User types are not supported. If v contains an */
* unsupported type an invalid LiteralValue is created. LiteralValue( const LiteralValue& other );
*/
LiteralValue( const QVariant& v );
/** /**
* Creates a literal value of type int (i.e. * Creates a new LiteralValue from a QVariant.
* http://www.w3.org/2001/XMLSchema#int) * User types are not supported. If v contains an
*/ * unsupported type an invalid LiteralValue is created.
LiteralValue( int i ); */
LiteralValue( const QVariant& v );
/** /**
* Creates a literal value of type long long (i.e. * Creates a literal value of type int (i.e.
* http://www.w3.org/2001/XMLSchema#long) * http://www.w3.org/2001/XMLSchema#int)
*/ */
LiteralValue( qlonglong i ); LiteralValue( int i );
/** /**
* Creates a literal value of type unsigned int (i.e. * Creates a literal value of type long long (i.e.
* http://www.w3.org/2001/XMLSchema#unsignedInt) * http://www.w3.org/2001/XMLSchema#long)
*/ */
LiteralValue( uint i ); LiteralValue( qlonglong i );
/** /**
* Creates a literal value of type unsigned long long (i.e. * Creates a literal value of type unsigned int (i.e.
* http://www.w3.org/2001/XMLSchema#unsignedLong) * http://www.w3.org/2001/XMLSchema#unsignedInt)
*/ */
LiteralValue( qulonglong i ); LiteralValue( uint i );
/** /**
* Creates a literal value of type bool (i.e. * Creates a literal value of type unsigned long long (i.e.
* http://www.w3.org/2001/XMLSchema#boolean) * http://www.w3.org/2001/XMLSchema#unsignedLong)
*/ */
LiteralValue( bool b ); LiteralValue( qulonglong i );
/** /**
* Creates a literal value of type double (i.e. * Creates a literal value of type bool (i.e.
* http://www.w3.org/2001/XMLSchema#double) * http://www.w3.org/2001/XMLSchema#boolean)
*/ */
LiteralValue( double d ); LiteralValue( bool b );
/** /**
* Creates a literal value of type QString (i.e. * Creates a literal value of type double (i.e.
* http://www.w3.org/2001/XMLSchema#string) * http://www.w3.org/2001/XMLSchema#double)
* \param string The value of the new literal interpreted */
* as UTF-8 encoded string. LiteralValue( double d );
*/
LiteralValue( const char* string );
/** /**
* Creates a literal value of type QString (i.e. * Creates a literal value of type QString (i.e.
* http://www.w3.org/2001/XMLSchema#string) * http://www.w3.org/2001/XMLSchema#string)
*/ * \param string The value of the new literal interpreted
LiteralValue( const QLatin1String& string ); * as UTF-8 encoded string.
*/
LiteralValue( const char* string );
/** /**
* Creates a literal value of type QString (i.e. * Creates a literal value of type QString (i.e.
* http://www.w3.org/2001/XMLSchema#string) * http://www.w3.org/2001/XMLSchema#string)
*/ */
LiteralValue( const QString& string ); LiteralValue( const QLatin1String& string );
/** /**
* Creates a literal value of type QDate (i.e. * Creates a literal value of type QString (i.e.
* http://www.w3.org/2001/XMLSchema#date) * http://www.w3.org/2001/XMLSchema#string)
*/ */
LiteralValue( const QDate& date ); LiteralValue( const QString& string );
/** /**
* Creates a literal value of type QTime (i.e. * Creates a literal value of type QDate (i.e.
* http://www.w3.org/2001/XMLSchema#time) * http://www.w3.org/2001/XMLSchema#date)
*/ */
LiteralValue( const QTime& time ); LiteralValue( const QDate& date );
/** /**
* Creates a literal value of type QDateTime (i.e. * Creates a literal value of type QTime (i.e.
* http://www.w3.org/2001/XMLSchema#dateTime) * http://www.w3.org/2001/XMLSchema#time)
*/ */
LiteralValue( const QDateTime& datetime ); LiteralValue( const QTime& time );
/** /**
* Creates a copy of \a other * Creates a literal value of type QDateTime (i.e.
*/ * http://www.w3.org/2001/XMLSchema#dateTime)
LiteralValue& operator=( const LiteralValue& other ); */
LiteralValue( const QDateTime& datetime );
/** /**
* Assigns \a i to this literal value. The type will * Creates a literal value of type QByteArray (i.e.
* be set to int (http://www.w3.org/2001/XMLSchema#int) * http://www.w3.org/2001/XMLSchema#base64Binary)
* unless it is already set to a compatible type. */
* LiteralValue( const QByteArray& data );
* Thus, a type http://www.w3.org/2001/XMLSchema#integer //@}
* or http://www.w3.org/2001/XMLSchema#decimal will not
* be changed.
*
* Be aware that Soprano does not check the ranges of the
* integer value yet.
*/
LiteralValue& operator=( int i );
/** //@{
* Assigns \a i to this literal value. The type will /**
* be set to long (http://www.w3.org/2001/XMLSchema#long). * Creates a copy of \a other
*/ */
LiteralValue& operator=( qlonglong i ); LiteralValue& operator=( const LiteralValue& other );
/** /**
* Assigns \a i to this literal value. The type will * Assigns \a i to this literal value. The type will
* be set to uint (http://www.w3.org/2001/XMLSchema#unsignedInt) * be set to int (http://www.w3.org/2001/XMLSchema#int)
* unless it is already set to a compatible type. * unless it is already set to a compatible type.
* *
* Thus, a type http://www.w3.org/2001/XMLSchema#unsignedShort * Thus, a type http://www.w3.org/2001/XMLSchema#integer
* will not be changed. * or http://www.w3.org/2001/XMLSchema#decimal will not
* * be changed.
* Be aware that Soprano does not check the ranges of the *
* unsigned value yet. * Be aware that Soprano does not check the ranges of the
*/ * integer value yet.
LiteralValue& operator=( uint i ); */
LiteralValue& operator=( int i );
/** /**
* Assigns \a i to this literal value. The type will * Assigns \a i to this literal value. The type will
* be set to unsigned long (http://www.w3.org/2001/XMLSchema#uns * be set to long (http://www.w3.org/2001/XMLSchema#long).
ignedLong). */
*/ LiteralValue& operator=( qlonglong i );
LiteralValue& operator=( qulonglong i );
/** /**
* Assigns \a b to this literal value. The type will * Assigns \a i to this literal value. The type will
* be set to bool (http://www.w3.org/2001/XMLSchema#boolean). * be set to uint (http://www.w3.org/2001/XMLSchema#unsignedInt)
*/ * unless it is already set to a compatible type.
LiteralValue& operator=( bool b ); *
* Thus, a type http://www.w3.org/2001/XMLSchema#unsignedShort
* will not be changed.
*
* Be aware that Soprano does not check the ranges of the
* unsigned value yet.
*/
LiteralValue& operator=( uint i );
/** /**
* Assigns \a d to this literal value. The type will * Assigns \a i to this literal value. The type will
* be set to double (http://www.w3.org/2001/XMLSchema#double). * be set to unsigned long (http://www.w3.org/2001/XMLSchema#unsign
*/ edLong).
LiteralValue& operator=( double d ); */
LiteralValue& operator=( qulonglong i );
/** /**
* Assigns \a s to this literal value. The type will * Assigns \a b to this literal value. The type will
* be set to string (http://www.w3.org/2001/XMLSchema#string). * be set to bool (http://www.w3.org/2001/XMLSchema#boolean).
*/ */
LiteralValue& operator=( const QString& s ); LiteralValue& operator=( bool b );
/** /**
* Assigns \a s to this literal value. The type will * Assigns \a d to this literal value. The type will
* be set to string (http://www.w3.org/2001/XMLSchema#string). * be set to double (http://www.w3.org/2001/XMLSchema#double).
*/ */
LiteralValue& operator=( const QLatin1String& s ); LiteralValue& operator=( double d );
/** /**
* Assigns \a date to this literal value. The type will * Assigns \a s to this literal value. The type will
* be set to %data (http://www.w3.org/2001/XMLSchema#date). * be set to string (http://www.w3.org/2001/XMLSchema#string).
*/ */
LiteralValue& operator=( const QDate& date ); LiteralValue& operator=( const QString& s );
/** /**
* Assigns \a time to this literal value. The type will * Assigns \a s to this literal value. The type will
* be set to %time (http://www.w3.org/2001/XMLSchema#time). * be set to string (http://www.w3.org/2001/XMLSchema#string).
*/ */
LiteralValue& operator=( const QTime& time ); LiteralValue& operator=( const QLatin1String& s );
/** /**
* Assigns \a datetime to this literal value. The type will * Assigns \a date to this literal value. The type will
* be set to dateTime (http://www.w3.org/2001/XMLSchema#dateTime * be set to %data (http://www.w3.org/2001/XMLSchema#date).
). */
*/ LiteralValue& operator=( const QDate& date );
LiteralValue& operator=( const QDateTime& datetime );
bool operator==( const LiteralValue& other ) const; /**
* Assigns \a time to this literal value. The type will
* be set to %time (http://www.w3.org/2001/XMLSchema#time).
*/
LiteralValue& operator=( const QTime& time );
bool operator!=( const LiteralValue& other ) const; /**
* Assigns \a datetime to this literal value. The type will
* be set to dateTime (http://www.w3.org/2001/XMLSchema#dateTime).
*/
LiteralValue& operator=( const QDateTime& datetime );
bool isValid() const; /**
* Assigns \a datetime to this literal value. The type will
* be set to ByteArray (http://www.w3.org/2001/XMLSchema#base64Bina
ry).
*/
LiteralValue& operator=( const QByteArray& data );
//@}
bool isInt() const; //@{
bool isInt64() const; bool operator==( const LiteralValue& other ) const;
bool isUnsignedInt() const;
bool isUnsignedInt64() const;
bool isBool() const;
bool isDouble() const;
/** bool operator!=( const LiteralValue& other ) const;
* Check if the literal contains a string value. //@}
* Be aware that unknown literal types are also
* treated as strings. In that case compare
* dataTypeUrl.
*/
bool isString() const;
bool isDate() const;
bool isTime() const;
bool isDateTime() const;
int toInt() const; //@{
qlonglong toInt64() const; bool isValid() const;
uint toUnsignedInt() const;
qulonglong toUnsignedInt64() const;
bool toBool() const;
double toDouble() const;
/** /**
* Each type can be converted to a string which means that * Determines if this literal value is a plain literal.
* toString in combination with dataTypeUrl provides all the * Plain literals have no data type, but may have an optional lang
* information necessary to store this literal as RDF. uage tag.
*/ *
QString toString() const; * \return \c true if this literal is plain
QDate toDate() const; */
QTime toTime() const; bool isPlain() const;
QDateTime toDateTime() const;
/** bool isInt() const;
* The XML Schema datatype URI. bool isInt64() const;
* bool isUnsignedInt() const;
* \return The URI of the XML Schema type referring to the bool isUnsignedInt64() const;
* stored type or an empty QUrl if the LiteralValue is empty. bool isBool() const;
*/ bool isDouble() const;
QUrl dataTypeUri() const;
QVariant::Type type() const;
/** /**
* The literal value represented in a QVariant. * Check if the literal contains a string value.
* Be aware that the RDF typing information is lost * Be aware that unknown literal types are also
* in the converted variant. * treated as strings. In that case compare
*/ * dataTypeUrl.
QVariant variant() const; */
bool isString() const;
bool isDate() const;
bool isTime() const;
bool isDateTime() const;
bool isByteArray() const;
//@}
/** //@{
* Create a LiteralValue object by parsing string \a value based int toInt() const;
on \a type. qlonglong toInt64() const;
* If \a type is unknown a simple string LiteralValue object is uint toUnsignedInt() const;
returned qulonglong toUnsignedInt64() const;
* containing the plain string \a value. bool toBool() const;
*/ double toDouble() const;
static LiteralValue fromString( const QString& value, QVariant::
Type type );
/** /**
* Create a LiteralValue object by parsing string \a value based * Each type can be converted to a string which means that
on \a dataTypeUri. * toString in combination with dataTypeUrl provides all the
* If \a type is unknown it will be stored as a string value wit * information necessary to store this literal as RDF.
h the plain *
* \a dataTypeUri as type. Thus, unkown literal types can still * The string value is cached so calling it multiple times in
be used without * a row is fast.
* automatic type conversion. Be aware that changing the value w *
ill also change * \warning For historical reasons this is not a user-readable repr
* the type. esentation.
*/ *
static LiteralValue fromString( const QString& value, const QUrl * \sa Node::toString
& dataTypeUri ); */
QString toString() const;
QDate toDate() const;
QTime toTime() const;
QDateTime toDateTime() const;
QByteArray toByteArray() const;
//@}
/** //@{
* Convert an XML Schema URI into a QVariant::Type. /**
* \return The QVariant::Type corresponding to dataTypeUri or QV * The XML Schema datatype URI.
ariant::Invalid *
* if dataTypeUri is unknown. * \return The URI of the XML Schema type referring to the
*/ * stored type or an empty QUrl if the LiteralValue is empty or
static QVariant::Type typeFromDataTypeUri( const QUrl& dataTypeU * is a plain literal.
ri ); */
QUrl dataTypeUri() const;
static QUrl dataTypeUriFromType( QVariant::Type type ); /**
* The language tag.
*
* \return The language tag of the plain literal or an empty Langua
geTag
* if the LiteralValue has no language or it is a typed literal.
*/
LanguageTag language() const;
private: /**
class Private; * The type of the data.
QSharedDataPointer<Private> d; *
}; * \return The QVariant type of the stored data or QVariant::Invali
d
* if it is an empty value.
*/
QVariant::Type type() const;
/**
* The literal value represented in a QVariant.
* Be aware that the RDF typing information is lost
* in the converted variant.
*/
QVariant variant() const;
//@}
/**
* Create a LiteralValue object by parsing string \a value based on
\a type.
* If \a type is unknown a simple string LiteralValue object is ret
urned
* containing the plain string \a value.
*
* \sa fromString(const QString&, const QUrl&)
*/
static LiteralValue fromString( const QString& value, QVariant::Typ
e type );
/**
* Create a LiteralValue object by parsing string \a value based on
\a dataTypeUri.
*
* \param value The value of the literal. Might be converted based
on \a dataTypeUri.
*
* \param dataTypeUri The data type URI. %Soprano can automatically
convert all XML schema
* types. All other (unknown) types will be stored as a string valu
e with the plain
* \a dataTypeUri as type. Thus, unknown literal types can still be
used without
* automatic type conversion. (Be aware though, that changing the v
alue of a LiteralValue
* instance will reset the type, ie. custom data type URIs will be
lost.)
*
* Both an empty \a value and \a dataTypeUri will result in an inva
lid LiteralValue
* instance but an empty \a value with a valid \a dataTypeUri is po
ssible. A valid
* \a value with an invalid \a dataTypeUri will result in a Literal
Value of type
* Vocabulary::XMLSchema::string.
*
* \return A newly created LiteralValue instance based on the provi
ded \a value and
* \a dataTypeUri.
*
* \sa fromString(const QString&, QVariant::Type), Vocabulary::XMLS
chema
*/
static LiteralValue fromString( const QString& value, const QUrl& d
ataTypeUri );
/**
* Create a plain LiteralValue object with an optional language tag
.
*
* \param value The value of the literal.
*
* \param lang The language tag.
*
* Both an empty \a value and \a lang will result in an invalid Lit
eralValue
* instance but an empty \a value with a valid \a lang is possible.
A valid
* \a value with an empty \a lang will result in a plain, untyped l
iteral with no
* language tag.
*
* \return A newly created LiteralValue instance based on the provi
ded \a value and
* \a lang.
*/
static LiteralValue createPlainLiteral( const QString& value, const
LanguageTag& lang = LanguageTag() );
/**
* Convert an XML Schema URI into a QVariant::Type.
* \return The QVariant::Type corresponding to dataTypeUri or QVari
ant::Invalid
* if dataTypeUri is unknown.
*/
static QVariant::Type typeFromDataTypeUri( const QUrl& dataTypeUri
);
/**
* Convert a QVariant::Type into an XML Schema URI.
* \return The XML Schema URI that corresponds to \p type or an emp
ty QUrl if
* the type os unknown, i.e. can not be mapped to an XML Schema typ
e.
*/
static QUrl dataTypeUriFromType( QVariant::Type type );
private:
class LiteralValueData;
class PlainData;
class TypedData;
QSharedDataPointer<LiteralValueData> d;
};
SOPRANO_EXPORT uint qHash( const LiteralValue& lit );
} }
SOPRANO_EXPORT QDebug operator<<( QDebug dbg, const Soprano::LiteralValue& ); SOPRANO_EXPORT QDebug operator<<( QDebug dbg, const Soprano::LiteralValue& );
#endif #endif
 End of changes. 45 change blocks. 
249 lines changed or deleted 387 lines changed or added


 model.h   model.h 
skipping to change at line 26 skipping to change at line 26
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Library General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef SOPRANO_MODEL_H #ifndef SOPRANO_MODEL_H
#define SOPRANO_MODEL_H #define SOPRANO_MODEL_H
#include <QtCore/QObject>
#include <QtCore/QList> #include <QtCore/QList>
#include <soprano/soprano_export.h> #include "soprano_export.h"
#include <soprano/error.h> #include "error.h"
#include "sopranotypes.h"
#include "node.h"
class QString;
class QTextStream; class QTextStream;
class QUrl;
namespace Soprano namespace Soprano
{ {
class Node; class QueryLegacy;
class Query; class QueryResultIterator;
class ResultSet;
class Statement; class Statement;
class StatementIterator; class StatementIterator;
class NodeIterator;
namespace Query {
class Query;
}
// FIXME: what about a QList<Statement> allStatements method? /**
class SOPRANO_EXPORT Model * \class Model model.h Soprano/Model
{ *
public: * \brief A Model is the central class in %Soprano. It is a queryable
Model(); * collection of RDF quadruples, i.e statements.
*
* Model itself is just an interface for numerous implementations. (If
you are looking for a simple container
* for statements, see Graph.) There are basically two types of Models
in %Soprano:
*
* \li StorageModel is the base class for Model implementations that ac
tually store RDF quadruples.
* StorageModels are created transparently by %Soprano backend plug
ins: Backend::createModel()
* \li FilterModel is the base class for all filter models. FilterModel
s can be stacked on top of
* a StorageModel to perform arbitrary tasks like inference or actu
al content filtering. An
* important FilterModel is Inference::InferenceModel.
*
* The simplest way to create a memory Model is to use the default Back
end:
*
* \code
* Model* memModel = Soprano::createModel();
* \endcode
*
* <b>%Error handling:</b>
*
* Model is based on %Soprano's own error handling system which tries t
o emulate exceptions to a certain extend.
* Most methods in Model have a means of reporting if an operation was
successful or not. For additional error
* information Model inherits ErrorCache which provides the method last
Error().
*
* Thus, advanced error handling would look as follows:
*
* \code
* Soprano::Model* model = Soprano::createModel();
* Soprano::Statement invalidStatement;
* if( model->addStatement( invalidStatement ) != Error::ErrorNone ) {
* showErrorMessage( model->lastError().message() );
* }
* \endcode
*
* For this to work properly Model implementations have to reset the er
ror in each method
* by either calling clearError() or setError().
*
* \sa \ref soprano_error_handling
*
* Model is thread-safe when used with a thread-safe backend (all "offi
cial" %Soprano backends are thread-safe).
* However, it is recommended to create Model instances in the main thr
ead.
*
* \author Daniele Galdi <daniele.galdi@gmail.com><br>Sebastian Trueg <
trueg@kde.org>
*/
class SOPRANO_EXPORT Model : public QObject, public Error::ErrorCache
{
Q_OBJECT
virtual ~Model(); public:
virtual ~Model();
/** //@{
* Add all the Statements present in the given Model to the /**
* current Model. * Add the Statement to the Model.
* *
* \param model The Model to add. * \param statement The Statement to add.
*/ */
// FIXME: why is this not a virtual method? There is for example virtual Error::ErrorCode addStatement( const Statement &statement )
librdf_add_submodel = 0;
ErrorCode add( const Model &model );
/** /**
* Add Statements to the Model. * \overload
* */
* \param iter The StatementIterator to add. Error::ErrorCode addStatement( const Node& subject, const Node& pre
*/ dicate, const Node& object, const Node& context = Node() );
ErrorCode add( const StatementIterator &iter );
/** /**
* Add Statements to the Model with a Context. * \overload
* */
* If Context is empty, this is equivalent to add( const Stateme Error::ErrorCode addStatements( const QList<Statement> &statements
ntIterator &iter ). );
* //@}
* \param iter The StatementIterator to add.
* \param context The Context node.
*/
ErrorCode add( const StatementIterator &iter, const Node &contex
t );
/** //@{
* Add all Statements to the Model. /**
* * Remove one statement. For removing statements with wildward matc
* \param statements A list of Statements to add. hing see removeAllStatements().
*/ *
ErrorCode add( const QList<Statement> &statements ); * \param statement The statement that should be removed. This has
to be a valid statement.
*
* \return Error::ErrorNone on success and an error code if stateme
nt was invalid or an error
* occured.
*/
virtual Error::ErrorCode removeStatement( const Statement &statemen
t ) = 0;
/** /**
* Add all Statements to the Model. * \overload
* */
* If Context is empty, this is equivalent to add( const QList<S Error::ErrorCode removeStatement( const Node& subject, const Node&
tatement> &statements ). predicate, const Node& object, const Node& context = Node() );
*
* \param statements A list of Statements to add.
* \param context The Context node.
*/
ErrorCode add( const QList<Statement> &statements, const Node &c
ontext );
/** /**
* Add the Statement to the Model. * Remove all statements that match the partial statement. For remo
* ving
* \param statement The Statement to add. * one specific statement see removeStatement().
*/ *
virtual ErrorCode add( const Statement &statement ) = 0; * \param statement A possible partially defined statement that ser
ves as
* a filter for all statements that should be removed.
*/
virtual Error::ErrorCode removeAllStatements( const Statement &stat
ement ) = 0;
/** /**
* Add a statement to a model with a context. * \overload
* It must be a complete statement - all of subject, predicate, *
object * \param subject The subject node to match. Can be empty as a wild
* parts must be present. card.
* * \param predicate The predicate node to match. Can be empty as a
* If context is empty this is equivalent to add( const Statemen wildcard.
t &statement ). * \param object The object node to match. Can be empty as a wildca
* rd.
* \param statement The Statement to add. * \param context The context node to match. Can be empty as a wild
* \param context The Context node. card.
*/ */
virtual ErrorCode add( const Statement &statement, const Node &c Error::ErrorCode removeAllStatements( const Node& subject, const No
ontext ) = 0; de& predicate, const Node& object, const Node& context = Node() );
/** /**
* \return true if the Model doesn't contains any Statement. * Convenience method which removes all %statements in statements.
*/ */
virtual bool isEmpty() const; Error::ErrorCode removeStatements( const QList<Statement> &statemen
ts );
/** /**
* \return A List of Context Nodes. * Convenience method that removes all statements in the context.
*/ */
virtual QList<Node> contexts() const = 0; Error::ErrorCode removeContext( const Node& );
/** /**
* \return true if the Model contains the given Statement. * Convenience method that clear the Model of all statements
*/ */
virtual bool contains( const Statement &statement ) const = 0; Error::ErrorCode removeAllStatements();
//@}
/** //@{
* \return true if the Model contains the given Context node. /**
*/ * Return an iterator over Model Statements that "partial"
virtual bool contains( const Node &context ) const = 0; * match the input Statement.
*
* \param partial The partial Statement to match.
*
* \return An iterator for all the matched Statements, on error an
invalid iterator is returned.
*/
virtual StatementIterator listStatements( const Statement &partial
) const = 0;
/** /**
* Execute the given query over the Model. * \overload
* *
* \return All the Statements that match the query. * \param subject The subject node to match. Can be empty as a wild
*/ card.
virtual ResultSet executeQuery( const Query &query ) const = 0; * \param predicate The predicate node to match. Can be empty as a
wildcard.
* \param object The object node to match. Can be empty as a wildca
rd.
* \param context The context node to match. Can be empty as a wild
card.
*
* \return An iterator for all the matched Statements, on error an
invalid iterator is returned.
*/
StatementIterator listStatements( const Node& subject, const Node&
predicate, const Node& object, const Node& context = Node() ) const;
/** /**
* \return An iterator for all Model Statements. * \overload
*/ *
virtual StatementIterator listStatements() const; * \return An iterator for all statements in the model, on error an
invalid iterator is returned.
*/
StatementIterator listStatements() const;
/** /**
* List all statements in a model context. * Convenience method which lists all statements in context.
* *
* \param context The Context Node. * \return An iterator for all the matched Statements, on error an
* invalid iterator is returned.
* \return An iterator for all Context Model Statements. */
*/ StatementIterator listStatementsInContext( const Node &context ) co
virtual StatementIterator listStatements( const Node &context ) nst;
const = 0;
/** /**
* Return an iterator over Model Statements that "partial" * List all contexts in the model, i.e. all named graphs.
* match the input Statement, in the given Context. *
* * \return An iterator over context Nodes, on error an invalid iter
* If context is empty, this is equivalent to listStatements( co ator is returned.
nst Statement &partial ). */
* virtual NodeIterator listContexts() const = 0;
* \param partial The partial Statement to match.
* \param context The Context Node.
*
* \return An iterator for all the matched Statements.
*/
virtual StatementIterator listStatements( const Statement &parti
al, const Node &context ) const = 0;
/** /** \cond query_api_disabled */
* Return an iterator over Model Statements that "partial"
* match the input Statement.
*
* \param partial The partial Statement to match.
*
* \return An iterator for all the matched Statements.
*/
virtual StatementIterator listStatements( const Statement &parti
al ) const = 0;
/** /**
* Return an iterator over Model statements that "partial" * Execute the given query over the Model.
* match the input parameter. *
* * \param query The query to evaluate.
* \param subject The Subject node (can be empty) *
* \param predicate The Predicate node (can be empty) * \return An iterator over all results matching the query,
* \param object The Object node (can be empty) * on error an invalid iterator is returned.
* *
* \return An iterator for all the matched Statements. * \sa Query::QueryParser
*/ */
// FIXME: REMOVEME // virtual QueryResultIterator executeQuery( const Query::Query& query )
StatementIterator listStatements( const Node &subject, const Nod const = 0;
e &predicate, const Node &object ) const;
/** /** \endcond query_api_disabled */
* Remove a Statement from the Model in a Context.
* It must be a complete statement - all of subject, predicate,
object
* parts must be present.
*
* If Context is Empty, this is equivalent to remove(const State
ment &statement)
*
* \param statement The Statement to remove.
* \param context The Context node.
*/
virtual ErrorCode remove(const Statement &statement, const Node
&context ) = 0;
/** /**
* Remove a Statement from the Model. * Execute the given query over the Model.
* It must be a complete statement - all of subject, predicate, *
object * This is a const read-only method. As such Model implementations
* parts must be present. should not
* * support SPARQL extensions such as INSERT or UPDATE through this
* \param statement The Statement to remove. method.
*/ * A future version of %Soprano will provide an additional API for
virtual ErrorCode remove( const Statement &statement ) = 0; queries
* that change the Model.
*
* \param query The query to evaluate.
* \param language The %query language used to encode \p query.
* \param userQueryLanguage If \p language equals Query::QueryLangu
ageUser
* userQueryLanguage defines the language to use.
*
* \return An iterator over all results matching the query,
* on error an invalid iterator is returned.
*/
virtual QueryResultIterator executeQuery( const QString& query, Que
ry::QueryLanguage language, const QString& userQueryLanguage = QString() )
const = 0;
//@}
/** //@{
* Remove a list of Statements from the Model. /**
* * Check if the model contains certain statements.
* \param statements The Statements to remove. *
*/ * \param statement A partially defined statement that serves as
virtual ErrorCode remove( const QList<Statement> &statements ); * a pattern.
*
* \return true if the Model contains a Statement matching the give
n statement
* pattern.
*/
virtual bool containsAnyStatement( const Statement &statement ) con
st = 0;
/** /**
* Remove Statements from a Model with the given Context. * \overload
* *
* \param context The Context. * \param subject The subject node to match. Can be empty as a wild
*/ card.
virtual ErrorCode remove( const Node &context ) = 0; * \param predicate The predicate node to match. Can be empty as a
wildcard.
* \param object The object node to match. Can be empty as a wildca
rd.
* \param context The context node to match. Can be empty as a wild
card.
*/
bool containsAnyStatement( const Node& subject, const Node& predica
te, const Node& object, const Node& context = Node() ) const;
virtual ErrorCode removeAll( const Statement &statement, const N /**
ode &context ); * Check if the model contains a statements.
*
* \param statement The statement in question. This has to be a val
id statement,
* i.e. subject, predicate, and object need to be defined. If the c
ontext node
* is empty the default graph is searched.
*
* \return \p true if the Model contains the Statement, \p false ot
herwise or
* is statement is invalid.
*/
virtual bool containsStatement( const Statement &statement ) const
= 0;
virtual ErrorCode removeAll( const Statement &statement ); /**
* \overload
*/
bool containsStatement( const Node& subject, const Node& predicate,
const Node& object, const Node& context = Node() ) const;
/** /**
* Remove all the statements matching (s, p, o) from this model. * Convenience method which is based on containsAnyStatement
* */
* \param subject The Subject node (can be empty) bool containsContext( const Node &context ) const;
* \param predicate The Predicate node (can be empty)
* \param object The Object node (can be empty)
*/
virtual ErrorCode removeAll( const Node &subject, const Node &pr
edicate, const Node &object );
/** /**
* Remove all the statements from this model. * \return true if the Model doesn't contains any Statement.
*/ */
ErrorCode removeAll(); virtual bool isEmpty() const = 0;
/** /**
* \return The size of the Model (number of Stamenent). * The number of statements stored in this Model.
* -1 if not supported. * \return The size of the Model, or -1 on error.
*/ */
virtual int size() const = 0; virtual int statementCount() const = 0;
//@}
/** //@{
* Write a model to a textstream. /**
* * Write all statements in this Model to os.
* \param The stream. *
* * Default implementation is based on Model::listStatements
* \return ERROR_UNKNOW if not implemented or an Error occurred. */
*/ virtual Error::ErrorCode write( QTextStream &os ) const;
virtual ErrorCode write( QTextStream &os ) const = 0; //@}
/** //@{
* Print the Model to the stdout. /**
* * Creates a new blank node with a unique identifier.
* \return ERROR_UNKNOW if not implemented or an Error occurred. *
*/ * \return A blank node that can be used to create new statements.
virtual ErrorCode print() const = 0; */
virtual Node createBlankNode() = 0;
//@}
private: Q_SIGNALS:
class Private; /**
Private* const d; * Emitted when new statements have been added to the model.
}; *
* Implementations of this interface have to emit this signal.
*/
void statementsAdded();
/**
* Emitted when statements have been removed from the model.
*
* Implementations of this interface have to emit this signal.
*/
void statementsRemoved();
/**
* Notification signal for new statements. Model implementations
* should emit this signal for each newly added statement.
*/
void statementAdded( const Soprano::Statement& statement );
/**
* Notification signal for removed statements. Model implementation
s
* should emit this signal for each removed statement.
*
* \warning Backends may choose not to emit this signal for each
* removed statement but only for a statement pattern (i.e. an
* invalid statement as used in removeAllStatements()) to
* prevent massive performance loss.
*/
void statementRemoved( const Soprano::Statement& statement );
protected:
Model();
private:
/**
* Model instances are not meant to be copied.
*/
Model( const Model& );
Model& operator=( const Model& );
class Private;
Private* const d;
};
} }
#endif // SOPRANO_MODEL_H #endif
 End of changes. 38 change blocks. 
222 lines changed or deleted 366 lines changed or added


 node.h   node.h 
/* /*
* This file is part of Soprano Project. * This file is part of Soprano Project.
* *
* Copyright (C) 2006-2007 Daniele Galdi <daniele.galdi@gmail.com> * Copyright (C) 2006-2007 Daniele Galdi <daniele.galdi@gmail.com>
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org> * Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
skipping to change at line 28 skipping to change at line 28
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef SOPRANO_NODE_H #ifndef SOPRANO_NODE_H
#define SOPRANO_NODE_H #define SOPRANO_NODE_H
#include <QtCore/QUrl> #include <QtCore/QUrl>
#include <QtCore/QSharedDataPointer> #include <QtCore/QSharedDataPointer>
#include <QtCore/QTextStream>
#include "soprano_export.h" #include "soprano_export.h"
#include "literalvalue.h" #include "literalvalue.h"
#include "languagetag.h"
#include "sopranomacros.h"
namespace Soprano namespace Soprano
{ {
/**
* \class Node node.h Soprano/Node
*
* \brief A Node represents one RDF resource.
*
* Nodes are the cornerstone of RDF data in %Soprano. Four Nodes form o
ne Statement and a Model
* is essentially a set of Statements.
*
* A Node can have one of four types: EmptyNode, ResourceNode, LiteralN
ode, and BlankNode.
* Resource nodes are identified through their URI (uri()), literal nod
es have a LiteralValue (literal()),
* and blank nodes have a string identifier.
*
* Empty nodes can be used as wildcards in methods such as Model::listS
tatements.
*
* \author Daniele Galdi <daniele.galdi@gmail.com><br>Sebastian Trueg <
trueg@kde.org>
*/
class SOPRANO_EXPORT Node class SOPRANO_EXPORT Node
{ {
public: public:
enum Type {
EmptyNode = 0, /**< An empty node, can be used as a wildcard
in commands like Model::listStatements. */
ResourceNode = 1, /**< A resource node has a URI which can be a
ccessed via uri() */
LiteralNode = 2, /**< A literal node has a literal value and a
n optional language. */
BlankNode = 3 /**< A blank node has an identifier string */
};
enum Type { /**
EmptyNode = 0, /**< An empty node, can be used as a place * \name Constructors
holder in queries. */ */
ResourceNode = 1, /**< rdf:Resource (& rdf:Property) - has a //@{
URI */ /**
LiteralNode = 2, /**< rdf:Literal - has an XML string, lang * Default costructor.
uage, XML space */ * Creates an empty node.
BlankNode = 3 /**< blank node has an identifier string * *
/ * \sa createEmptyNode()
}; */
Node();
/** // This constructor is non-explicit for a reason: it makes creating
* Default costructor. // Statements much much easier and more readable
* Creates an empty node. /**
*/ * Creates a resource node.
Node(); *
* \param uri The URI of the node. If empty the type will be ignore
d
* and an empty node will be created.
*
* \sa createResourceNode()
*/
Node( const QUrl &uri );
// This constructor is non-explicit for a reason: it makes creat /**
ing * Creates a blank node.
// Statements much much easier and more readable *
/** * \param id An identifier for the blank node.
* Creates a resource or blank node. *
* * \sa createBlankNode()
* \param uri The URI of the node. If empty the type will be ign */
ored explicit Node( const QString& id );
* and an empty node will be created.
* \param type ResourceNode or BlankNode. Otherwise an empty nod
e will
* be created.
*/
Node( const QUrl &uri, Type type = ResourceNode );
/** /**
* Creates a literal node. * Creates a literal node.
* *
* \param value The value of a node. If empty the node will beco * \param value The value of a node. If empty the node will become
me * an empty node.
* an empty node. *
* * \sa createLiteralNode()
* \param language The language of the literal value. *
* * \since 2.3
* Caution: This constructor allows to create Nodes with */
* empty uris or values. Node( const LiteralValue& value );
*/
Node( const LiteralValue& value,
const QString& language = QString() );
Node( const Node &other ); /**
* Creates a literal node.
*
* \param value The value of a node. If empty the node will become
* an empty node.
* \param language The language of the literal value.
*
* \sa createLiteralNode()
*
* \deprecated Use Soprano::Node::Node( const LiteralValue& ) and
* Soprano::LiteralValue::createPlainLiteral( const QSt
ring&, const LanguageTag& )
*/
SOPRANO_CONSTRUCTOR_DEPRECATED Node( const LiteralValue& value,
const QString& language );
~Node(); /**
* Copy constructor.
*/
Node( const Node &other );
Node& operator=( const Node& other ); ~Node();
//@}
/** /**
* Assigns resource to this node and makes it a ResourceNode. * \name Operators
*/ */
Node& operator=( const QUrl& resource ); //@{
Node& operator=( const Node& other );
Node& operator=( const LiteralValue& literal ); /**
* Assigns \p resource to this node and makes it a ResourceNode.
*/
Node& operator=( const QUrl& resource );
bool operator==( const Node& other ) const; /**
bool operator!=( const Node& other ) const; * Assigns \p literal to this node and makes it a LiteralNode.
*/
Node& operator=( const LiteralValue& literal );
/** /**
* Match this node against other. The only difference * Comparision operator.
* to operator== is that empty nodes are matched as wildcards, * \return \p true if this node and \p other are equal.
* i.e. they match any other node. */
* bool operator==( const Node& other ) const;
* \return true if this node matches other, false if not.
*/
bool matches( const Node& other ) const;
/** /**
* \return The Node type. * Comparision operator.
*/ * \return \p true if this node and \p other differ.
Type type() const; */
bool operator!=( const Node& other ) const;
/** /**
* \return true if the Node is empty. * Comparision operator.
*/ * \return \p true if this node is a ResourceNode and
bool isEmpty() const; * has URI \p uri.
*/
bool operator==( const QUrl& uri ) const;
/** /**
* \return true if the Node is a Resource,Literal or Blank. * Comparision operator.
*/ * \return \p true if this node is a LiteralNode and
bool isValid() const ; * has literal value \p other.
*/
bool operator==( const LiteralValue& other ) const;
/** /**
* \return true if the Node is a Literal. * Match this node against template node \a other. The only differe
*/ nce
bool isLiteral() const; * to operator== is that empty nodes are matched as wildcards,
* i.e. they match any other node.
*
* Be aware that the following is NOT always true since only \a oth
er
* is treated a a wildcard:
*
* \code
* // NOT always true:
* a.matches(b) == b.matches(a)
* \endcode
*
* \return \p true if this node matches other, \p false if not.
*
* \sa Statement::matches
*/
bool matches( const Node& other ) const;
//@}
/** /**
* \return true if the Node is a Resource. * \name Type information
*/ */
bool isResource() const; //@{
/**
* \return The node type.
*/
Type type() const;
/** /**
* \return true if the Node is a Blank node (anonymous). * \return \p true if the node is empty.
*/ */
bool isBlank() const; bool isEmpty() const;
/** /**
* \return The URI if the node is a Resource or blank node. * \return \p true if the node is a ResourceNode, LiteralNode or Bl
* An null QUrl otherwise. ankNode.
*/ */
QUrl uri() const; bool isValid() const ;
/** /**
* \return The Literal value if the node is a Literal node. * \return \p true if the node is a LiteralNode.
* An null QString otherwise. */
*/ bool isLiteral() const;
LiteralValue literal() const;
/** /**
* \return The datatype URI of a literal node, i.e. the XML sche * \return \p true if the node is a ResourceNode.
ma type */
* or an empty value if the node is not a literal. bool isResource() const;
* \sa LiteralValue::dataTypeUri
*/
QUrl dataType() const;
/** /**
* Each literal value can have an associated language, thus each * \return \p true if the node is a BlankNode (anonymous).
property */
* can be stored for different languages. An empty language refe bool isBlank() const;
rs to the //@}
* default language.
*
* \return A string representing the language of the literal val
ue
* or an empty string if the node is not a literal.
*/
QString language() const;
/** /**
*\return A String representation of the Node. * \name Resource nodes
*/ */
QString toString() const; //@{
/**
* \return The URI if the node is a ResourceNode.
* An null QUrl otherwise.
*/
QUrl uri() const;
//@}
private: /**
class Private; * \name Blank nodes
QSharedDataPointer<Private> d; */
}; //@{
/**
* Retrieve a blank node's identifier.
* \return The node's identifier if it is a BlankNode, a null
* string otherwise.
*/
QString identifier() const;
//@}
/**
* \name Literal nodes
*/
//@{
/**
* \return The literal value if the node is a LiteralNode.
* An null QString otherwise.
*/
LiteralValue literal() const;
/**
* \return The datatype URI of a literal node, i.e. the XML schema
type
* or an empty value if the node is not a LiteralNode.
* \sa LiteralValue::dataTypeUri
*/
QUrl dataType() const;
/**
* Each literal value can have an associated language, thus each pr
operty
* can be stored for different languages. An empty language refers
to the
* default language.
*
* \return A string representing the language of the literal value
* or an empty string if the node is not a literal.
*
* \deprecated Language exists on the Soprano::LiteralValue. Use So
prano::Node::literal() and
* Soprano::LiteralValue::language().
*/
QString language() const;
//@}
/**
* \name Conversion
*/
//@{
/**
* Converts the Node to a string.
*
* \return A String representation of the Node, suitable for storag
e,
* not really suitable for user readable strings.
*
* \sa LiteralValue::toString(), QUrl::toString(), toN3()
*/
QString toString() const;
/**
* Convert a Node into N3 notation to be used in SPARQL graph patte
rns.
*
* Examples:
* \code
* <http://soprano.sourceforce.net/>
* "Hello World"^^<http://www.w3.org/2001/XMLSchema#string>
* "09-08-1977T17:42.234Z"^^<http://www.w3.org/2001/XMLSchema#dateT
ime>
* _:blankNode
* \endcode
*
* \return A string representing the node in N3 encoding or an empt
y
* string for invalid nodes.
*
* \sa toString()
*
* \since 2.2
*/
QString toN3() const;
//@}
/**
* Convenience method to create an empty node.
* Using this method instead of the default constructor
* may result in better readable code.
*
* \return An empty Node.
*/
static Node createEmptyNode();
/**
* Convenience method to create a resource node.
* Using this method instead of the constructor
* may result in better readable code.
*
* \param uri The URI of the node. If empty the type will be ignore
d
* and an empty node will be created.
*
* \return A resource Node or an empty Node if the specified URI is
empty.
*/
static Node createResourceNode( const QUrl& uri );
/**
* Convenience method to create a blank node.
* Using this method instead of the constructor
* may result in better readable code.
*
* If you need to create a new blank node which is not
* used in the model yet and, thus, has a unique identifier
* see Model::createBlankNode().
*
* \param id An identifier for the blank node.
*
* \return A blank node or an empty Node if the specified
* identifier was empty.
*/
static Node createBlankNode( const QString& id );
/**
* Convenience method to create a literal node.
* Using this method instead of the constructor
* may result in better readable code.
*
* \param value The value of a node. If empty the node will become
* an empty node.
*
* \return A literal node or an empty node if the specified value
* was empty.
*
* \since 2.3
*/
static Node createLiteralNode( const LiteralValue& value );
/**
* Convenience method to create a literal node.
* Using this method instead of the constructor
* may result in better readable code.
*
* \param value The value of a node. If empty the node will become
* an empty node.
* \param language The language of the literal value.
*
* \return A literal node or an empty node if the specified value
* was empty.
*
* \deprecated Use Soprano::Node::createLiteralNode( const LiteralV
alue& ) and
* Soprano::LiteralValue::createPlainLiteral( const QSt
ring&, const LanguageTag& )
*/
static SOPRANO_DEPRECATED Node createLiteralNode( const LiteralValu
e& value, const QString& language );
/**
* Format a resource URI as N3 string to be used in SPARQL queries.
*
* \return A string representing the resource in N3 encoding or an
empty
* string for invalid URIs.
*
* Example:
* \code
* <http://soprano.sourceforce.net/>
* \endcode
*
* \sa toN3
*
* \since 2.3
*/
static QString resourceToN3( const QUrl& resource );
/**
* Format a blank node identifier as N3 string to be used in SPARQL
queries.
*
* \return A string representing the blank identifier in N3 encodin
g or an empty
* string for invalid/empty ids.
*
* Example:
* \code
* _:blankNode
* \endcode
*
* \sa toN3
*
* \since 2.3
*/
static QString blankToN3( const QString& blank );
/**
* Format a literal value as N3 string to be used in SPARQL queries
.
*
* \return A string representing the literal in N3 encoding or an e
mpty
* string for invalid literals.
*
* Examples:
* \code
* "Hello World"^^<http://www.w3.org/2001/XMLSchema#string>
* "09-08-1977T17:42.234Z"^^<http://www.w3.org/2001/XMLSchema#dateT
ime>
* \endcode
*
* \sa toN3
*
* \since 2.3
*/
static QString literalToN3( const LiteralValue& literal );
private:
class NodeData;
class ResourceNodeData;
class BNodeData;
class LiteralNodeData;
QSharedDataPointer<NodeData> d;
};
/**
* \relates Soprano::Node
*/
SOPRANO_EXPORT uint qHash( const Node& node );
} }
/**
* \relates Soprano::Node
*/
SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Node& ); SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Node& );
/**
* Default Soprano::Node stream operator. The operator serializes the Node
* based on the N-Triples standard, except that it uses Unicode strings.
*
* \sa Soprano::Node::toN3()
*
* \relates Soprano::Node
*/
SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Node
& );
#if QT_VERSION < 0x040700
SOPRANO_EXPORT uint qHash( const QUrl& url );
#endif
#endif // SOPRANO_NODE_H #endif // SOPRANO_NODE_H
 End of changes. 31 change blocks. 
125 lines changed or deleted 442 lines changed or added


 parser.h   parser.h 
skipping to change at line 25 skipping to change at line 25
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Library General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef SOPRANO_PARSER_H #ifndef SOPRANO_PARSER_H
#define SOPRANO_PARSER_H #define SOPRANO_PARSER_H
#include <soprano/soprano_export.h> #include "plugin.h"
#include "soprano_export.h"
#include "sopranotypes.h"
#include "error.h"
#include <QtCore/QObject>
class QTextStream; class QTextStream;
class QString;
class QUrl; class QUrl;
namespace Soprano namespace Soprano
{ {
class Model; class StatementIterator;
/**
* Different types of RDF serialization.
*/
// FIXME: what about the used charsets? Should we and if so, how should
we include them?
enum RdfSerialization {
UNKNOWN = 0x0, /**< The serialization is unknown. */
RDF_XML = 0x1, /**< Standard RDF/XML serialization */
N3 = 0x2, /**< Notation 3: http://www.w3.org/DesignIssues/Not
ation3 */
N_TRIPLES = 0x4, /**< N-Triples as defined by W3: http://www.w3.org/
TR/rdf-testcases/#ntriples */
TURTLE = 0x8, /**< Turtle - Terse RDF Triple Language: http://www
.dajobe.org/2004/01/turtle/ */
TRIG = 0x10 /**< TriG - Turtle + Named Graphs: http://sites.wiw
iss.fu-berlin.de/suhl/bizer/TriG/ */
};
Q_DECLARE_FLAGS(RdfSerializations, RdfSerialization)
/** /**
* \return The mimetype of serialization or an empty string is serializ * \class Parser parser.h Soprano/Parser
ation is UNKNOWN *
* \brief Soprano::Parser defines the interface for a Soprano RDF parse
r plugin.
*
* Each parser plugin may support multiple RDF serializations (supporte
dSerializations()).
*
*
* \section Usage
*
* Using a Parser is straightforward. One starts by getting a plugin th
at supports the requested
* RDF data serialization:
*
* \code
* Soprano::Parser* p = Soprano::PluginManager::instance()->discoverPar
serForSerialization( Soprano::SerializationRdfXml );
* \endcode
*
* Then parsing RDF data is done in a single method call resulting in a
StatementIterator over
* the resulting graph (since parsers may support multiple serializatio
ns one always needs to
* provide the serialization type unless a parser plugin support autode
tection).
*
* \code
* Soprano::StatementIterator it = p->parseFile( "myrdffile.rdf", Sopra
no::SerializationRdfXml );
* \endcode
*
* \sa \ref soprano_writing_plugins
*
* \author Daniele Galdi <daniele.galdi@gmail.com><br>Sebastian Trueg <
trueg@kde.org>
*/ */
SOPRANO_EXPORT QString serializationMimeType( RdfSerialization serializ class SOPRANO_EXPORT Parser : public Plugin, public Error::ErrorCache
ation ); {
public:
virtual ~Parser();
/** /**
* Parse a mimetype and match it to the RdfSerialization enum. * The serialiazation types supported by this parser.
* \return the RdfSerialization type that matches mimetype or UNKNOWN i * \return A combination of Soprano::RdfSerialization types. If
f the mimetype * the list contains Soprano::SerializationUser the parser
* could not be parsed. * supports additional RDF serializations not
*/ * officially supported by %Soprano.
SOPRANO_EXPORT RdfSerialization mimeTypeToSerialization( const QString& */
mimetype ); virtual RdfSerializations supportedSerializations() const = 0;
class SOPRANO_EXPORT Parser /**
{ * A parser can support additional RDF serializations that are not
public: defined in Soprano::RdfSerialization.
virtual ~Parser(); * In that case supportedSerializations() has to include Soprano::S
erializationUser.
*
* The default implementation returns an empty list.
*
* \return A list of supported user RDF serializations.
*/
virtual QStringList supportedUserSerializations() const;
/** /**
* The serialiazation types supported by this parser. * Check if a plugin supports a specific serialization.
* \return A combination of RdfSerialization types. *
*/ * \param s The requested serialization.
virtual RdfSerializations supportedSerializations() const = 0; * \param userSerialization If serialization is set to Soprano::Ser
ializationUser this parameter specifies the
* requested serialization. It allows the extension of the %S
oprano Parser interface with new
* RDF serializations that are not officially supported by %S
oprano.
*
* \return \p true if the parser is able to parse RDF data encoded
* in serialization s, \p false otherwise.
*/
bool supportsSerialization( RdfSerialization s, const QString& user
Serialization = QString() ) const;
/** /**
* \deprecated * Parse an RDF model which has been serialized in a file,
* Calls parseFile with RDF_XML serialization * using the supplied baseURI to resolve any relative URI reference
*/ s.
Model* parse( const QUrl& url ) const; *
* The default implementation simply calls parseStream() on an open
ed
* QFile instance.
*
* \param filename The name (path) of the file to parse
* \param baseUri The base URI to be used for relative references.
* \param serialization The serialization used in the file.
* \param userSerialization If serialization is set to Soprano::Ser
ializationUser this parameter specifies the
* serialization to use. It allows the extension of the %Sopr
ano Parser interface with new
* RDF serializations that are not officially supported by %S
oprano.
*
* \return An iterator that iterates over the result statements.
*/
virtual StatementIterator parseFile( const QString& filename, const
QUrl& baseUri, RdfSerialization serialization, const QString& userSerializ
ation = QString() ) const;
/** /**
* Parse an RDF model which has been serialized in a file, * Parse an RDF model which has been serialized into a string,
* using the supplied baseURI to resolve any relative URI refere * using the supplied baseURI to resolve any relative URI reference
nces. s.
* *
* The default implementation simply calls parseStream on an ope * The default implementation simply calls parseStream().
ned *
* QFile instance. * \param data The serialized RDF string.
* * \param baseUri The base URI to be used for relative references.
* \param filename The name (path) of the file to parse * \param serialization The serialization used for the string data.
* \param baseUri The base URI to be used for relative reference * \param userSerialization If serialization is set to Soprano::Ser
s. ializationUser this parameter specifies the
* \param serialization The serialization used in the file. * serialization to use. It allows the extension of the %Sopr
* If UNKNOWN the parser is supposed to auto detect the serializ ano Parser interface with new
ation type. * RDF serializations that are not officially supported by %S
* Might not be reliable. oprano.
*/ *
virtual Model* parseFile( const QString& filename, const QUrl& b * \return An iterator that iterates over the result statements.
aseUri, RdfSerialization serialization = UNKNOWN ) const; */
virtual StatementIterator parseString( const QString& data, const Q
Url& baseUri, RdfSerialization serialization, const QString& userSerializat
ion = QString() ) const;
/** /**
* Parse an RDF model which has been serialized into a string, * Read a serialized RDF model from a test stream,
* using the supplied baseURI to resolve any relative URI refere * using the supplied baseURI to resolve any relative URI reference
nces. s.
* *
* The default implementation simply calls parseStream. * \param stream The text stream to read the serialized RDF data fr
* om.
* \param data The serialized RDF string. * \param baseUri The base URI to be used for relative references.
* \param baseUri The base URI to be used for relative reference * \param serialization The serialization used for the string data
s. from the stream.
* \param serialization The serialization used for the string da * \param userSerialization If serialization is set to Soprano::Ser
ta. ializationUser this parameter specifies the
* If UNKNOWN the parser is supposed to auto detect the serializ * serialization to use. It allows the extension of the %Sopr
ation type. ano Parser interface with new
* Might not be reliable. * RDF serializations that are not officially supported by %S
*/ oprano.
virtual Model* parseString( const QString& data, const QUrl& bas *
eUri, RdfSerialization serialization = UNKNOWN ) const; * \return An iterator that iterates over the result statements.
*/
virtual StatementIterator parseStream( QTextStream& stream, const Q
Url& baseUri, RdfSerialization serialization, const QString& userSerializat
ion = QString() ) const = 0;
/** protected:
* Read a serialized RDF model from a test stream, Parser( const QString& name );
* using the supplied baseURI to resolve any relative URI refere
nces.
*
* \param stream The text stream to read the serialized RDF data
from.
* \param baseUri The base URI to be used for relative reference
s.
* \param serialization The serialization used for the string da
ta from the stream.
* If UNKNOWN the parser is supposed to auto detect the serializ
ation type.
* Might not be reliable.
*/
virtual Model* parseStream( QTextStream* stream, const QUrl& bas
eUri, RdfSerialization serialization = UNKNOWN ) const = 0;
protected: private:
Parser(); class Private;
}; Private* const d;
};
} }
Q_DECLARE_OPERATORS_FOR_FLAGS(Soprano::RdfSerializations) Q_DECLARE_INTERFACE(Soprano::Parser, "org.soprano.plugins.Parser/1.0")
#endif // SOPRANO_PARSER_H #endif // SOPRANO_PARSER_H
 End of changes. 14 change blocks. 
106 lines changed or deleted 157 lines changed or added


 pluginmanager.h   pluginmanager.h 
/* /*
* This file is part of Soprano Project. * This file is part of Soprano Project.
* *
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org> * Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Library General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef _SOPRANO_PLUGIN_MANAGER_H_ #ifndef _SOPRANO_PLUGIN_MANAGER_H_
#define _SOPRANO_PLUGIN_MANAGER_H_ #define _SOPRANO_PLUGIN_MANAGER_H_
#include <QtCore/QObject> #include "sopranotypes.h"
#include "soprano_export.h"
#include <soprano/soprano_export.h> #include <QtCore/QObject>
#include <QtCore/QStringList>
namespace Soprano namespace Soprano
{ {
class Backend; class Backend;
class Parser;
class Serializer;
class SOPRANO_EXPORT PluginManager : public QObject namespace Query {
class Parser;
class Serializer;
}
/**
* \class PluginManager pluginmanager.h Soprano/PluginManager
*
* \brief The PluginManager loads and maintains all %Soprano plugins.
*
* Normally there is no need to use this class as all important methods
have
* global counterparts in the Soprano namespace.
*
* \sa \ref soprano_writing_plugins
*
* \author Sebastian Trueg <trueg@kde.org>
*/
class SOPRANO_EXPORT PluginManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
~PluginManager(); ~PluginManager();
/** //@{
* Find a backend plugin by its name. /**
* * Set the plugin search path. The PluginManager searches a set of
* \return the backend specified by \a name or null if could not folders for installed
* be found. * plugins. Here a plugin consists of a desktop file describing it
*/ and the actual plugin
const Backend* discoverBackendByName( const QString& name ); * library file. For loading custom plugins manually see loadCustom
Plugin.
*
* \param path The folders that PluginManager should search for plu
gin description files.
* \param useDefaults If true PluginManager will also search the de
fault plugin paths
*
* \sa \ref soprano_writing_plugins
*
* \since 2.3
*/
void setPluginSearchPath( const QStringList& path, bool useDefaults
= true );
/** /**
* Find a backend plugin by its features. * Load a custom plugin from a library at the specified path.
* *
* \return a backend that supports the features defined in \a feature * \param path The path to the library file that contains the plugi
s. n. Be aware that
*/ * plugins loaded via this method do not need a desktop file as des
const Backend* discoverBackendByFeatures( const QStringList& features cribed
); *
* PluginManager uses the name the plugin provides (Plugin::pluginN
ame)
* to manage the plugin.
*
* \return \p true if the plugin could be loaded successfully, \p f
alse
* if no suported plugin could be found at path.
*
* \since 2.3
*/
bool loadCustomPlugin( const QString& path );
static PluginManager* instance(); /**
* Load a custom Backend plugin from a library at the specified pat
h.
*
* \param path The path to the library file that contains the plugi
n.
*
* PluginManager uses the name the plugin provides (Plugin::pluginN
ame)
* to manage the plugin.
*
* \return The loaded Backend plugin or 0 in case no suported plugi
n could
* be found at path or the found plugin is not a backend.
*
* \since 2.3
*/
const Backend* loadCustomBackend( const QString& path );
/**
* Load a custom Parser plugin from a library at the specified path
.
*
* \param path The path to the library file that contains the plugi
n.
*
* PluginManager uses the name the plugin provides (Plugin::pluginN
ame)
* to manage the plugin.
*
* \return The loaded Parser plugin or 0 in case no suported plugin
could
* be found at path or the found plugin is not a backend.
*
* \since 2.3
*/
const Parser* loadCustomParser( const QString& path );
/**
* Load a custom Serializer plugin from a library at the specified
path.
*
* \param path The path to the library file that contains the plugi
n.
*
* PluginManager uses the name the plugin provides (Plugin::pluginN
ame)
* to manage the plugin.
*
* \return The loaded Serializer plugin or 0 in case no suported pl
ugin could
* be found at path or the found plugin is not a backend.
*
* \since 2.3
*/
const Serializer* loadCustomSerializer( const QString& path );
//@}
//@{
/**
* Find a backend plugin by its name.
*
* \return the backend specified by \a name or null if could not
* be found.
*/
const Backend* discoverBackendByName( const QString& name );
/**
* Find a backend plugin by its features.
*
* \param features The features that are requested, a combination o
f Soprano::BackendFeature flags.
* \param userFeatures If features contain Backend::BackendFeatureU
ser this paramter states the additionally requested user features.
*
* \return a Backend that supports the features defined in \a featu
res.
*/
const Backend* discoverBackendByFeatures( BackendFeatures features,
const QStringList& userFeatures = QStringList() );
QList<const Backend*> allBackends();
//@}
//@{
/**
* Find a parser plugin by its name.
*
* \return the parser specified by \a name or null if could not
* be found.
*/
const Parser* discoverParserByName( const QString& name );
/**
* Find a Parser instance that is able to parse RDF data serialized
as
* serialization.
*
* \param serialization The requested serialization.
* \param userSerialization If serialization is set to Soprano::Ser
ializationUser this parameter specifies the
* serialization to use. It allows the extension of the %Sopr
ano Parser interface with new
* RDF serializations that are not officially supported by %S
oprano.
*
* \return A Parser plugin that can parse RDF data encoded in the r
equested
* serialization or 0 if no such plugin could be found.
*/
const Parser* discoverParserForSerialization( RdfSerialization seri
alization, const QString& userSerialization = QString() );
QList<const Parser*> allParsers();
//@}
//@{
/**
* Find a serializer plugin by its name.
*
* \return the serializer specified by \a name or null if could not
* be found.
*/
const Serializer* discoverSerializerByName( const QString& name );
/**
* Find a Serializer instance that is able to encode RDF data using
* serialization.
*
* \param serialization The requested serialization.
* \param userSerialization If serialization is set to Soprano::Ser
ializationUser this parameter specifies the
* serialization to use. It allows the extension of the %Sopr
ano Serializer interface with new
* RDF serializations that are not officially supported by %S
oprano.
*
* \return A Serializer plugin that can serialize RDF data encoded
in the requested
* serialization or 0 if no such plugin could be found.
*/
const Serializer* discoverSerializerForSerialization( RdfSerializat
ion serialization, const QString& userSerialization = QString() );
QList<const Serializer*> allSerializers();
//@}
/** \cond query_api_disabled */
//@{
/**
* Find a query parser plugin by its name.
*
* \return the query parser specified by \a name or null if could n
ot
* be found.
*/
// const Query::Parser* discoverQueryParserByName( const QString& name )
;
/**
* Find a Query::Parser instance that is able to parse the specifie
d query language.
*
* \param lang The language the plugin is supposed to support.
* \param userQueryLanguage If lang is set to Query::QueryLanguageU
ser this parameter specifies the
* query language to use. It allows the extension of the %Sop
rano Query interface with new
* query languages that are not officially supported by %Sopr
ano.
*
* \return A Query::Parser plugin that can parse query language lan
g or 0 if no such plugin could be found.
*/
// const Query::Parser* discoverQueryParserForQueryLanguage( Query::Quer
yLanguage lang, const QString& userQueryLanguage = QString() );
// QList<const Query::Parser*> allQueryParsers();
//@}
//@{
/**
* Find a query serializer plugin by its name.
*
* \return the query serializer specified by \a name or null if cou
ld not
* be found.
*/
// const Query::Serializer* discoverQuerySerializerByName( const QString
& name );
/**
* Find a Query::Serializer instance that is able to serialize the
specified query language.
*
* \param lang The language the plugin is supposed to support.
* \param userQueryLanguage If lang is set to Query::QueryLanguageU
ser this parameter specifies the
* query language to use. It allows the extension of the %Sop
rano Query interface with new
* query languages that are not officially supported by %Sopr
ano.
*
* \return A Query::Serializer plugin that can parse query language
lang or 0 if no such plugin could be found.
*/
// const Query::Serializer* discoverQuerySerializerForQueryLanguage( Que
ry::QueryLanguage lang, const QString& userQueryLanguage = QString() );
// QList<const Query::Serializer*> allQuerySerializers();
//@}
/** \endcond query_api_disabled */
/**
* Get the singleton instance of the PluginManager
*/
static PluginManager* instance();
private: private:
PluginManager( QObject* parent = 0 ); PluginManager( QObject* parent = 0 );
void loadAllPlugins();
void loadPlugin( const QString& path );
void loadPlugins( const QString& path );
void loadAllPlugins(); class Private;
void loadPlugins( const QString& path ); Private* const d;
class Private; friend class PluginManagerFactory;
Private* const d;
}; };
} }
#endif #endif
 End of changes. 13 change blocks. 
28 lines changed or deleted 294 lines changed or added


 soprano.h   soprano.h 
/* /*
* This file is part of Soprano Project * This file is part of Soprano Project
* *
* Copyright (C) 2006 Daniele Galdi <daniele.galdi@gmail.com> * Copyright (C) 2006 Daniele Galdi <daniele.galdi@gmail.com>
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Library General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef SOPRANO_H #include "global.h"
#define SOPRANO_H //#include "query.h"
#include "queryresultiterator.h"
#include <soprano/query.h> #include "node.h"
#include <soprano/resultset.h> #include "nodeiterator.h"
#include <soprano/node.h> #include "literalvalue.h"
#include <soprano/literalvalue.h> #include "languagetag.h"
#include <soprano/statement.h> #include "statement.h"
#include <soprano/statementiterator.h> #include "statementiterator.h"
#include <soprano/model.h> #include "simplestatementiterator.h"
#include <soprano/parser.h> #include "model.h"
#include <soprano/backend.h> #include "storagemodel.h"
#include <soprano/pluginmanager.h> #include "filtermodel.h"
#include <soprano/error.h> #include "parser.h"
#include "serializer.h"
namespace Soprano { #include "backend.h"
/** #include "pluginmanager.h"
* Find a backend plugin by its name. #include "error.h"
* #include "locator.h"
* \return the backend specified by \a name or null if could not #include "bindingset.h"
* be found. #include "version.h"
*/ #include "sopranotypes.h"
SOPRANO_EXPORT const Backend* discoverBackendByName( const QString& name #include "vocabulary.h"
); #include "dummymodel.h"
#include "mutexmodel.h"
/** #include "asyncmodel.h"
* Find a backend plugin by its features.
*
* \return a backend that supports the features defined in \a features.
*/
SOPRANO_EXPORT const Backend* discoverBackendByFeatures( const QStringLis
t& features );
/**
* By default and if available backend "redland" is used.
*/
SOPRANO_EXPORT void setUsedBackend( const Backend* );
SOPRANO_EXPORT const Backend* usedBackend();
/**
* Creates a simple memory model
* The caller takes ownership and has to care about deletion.
*/
// FIXME: Isn't the notion of a "memory model" already way to implementat
ion-specific?
SOPRANO_EXPORT Model* createModel();
/**
* Creates a new RDF storage using the backend set via setUsedBackend.
* The caller takes ownership and has to care about deletion.
*
* \param name The name of the storage
*
* \param options Specify optional options for the created model. Options
are key/value
* pairs in the form of "key=value".
* Possible options may include (options always depend on the impl
ementation)
* \li storagePath Where to store the data on the local harddrive
* \li storageType The database backend used, i.e. berkdb or sqlit
e or memory
*
* \sa Model, Backend::createModel
*/
SOPRANO_EXPORT Model* createModel( const QString& name, const QStringList
& options = QStringList() );
/**
* Create a new RDF parser using the backend set via setUsedBackend.
* The caller takes ownership and has to care about deletion.
*
* \param options optional options. Unused for now.
*/
SOPRANO_EXPORT Parser* createParser( const QStringList& options = QString
List() );
}
#endif // SOPRANO_H
 End of changes. 2 change blocks. 
0 lines changed or deleted 1 lines changed or added


 soprano_export.h   soprano_export.h 
skipping to change at line 28 skipping to change at line 28
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef SOPRANO_EXPORT_H #ifndef SOPRANO_EXPORT_H
#define SOPRANO_EXPORT_H #define SOPRANO_EXPORT_H
/* needed for KDE_EXPORT and KDE_IMPORT macros */ /* needed for KDE_EXPORT and KDE_IMPORT macros */
#include <QtCore/QtGlobal> #include <QtCore/QtGlobal>
#if defined Q_OS_WIN
#ifndef SOPRANO_EXPORT #ifndef SOPRANO_EXPORT
# if defined(MAKE_SOPRANO_LIB) # if defined(MAKE_SOPRANO_LIB)
/* We are building this library */ /* We are building this library */
# define SOPRANO_EXPORT Q_DECL_EXPORT # define SOPRANO_EXPORT Q_DECL_EXPORT
# else # else
/* We are using this library */ /* We are using this library */
# define SOPRANO_EXPORT Q_DECL_IMPORT # define SOPRANO_EXPORT Q_DECL_IMPORT
# endif # endif
#endif #endif
#ifndef REDLANDBACKEND_EXPORT #ifndef SOPRANO_SERVER_EXPORT
# if defined(MAKE_REDLANDBACKEND_LIB) # if defined(MAKE_SOPRANO_SERVER_LIB)
/* We are building this library */ /* We are building this library */
# define REDLANDBACKEND_EXPORT Q_DECL_EXPORT # define SOPRANO_SERVER_EXPORT Q_DECL_EXPORT
# else # else
/* We are using this library */ /* We are using this library */
# define REDLANDBACKEND_EXPORT Q_DECL_IMPORT # define SOPRANO_SERVER_EXPORT Q_DECL_IMPORT
# endif # endif
#endif #endif
#else /* UNIX */ #ifndef SOPRANO_CLIENT_EXPORT
# if defined(MAKE_SOPRANO_CLIENT_LIB)
#define SOPRANO_EXPORT Q_DECL_EXPORT /* We are building this library */
#define REDLANDBACKEND_EXPORT Q_DECL_EXPORT # define SOPRANO_CLIENT_EXPORT Q_DECL_EXPORT
# else
/* We are using this library */
# define SOPRANO_CLIENT_EXPORT Q_DECL_IMPORT
# endif
#endif
#ifndef SOPRANO_INDEX_EXPORT
# if defined(MAKE_SOPRANO_INDEX_LIB)
/* We are building this library */
# define SOPRANO_INDEX_EXPORT Q_DECL_EXPORT
# else
/* We are using this library */
# define SOPRANO_INDEX_EXPORT Q_DECL_IMPORT
# endif
#endif #endif
#endif #endif
 End of changes. 6 change blocks. 
10 lines changed or deleted 21 lines changed or added


 statement.h   statement.h 
/* This file is part of Soprano Project. /* This file is part of Soprano Project.
* *
* Copyright (C) 2006 Daniele Galdi <daniele.galdi@gmail.com> * Copyright (C) 2006 Daniele Galdi <daniele.galdi@gmail.com>
* Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Library General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef SOPRANO_STATEMENT_H #ifndef SOPRANO_STATEMENT_H
#define SOPRANO_STATEMENT_H #define SOPRANO_STATEMENT_H
#include <QtCore/QSharedDataPointer> #include "node.h"
#include "soprano_export.h"
#include <soprano/node.h>
#include <soprano/soprano_export.h>
namespace Soprano namespace Soprano
{ {
/**
* \class Statement statement.h Soprano/Statement
*
* \brief A Statement instance represents one RDF quadruple.
*
* In %Soprano statements are quadruples, i.e. in addition to the subje
ct, predicate, and
* object nodes, they have a fourth node, the context. The context repr
esents the named graph
* in which the statement is stored. If the context is an empty node th
e statement is stored in
* the default graph.
*
* A Statement is valid if subject, predicate, and object are valid. In
valid statements can, however,
* be used in many methods such as Model::listStatements as wildwards.
*
* \sa Node
*
* \author Daniele Galdi <daniele.galdi@gmail.com><br>Sebastian Trueg <
trueg@kde.org>
*/
class SOPRANO_EXPORT Statement class SOPRANO_EXPORT Statement
{ {
public: public:
//@{
/** /**
* Default Constructor, build an Empty(not valid) Statement. * Default Constructor, build an empty (invalid) Statement.
*/ */
Statement(); Statement();
/**
* Build a Statement with the given subject, predicate and objec
t.
*
* \param subject The subject.
*
* \param predicate The predicate.
*
* \param object The object.
*
* \param context The context node.
*/
Statement( const Node &subject, const Node &predicate, const Nod
e &object, const Node &context = Node() );
Statement( const Statement &other );
virtual ~Statement();
Statement& operator=( const Statement& other ); /**
* Build a Statement with the given subject, predicate and object.
*
* \param subject The subject (cannot be of type Node::LiteralNode)
*
* \param predicate The predicate (has to be of type Node::Resource
Node or Node::EmptyNode)
*
* \param object The object can be of either Node type.
*
* \param context The context node (has to be of type Node::Resourc
eNode or Node::EmptyNode)
*/
Statement( const Node &subject, const Node &predicate, const Node &
object, const Node &context = Node() );
bool operator==( const Statement& other ); Statement( const Statement &other );
bool operator!=( const Statement& other );
/** virtual ~Statement();
* Match this statement against other. The only difference
* to operator== is that empty nodes are matched as wildcards,
* i.e. they match any other node.
*
* \return true if this statement matches other, false if not.
*/
bool matches( const Statement& other ) const;
/** Statement& operator=( const Statement& other );
* Change the Statement subject. //@}
*
* \param subject The new subject.
*/
void setSubject( const Node &subject );
/** //@{
* \return The subject. bool operator==( const Statement& other ) const;
*/ bool operator!=( const Statement& other ) const;
Node subject() const;
/** /**
* Change the Statement predicate. * Match this statement against template statement \a other. The on
* ly difference
* \param predicate The new predicate. * to operator== is that empty nodes are matched as wildcards,
*/ * i.e. they match any other node.
void setPredicate( const Node &predicate ); *
* Be aware that the following is NOT always true since only \a oth
er
* is treated a a wildcard:
*
* \code
* // NOT always true:
* a.matches(b) == b.matches(a)
* \endcode
*
* \return \p true if this statement matches other, \p false if not
.
*
* \sa Node::matches()
*/
bool matches( const Statement& other ) const;
//@}
/** //@{
* \return The predicate. /**
*/ * A Statement is valid if the subject is a resource or blank
Node predicate() const; * node, the predicate is a resource node,
* and the object is a valid node.
*
* \return @p true if the Statement is valid, @p false otherwise
*/
bool isValid() const;
//@}
/** //@{
* Change the Statement object. /**
* * \return The subject.
* \param object The new object. */
*/ Node subject() const;
void setObject( const Node &object );
/** /**
* \return The object. * \return The predicate.
*/ */
Node object() const; Node predicate() const;
/** /**
* Change the Statement context. * \return The object.
* */
* \param context The new Context. Node object() const;
*/
void setContext( const Node &context );
/** /**
* \return The Context node. * \return The Context node.
*/ */
Node context() const; Node context() const;
//@}
/** //@{
* A Statement is valid if subject, predicate and object are val /**
id. * Change the Statement subject.
* *
* \return @p true if the Statement is valid, @p false otherwise * \param subject The new subject.
*/ */
bool isValid() const; void setSubject( const Node &subject );
bool operator==( const Statement& other ) const; /**
* Change the Statement predicate.
*
* \param predicate The new predicate.
*/
void setPredicate( const Node &predicate );
/**
* Change the Statement object.
*
* \param object The new object.
*/
void setObject( const Node &object );
private: /**
class Private; * Change the Statement context.
QSharedDataPointer<Private> d; *
}; * \param context The new Context.
*/
void setContext( const Node &context );
//@}
private:
class Private;
QSharedDataPointer<Private> d;
};
} }
/**
* \relates Soprano::Statement
*/
SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Statement& ); SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Statement& );
/**
* \relates Soprano::Statement
*/
SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Stat
ement& );
#endif // SOPRANO_STATEMENT_H #endif // SOPRANO_STATEMENT_H
 End of changes. 21 change blocks. 
94 lines changed or deleted 143 lines changed or added


 statementiterator.h   statementiterator.h 
/* /*
* This file is part of Soprano Project. * This file is part of Soprano Project.
* *
* Copyright (C) 2006 Daniele Galdi <daniele.galdi@gmail.com> * Copyright (C) 2006 Daniele Galdi <daniele.galdi@gmail.com>
* Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Library General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef SOPRANO_STATEMENT_ITERATOR_H #ifndef SOPRANO_STATEMENT_ITERATOR_H
#define SOPRANO_STATEMENT_ITERATOR_H #define SOPRANO_STATEMENT_ITERATOR_H
#include <QtCore/QSharedDataPointer> #include "iterator.h"
#include <soprano/soprano_export.h> #include "statement.h"
#include "soprano_export.h"
#include <QtCore/QList>
namespace Soprano { namespace Soprano {
class Statement; class Node;
class StatementIteratorPrivate; class NodeIterator;
class Statement;
class StatementIteratorBackend;
class SOPRANO_EXPORT StatementIterator /**
{ * \class StatementIterator statementiterator.h Soprano/StatementIterat
public: or
StatementIterator(); *
StatementIterator( StatementIteratorPrivate *sti ); * \brief An iterator that provides a stream of Statements.
*
* The most common use of StatementIterator is through Model::listState
ments().
*
* Many backends do lock the underlying Model during iteration. Thus,
* it is always a good idea to cache the results if they are to be used
* to modify the model to prevent a deadlock:
*
* \code
* Soprano::StatementIterator it = model->listStatements();
* QList<Statement> allStatements = it.allElements();
* Q_FOREACH( Soprano::Statement s, allStatements ) {
* modifyTheModel( model, s );
* }
* \endcode
*
* Iterators have to be closed.
* This can either be achieved by deleting the iterator, finishing it (
next() does return \p false),
* or calling close(). Before that other operations on the Model may bl
ock.
*
* Iterators are not thread-safe. Two threads using the same iterator m
ay result
* in undefined behaviour and even crashes. An iterator needs to be clo
sed by the
* same thread that opened it (except if the iterator contains special
code to handle such
* a situation.)
*
* \warning Be aware that iterators in Soprano are shared objects which
means
* that copies of one iterator object work on the same data.
*
* For further details on %Soprano iterators see Iterator.
*
* \author Daniele Galdi <daniele.galdi@gmail.com><br>Sebastian Trueg <
trueg@kde.org>
*/
class SOPRANO_EXPORT StatementIterator : public Iterator<Statement>
{
public:
/**
* Creates and empty, invalid iterator.
*/
StatementIterator();
StatementIterator( const StatementIterator &sti ); /**
* Create a new StatementIterator instance that uses sti as backend
.
* StatementIterator will take ownership of the backend.
*/
StatementIterator( IteratorBackend<Statement> *sti );
virtual ~StatementIterator(); StatementIterator( const StatementIterator &sti );
StatementIterator& operator=( const StatementIterator& ); virtual ~StatementIterator();
/** StatementIterator& operator=( const StatementIterator& );
*\return true if there is another Statement
*/
bool hasNext() const;
/** /**
*\return the Next Statement * Convenience method which extracts all statements (this does not
*/ include the
Statement next() const; * statements that have already been read from the iterator) from t
he iterator
* and returns them in a list.
*
* Be aware that after calling this method the iterator will be inv
alid.
*
* \return A list of all statements that rest in the iterator.
*/
QList<Statement> allStatements() { return allElements(); }
/** /**
*\return true if the Iterator is valid * Convenience method that creates an iterator over the subject nod
*/ es of the statements
bool isValid() const; * in this iterator.
*
* \warning The new iterator is just a wrapper around this one. Thu
s, changing it will also
* change this one.
*
* \return A wrapper iterator over the subject nodes.
*/
NodeIterator iterateSubjects() const;
/** /**
*\return true if the Iterator is empty * Convenience method that creates an iterator over the predicate n
*/ odes of the statements
bool isEmpty() const; * in this iterator.
*
* \warning The new iterator is just a wrapper around this one. Thu
s, changing it will also
* change this one.
*
* \return A wrapper iterator over the predicate nodes.
*/
NodeIterator iteratePredicates() const;
private: /**
QSharedDataPointer<StatementIteratorPrivate> d; * Convenience method that creates an iterator over the object node
}; s of the statements
* in this iterator.
*
* \warning The new iterator is just a wrapper around this one. Thu
s, changing it will also
* change this one.
*
* \return A wrapper iterator over the object nodes.
*/
NodeIterator iterateObjects() const;
/**
* Convenience method that creates an iterator over the context nod
es of the statements
* in this iterator.
*
* \warning The new iterator is just a wrapper around this one. Thu
s, changing it will also
* change this one.
*
* \return A wrapper iterator over the context nodes.
*/
NodeIterator iterateContexts() const;
};
} }
#endif // SOPRANO_STATEMENT_ITERATOR_H #endif // SOPRANO_STATEMENT_ITERATOR_H
 End of changes. 13 change blocks. 
31 lines changed or deleted 132 lines changed or added


 version.h   version.h 
skipping to change at line 28 skipping to change at line 28
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef _SOPRANO_VERSION_H_ #ifndef _SOPRANO_VERSION_H_
#define _SOPRANO_VERSION_H_ #define _SOPRANO_VERSION_H_
#include "soprano_export.h" #include "soprano_export.h"
/// @brief Soprano version as string at compile time. /// @brief Soprano version as string at compile time.
#define SOPRANO_VERSION_STRING "0.9.0" #define SOPRANO_VERSION_STRING "2.4.61"
/// @brief The major Soprano version number at compile time /// @brief The major Soprano version number at compile time
#define SOPRANO_VERSION_MAJOR 0 #define SOPRANO_VERSION_MAJOR 2
/// @brief The minor Soprano version number at compile time /// @brief The minor Soprano version number at compile time
#define SOPRANO_VERSION_MINOR 9 #define SOPRANO_VERSION_MINOR 4
/// @brief The Soprano release version number at compile time /// @brief The Soprano release version number at compile time
#define SOPRANO_VERSION_RELEASE 0 #define SOPRANO_VERSION_RELEASE 61
/**
* \brief Create a unique number from the major, minor and release number o
f a %Soprano version
*
* This function can be used for preprocessing. For version information at
runtime
* use the version methods in the Soprano namespace.
*/
#define SOPRANO_MAKE_VERSION( a,b,c ) (((a) << 16) | ((b) << 8) | (c))
/**
* \brief %Soprano Version as a unique number at compile time
*
* This macro calculates the %Soprano version into a number. It is mainly u
sed
* through SOPRANO_IS_VERSION in preprocessing. For version information at
runtime
* use the version methods in the Soprano namespace.
*/
#define SOPRANO_VERSION \
SOPRANO_MAKE_VERSION(SOPRANO_VERSION_MAJOR,SOPRANO_VERSION_MINOR,SOPRAN
O_VERSION_RELEASE)
/**
* \brief Check if the %Soprano version matches a certain version or is hig
her
*
* This macro is typically used to compile conditionally a part of code:
* \code
* #if SOPRANO_IS_VERSION(2,1)
* // Code for Soprano 2.1
* #else
* // Code for Soprano 2.0
* #endif
* \endcode
*
* For version information at runtime
* use the version methods in the Soprano namespace.
*/
#define SOPRANO_IS_VERSION(a,b,c) ( SOPRANO_VERSION >= SOPRANO_MAKE_VERSION
(a,b,c) )
namespace Soprano { namespace Soprano {
/** /**
* @brief Returns the major number of Soprano's version, e.g. * @brief Returns the major number of Soprano's version, e.g.
* 1 for Soprano 1.0.2. * 1 for %Soprano 1.0.2.
* @return the major version number at runtime. * @return the major version number at runtime.
*/ */
SOPRANO_EXPORT unsigned int versionMajor(); SOPRANO_EXPORT unsigned int versionMajor();
/** /**
* @brief Returns the minor number of Soprano's version, e.g. * @brief Returns the minor number of Soprano's version, e.g.
* 0 for KDE 1.0.2. * 0 for %Soprano 1.0.2.
* @return the minor version number at runtime. * @return the minor version number at runtime.
*/ */
SOPRANO_EXPORT unsigned int versionMinor(); SOPRANO_EXPORT unsigned int versionMinor();
/** /**
* @brief Returns the release of Soprano's version, e.g. * @brief Returns the release of Soprano's version, e.g.
* 2 for Soprano 1.0.2. * 2 for %Soprano 1.0.2.
* @return the release number at runtime. * @return the release number at runtime.
*/ */
SOPRANO_EXPORT unsigned int versionRelease(); SOPRANO_EXPORT unsigned int versionRelease();
/** /**
* @brief Returns the Soprano version as string, e.g. "1.0.2". * @brief Returns the %Soprano version as string, e.g. "1.0.2".
* *
* On contrary to the macro SOPRANO_VERSION_STRING this function return s * On contrary to the macro SOPRANO_VERSION_STRING this function return s
* the version number of Soprano at runtime. * the version number of Soprano at runtime.
* @return the Soprano version. You can keep the string forever * @return the %Soprano version. You can keep the string forever
*/ */
SOPRANO_EXPORT const char* versionString(); SOPRANO_EXPORT const char* versionString();
} }
#endif #endif
 End of changes. 9 change blocks. 
9 lines changed or deleted 51 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/