Soprano  2.9.4
node.h
Go to the documentation of this file.
1 /*
2  * This file is part of Soprano Project.
3  *
4  * Copyright (C) 2006-2007 Daniele Galdi <daniele.galdi@gmail.com>
5  * Copyright (C) 2007-2009 Sebastian Trueg <trueg@kde.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef SOPRANO_NODE_H
24 #define SOPRANO_NODE_H
25 
26 #include <QtCore/QUrl>
27 #include <QtCore/QSharedDataPointer>
28 #include <QtCore/QTextStream>
29 
30 #include "soprano_export.h"
31 #include "literalvalue.h"
32 #include "languagetag.h"
33 #include "sopranomacros.h"
34 
35 namespace Soprano
36 {
54  {
55  public:
56  enum Type {
57  EmptyNode = 0,
58  ResourceNode = 1,
59  LiteralNode = 2,
60  BlankNode = 3
61  };
62 
73  Node();
74 
75  // This constructor is non-explicit for a reason: it makes creating
76  // Statements much much easier and more readable
85  Node( const QUrl &uri );
86 
94  explicit Node( const QString& id );
95 
107 
121  const QString& language );
122 
126  Node( const Node &other );
127 
128  ~Node();
130 
135  Node& operator=( const Node& other );
136 
140  Node& operator=( const QUrl& resource );
141 
145  Node& operator=( const LiteralValue& literal );
146 
151  bool operator==( const Node& other ) const;
152 
157  bool operator!=( const Node& other ) const;
158 
164  bool operator==( const QUrl& uri ) const;
165 
171  bool operator==( const LiteralValue& other ) const;
172 
190  bool matches( const Node& other ) const;
192 
200  Type type() const;
201 
205  bool isEmpty() const;
206 
210  bool isValid() const ;
211 
215  bool isLiteral() const;
216 
220  bool isResource() const;
221 
225  bool isBlank() const;
227 
236  QUrl uri() const;
238 
250 
260 
266  QUrl dataType() const;
267 
279  QString language() const;
281 
294  QString toString() const;
295 
314  QString toN3() const;
316 
325 
336  static Node createResourceNode( const QUrl& uri );
337 
352  static Node createBlankNode( const QString& id );
353 
368 
384  static SOPRANO_DEPRECATED Node createLiteralNode( const LiteralValue& value, const QString& language );
385 
401  static QString resourceToN3( const QUrl& resource );
402 
418  static QString blankToN3( const QString& blank );
419 
436  static QString literalToN3( const LiteralValue& literal );
437 
448  NoFlags = 0x0,
449 
456  StrictLiteralTypes = 0x1,
457 
463  StrictUris = 0x2,
464 
468  IgnorePrefixes = 0x4
469  };
470  Q_DECLARE_FLAGS( N3ParserFlags, N3ParserFlag )
471 
472 
484  static Node fromN3( const QString& n3, N3ParserFlags flags = NoFlags );
485 
498  static Node fromN3Stream( QTextStream& stream, N3ParserFlags flags = NoFlags );
499 
500  private:
501  class NodeData;
502  class ResourceNodeData;
503  class BNodeData;
504  class LiteralNodeData;
505  QSharedDataPointer<NodeData> d;
506  };
507 
511  SOPRANO_EXPORT uint qHash( const Node& node );
512 }
513 
517 SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Node& );
518 
527 SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Node& );
528 
536 SOPRANO_EXPORT QTextStream& operator>>( QTextStream& s, Soprano::Node& );
537 
538 #if QT_VERSION < 0x040700
539 SOPRANO_EXPORT uint qHash( const QUrl& url );
540 #endif
541 
542 Q_DECLARE_OPERATORS_FOR_FLAGS( Soprano::Node::N3ParserFlags )
543 
544 #endif // SOPRANO_NODE_H
Soprano::Node::operator!=
bool operator!=(const Node &other) const
soprano_export.h
Soprano::Node::matches
bool matches(const Node &other) const
Soprano::Node::isEmpty
bool isEmpty() const
Soprano::Node::operator==
bool operator==(const LiteralValue &other) const
QUrl
Soprano::Node::type
Type type() const
Soprano::Node::isValid
bool isValid() const
Soprano::Node::Node
Node()
Soprano::Node::operator==
bool operator==(const QUrl &uri) const
languagetag.h
Soprano::Node::createResourceNode
static Node createResourceNode(const QUrl &uri)
Soprano::Node::Type
Type
Definition: node.h:56
QSharedDataPointer
Soprano::LiteralValue
Represents a literal value of an RDF Node.
Definition: literalvalue.h:67
SOPRANO_EXPORT
#define SOPRANO_EXPORT
Definition: soprano_export.h:37
literalvalue.h
Soprano::Vocabulary::RDF::value
SOPRANO_EXPORT QUrl value()
Soprano::Node::toN3
QString toN3() const
Soprano::Node::Node
Node(const QUrl &uri)
Soprano::Node::dataType
QUrl dataType() const
Soprano::Node::uri
QUrl uri() const
Soprano::Vocabulary::Xesam::url
SOPRANO_EXPORT QUrl url()
Soprano::Node::createBlankNode
static Node createBlankNode(const QString &id)
Soprano::Node::operator=
Node & operator=(const LiteralValue &literal)
Soprano::Node::Node
SOPRANO_CONSTRUCTOR_DEPRECATED Node(const LiteralValue &value, const QString &language)
QTextStream
SOPRANO_CONSTRUCTOR_DEPRECATED
#define SOPRANO_CONSTRUCTOR_DEPRECATED
Definition: sopranomacros.h:51
Soprano::Node::literalToN3
static QString literalToN3(const LiteralValue &literal)
Soprano::Node::operator=
Node & operator=(const Node &other)
Soprano::Node::createLiteralNode
static Node createLiteralNode(const LiteralValue &value)
Soprano::Node::operator==
bool operator==(const Node &other) const
Soprano::Node::resourceToN3
static QString resourceToN3(const QUrl &resource)
Soprano::qHash
SOPRANO_EXPORT uint qHash(const LanguageTag &node)
Soprano::Node::identifier
QString identifier() const
Soprano::Node::Node
Node(const Node &other)
Soprano::Node::~Node
~Node()
Soprano::Node::createEmptyNode
static Node createEmptyNode()
Soprano::Node::Node
Node(const QString &id)
Soprano::Node::language
QString language() const
Soprano::Node::operator=
Node & operator=(const QUrl &resource)
Soprano::Node::isResource
bool isResource() const
Soprano::Node::literal
LiteralValue literal() const
Soprano::Node::blankToN3
static QString blankToN3(const QString &blank)
Soprano::Node::Node
Node(const LiteralValue &value)
Soprano::Node::isLiteral
bool isLiteral() const
Soprano
Definition: backend.h:36
Soprano::Node::isBlank
bool isBlank() const
sopranomacros.h
Soprano::Node::N3ParserFlag
N3ParserFlag
Definition: node.h:444
Soprano::Node
A Node represents one RDF resource.
Definition: node.h:54
Soprano::Node::createLiteralNode
static SOPRANO_DEPRECATED Node createLiteralNode(const LiteralValue &value, const QString &language)
Soprano::Node::toString
QString toString() const
QString
Soprano::Vocabulary::Xesam::language
SOPRANO_EXPORT QUrl language()