Go to the documentation of this file.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
00444 enum N3ParserFlag {
00448 NoFlags = 0x0,
00449
00456 StrictLiteralTypes = 0x1,
00457
00463 StrictUris = 0x2,
00464
00468 IgnorePrefixes = 0x4
00469 };
00470 Q_DECLARE_FLAGS( N3ParserFlags, N3ParserFlag )
00471
00472
00484 static Node fromN3( const QString& n3, N3ParserFlags flags = NoFlags );
00485
00498 static Node fromN3Stream( QTextStream& stream, N3ParserFlags flags = NoFlags );
00499
00500 private:
00501 class NodeData;
00502 class ResourceNodeData;
00503 class BNodeData;
00504 class LiteralNodeData;
00505 QSharedDataPointer<NodeData> d;
00506 };
00507
00511 SOPRANO_EXPORT uint qHash( const Node& node );
00512 }
00513
00517 SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Node& );
00518
00527 SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Node& );
00528
00536 SOPRANO_EXPORT QTextStream& operator>>( QTextStream& s, Soprano::Node& );
00537
00538 #if QT_VERSION < 0x040700
00539 SOPRANO_EXPORT uint qHash( const QUrl& url );
00540 #endif
00541
00542 Q_DECLARE_OPERATORS_FOR_FLAGS( Soprano::Node::N3ParserFlags )
00543
00544 #endif // SOPRANO_NODE_H