soprano/node.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of Soprano Project.
00003  *
00004  * Copyright (C) 2006-2007 Daniele Galdi <daniele.galdi@gmail.com>
00005  * Copyright (C) 2007 Sebastian Trueg <trueg@kde.org>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public License
00018  * along with this library; see the file COPYING.LIB.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  * Boston, MA 02110-1301, USA.
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 
00033 namespace Soprano
00034 {
00042     class SOPRANO_EXPORT Node
00043     {
00044     public:
00045         enum Type {
00046             EmptyNode    = 0, 
00047             ResourceNode = 1, 
00048             LiteralNode  = 2, 
00049             BlankNode    = 3  
00050         };
00051 
00062         Node();
00063 
00064         // This constructor is non-explicit for a reason: it makes creating
00065         // Statements much much easier and more readable
00074         Node( const QUrl &uri );
00075 
00083         explicit Node( const QString& id );
00084 
00094         Node( const LiteralValue& value,
00095               const QString& language = QString() );
00096 
00097         Node( const Node &other );
00098 
00099         ~Node();
00101 
00106         Node& operator=( const Node& other );
00107 
00111         Node& operator=( const QUrl& resource );
00112 
00113         Node& operator=( const LiteralValue& literal );
00114 
00115         bool operator==( const Node& other ) const;
00116         bool operator!=( const Node& other ) const;
00117 
00118         bool operator==( const QUrl& other ) const;
00119         bool operator==( const LiteralValue& other ) const;
00120 
00128         bool matches( const Node& other ) const;
00130 
00138         Type type() const;
00139 
00143         bool isEmpty() const;
00144 
00148         bool isValid() const ;
00149 
00153         bool isLiteral() const;
00154 
00158         bool isResource() const;
00159 
00163         bool isBlank() const;
00165 
00174         QUrl uri() const;
00176 
00186         QString identifier() const;
00188 
00197         LiteralValue literal() const;
00198 
00204         QUrl dataType() const;
00205 
00214         QString language() const;
00216 
00218 
00221         QString toString() const;
00223         
00231         static Node createEmptyNode();
00232 
00243         static Node createResourceNode( const QUrl& uri );
00244 
00259         static Node createBlankNode( const QString& id );
00260 
00273         static Node createLiteralNode( const LiteralValue& value, const QString& language );
00274 
00275     private:
00276         class NodeData;
00277         class ResourceNodeData;
00278         class BNodeData;
00279         class LiteralNodeData;
00280         QSharedDataPointer<NodeData> d;
00281     };
00282 }
00283 
00284 SOPRANO_EXPORT QDebug operator<<( QDebug s, const Soprano::Node& );
00285 
00290 SOPRANO_EXPORT QTextStream& operator<<( QTextStream& s, const Soprano::Node& );
00291 
00292 #endif // SOPRANO_NODE_H

Generated on Fri Mar 7 19:00:11 2008 for Soprano by  doxygen 1.5.4