syndication/rdf
literal.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 "literal.h" 00024 #include "nodevisitor.h" 00025 00026 #include <QtCore/QString> 00027 00028 namespace Syndication { 00029 namespace RDF { 00030 00031 class Literal::LiteralPrivate 00032 { 00033 public: 00034 00035 QString text; 00036 unsigned int id; 00037 00038 bool operator==(const LiteralPrivate& other) const 00039 { 00040 return text == other.text; 00041 } 00042 }; 00043 00044 Literal::Literal() : d() 00045 { 00046 } 00047 00048 Literal::Literal(const Literal& other) : Node(other) 00049 { 00050 d = other.d; 00051 } 00052 00053 Literal* Literal::clone() const 00054 { 00055 return new Literal(*this); 00056 } 00057 00058 void Literal::accept(NodeVisitor* visitor, NodePtr ptr) 00059 { 00060 LiteralPtr lptr = boost::static_pointer_cast<Syndication::RDF::Literal>(ptr); 00061 if (!visitor->visitLiteral(lptr)) 00062 Node::accept(visitor, ptr); 00063 } 00064 00065 Literal::Literal(const QString& text) : d(new LiteralPrivate) 00066 { 00067 d->text = text; 00068 d->id = idCounter++; 00069 } 00070 00071 Literal::~Literal() 00072 { 00073 } 00074 00075 Literal& Literal::operator=(const Literal& other) 00076 { 00077 d = other.d; 00078 return *this; 00079 } 00080 00081 bool Literal::operator==(const Node& other) const 00082 { 00083 const Literal* o2 = dynamic_cast<const Literal*>(&other); 00084 if (!o2) 00085 return false; 00086 00087 if (!d || !o2->d) 00088 return d == o2->d; 00089 00090 return *d == *(o2->d); 00091 } 00092 00093 bool Literal::isNull() const 00094 { 00095 return !d; 00096 } 00097 00098 unsigned int Literal::id() const 00099 { 00100 return d ? d->id : 0; 00101 } 00102 00103 bool Literal::isResource() const 00104 { 00105 return false; 00106 } 00107 00108 bool Literal::isProperty() const 00109 { 00110 return false; 00111 } 00112 00113 bool Literal::isLiteral() const 00114 { 00115 return true; 00116 } 00117 00118 bool Literal::isAnon() const 00119 { 00120 return false; 00121 } 00122 00123 bool Literal::isSequence() const 00124 { 00125 return false; 00126 } 00127 00128 QString Literal::text() const 00129 { 00130 return d ? d->text : QString(); 00131 } 00132 00133 Literal::operator QString() const 00134 { 00135 return d ? d->text : QString(); 00136 } 00137 00138 void Literal::setModel(const Model& /*model*/) 00139 { 00140 } 00141 00142 void Literal::setId(unsigned int id) 00143 { 00144 d->id = id; 00145 } 00146 00147 } // namespace RDF 00148 } // namespace Syndication
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:47:16 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:47:16 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.