00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SOPRANO_NODE_H
00024 #define SOPRANO_NODE_H
00025
00026 #include <QtCore/QUrl>
00027 #include <QtCore/QSharedDataPointer>
00028 #include <QtCore/QTextStream>
00029
00030 #include "soprano_export.h"
00031 #include "literalvalue.h"
00032 #include "languagetag.h"
00033 #include "sopranomacros.h"
00034
00035 namespace Soprano
00036 {
00053 class SOPRANO_EXPORT Node
00054 {
00055 public:
00056 enum Type {
00057 EmptyNode = 0,
00058 ResourceNode = 1,
00059 LiteralNode = 2,
00060 BlankNode = 3
00061 };
00062
00073 Node();
00074
00075
00076
00085 Node( const QUrl &uri );
00086
00094 explicit Node( const QString& id );
00095
00106 Node( const LiteralValue& value );
00107
00120 SOPRANO_CONSTRUCTOR_DEPRECATED Node( const LiteralValue& value,
00121 const QString& language );
00122
00126 Node( const Node &other );
00127
00128 ~Node();
00130
00135 Node& operator=( const Node& other );
00136
00140 Node& operator=( const QUrl& resource );
00141
00145 Node& operator=( const LiteralValue& literal );
00146
00151 bool operator==( const Node& other ) const;
00152
00157 bool operator!=( const Node& other ) const;
00158
00164 bool operator==( const QUrl& uri ) const;
00165
00171 bool operator==( const LiteralValue& other ) const;
00172
00190 bool matches( const Node& other ) const;
00192
00200 Type type() const;
00201
00205 bool isEmpty() const;
00206
00210 bool isValid() const ;
00211
00215 bool isLiteral() const;
00216
00220 bool isResource() const;
00221
00225 bool isBlank() const;
00227
00236 QUrl uri() const;
00238
00248 QString identifier() const;
00250
00259 LiteralValue literal() const;
00260
00266 QUrl dataType() const;
00267
00279 QString language() const;
00281
00294 QString toString() const;
00295
00314 QString toN3() const;
00316
00324 static Node createEmptyNode();
00325
00336 static Node createResourceNode( const QUrl& uri );
00337
00352 static Node createBlankNode( const QString& id );
00353
00367 static Node createLiteralNode( const LiteralValue& value );
00368
00384 static SOPRANO_DEPRECATED Node createLiteralNode( const LiteralValue& value, const QString& language );
00385
00401 static QString resourceToN3( const QUrl& resource );
00402
00418 static QString blankToN3( const QString& blank );
00419
00436 static QString literalToN3( const LiteralValue& literal );
00437
00438 private:
00439 class NodeData;
00440 class ResourceNodeData;
00441 class BNodeData;
00442 class LiteralNodeData;
00443 QSharedDataPointer<NodeData> d;
00444 };
00445
00449 SOPRANO_EXPORT uint qHash( const Node& node );
00450 }
00451
00455 SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Node& );
00456
00465 SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Node& );
00466
00467 #if QT_VERSION < 0x040700
00468 SOPRANO_EXPORT uint qHash( const QUrl& url );
00469 #endif
00470
00471 #endif // SOPRANO_NODE_H