• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

syndication/rdf

statement.cpp

00001 /*
00002  * This file is part of the syndication library
00003  *
00004  * Copyright (C) 2006 Frank Osterfeld <osterfeld@kde.org>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; see the file COPYING.LIB.  If not, write to
00018  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "statement.h"
00024 #include "literal.h"
00025 #include "model.h"
00026 #include "property.h"
00027 #include "resource.h"
00028 
00029 #include <QtCore/QString>
00030 
00031 namespace Syndication {
00032 namespace RDF {
00033 
00034 class Statement::StatementPrivate
00035 {
00036     public:
00037     
00038         uint subjectID;
00039         uint predicateID;
00040         uint objectID;
00041         Model model;
00042 
00043         bool operator==(const StatementPrivate& other) const
00044         {
00045             // FIXME: use better check that works also with multiple models
00046             return subjectID == other.subjectID &&
00047                    predicateID == other.predicateID &&
00048                    objectID == other.objectID;
00049         }
00050 };
00051 
00052 Statement::Statement() : d(new StatementPrivate)
00053 {
00054     d->subjectID = 0;
00055     d->predicateID = 0;
00056     d->objectID = 0;
00057 }
00058 
00059 Statement::Statement(const Statement& other)
00060 {
00061     d = other.d;
00062 }
00063 
00064 Statement::Statement(ResourcePtr subject, PropertyPtr predicate, 
00065                         NodePtr object) : d(new StatementPrivate)
00066 {
00067     d->model = subject->model();
00068     d->subjectID = subject->id();
00069     d->predicateID = predicate->id();
00070     d->objectID = object->id();
00071 }
00072 
00073 Statement::~Statement()
00074 {
00075 }
00076 
00077 Statement& Statement::operator=(const Statement& other)
00078 {
00079     d = other.d;
00080     return *this;
00081 }
00082 
00083 bool Statement::operator==(const Statement& other) const
00084 {
00085     if (!d || !other.d)
00086         return d == other.d;
00087 
00088     return *d == *(other.d);
00089 }
00090 
00091 bool Statement::isNull() const
00092 {
00093     return d->subjectID == 0;
00094 }
00095 
00096 ResourcePtr Statement::subject() const
00097 {
00098     return d->model.resourceByID(d->subjectID);
00099 }
00100 
00101 PropertyPtr Statement::predicate() const
00102 {
00103     return d->model.propertyByID(d->predicateID);
00104 }
00105 
00106 NodePtr Statement::object() const
00107 {
00108     return d->model.nodeByID(d->objectID);
00109 }
00110 
00111 ResourcePtr Statement::asResource() const
00112 {
00113     if (isNull() || !d->model.nodeByID(d->objectID)->isResource())
00114         return ResourcePtr(new Resource);
00115 
00116     return d->model.resourceByID(d->objectID);
00117 }
00118 
00119 QString Statement::asString() const
00120 {
00121     if (isNull())
00122         return QString();
00123 
00124     return d->model.nodeByID(d->objectID)->text();
00125 }
00126 
00127 } // namespace RDF
00128 } // namespace Syndication

syndication/rdf

Skip menu "syndication/rdf"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.6
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal