Syndication

literal.cpp
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2006 Frank Osterfeld <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #include "literal.h"
9 #include "nodevisitor.h"
10 
11 namespace Syndication
12 {
13 namespace RDF
14 {
15 class SYNDICATION_NO_EXPORT Literal::LiteralPrivate
16 {
17 public:
18  QString text;
19  unsigned int id;
20 
21  bool operator==(const LiteralPrivate &other) const
22  {
23  return text == other.text;
24  }
25 };
26 
27 Literal::Literal()
28  : d()
29 {
30 }
31 
32 Literal::Literal(const Literal &other)
33  : Node(other)
34 {
35  d = other.d;
36 }
37 
38 Literal *Literal::clone() const
39 {
40  return new Literal(*this);
41 }
42 
43 void Literal::accept(NodeVisitor *visitor, NodePtr ptr)
44 {
45  LiteralPtr lptr = ptr.staticCast<Syndication::RDF::Literal>();
46  if (!visitor->visitLiteral(lptr)) {
47  Node::accept(visitor, ptr);
48  }
49 }
50 
51 Literal::Literal(const QString &text)
52  : d(new LiteralPrivate)
53 {
54  d->text = text;
55  d->id = idCounter++;
56 }
57 
58 Literal::~Literal()
59 {
60 }
61 
62 Literal &Literal::operator=(const Literal &other)
63 {
64  d = other.d;
65  return *this;
66 }
67 
68 bool Literal::operator==(const Node &other) const
69 {
70  const Literal *o2 = dynamic_cast<const Literal *>(&other);
71  if (!o2) {
72  return false;
73  }
74 
75  if (!d || !o2->d) {
76  return d == o2->d;
77  }
78 
79  return *d == *(o2->d);
80 }
81 
82 bool Literal::isNull() const
83 {
84  return !d;
85 }
86 
87 unsigned int Literal::id() const
88 {
89  return d ? d->id : 0;
90 }
91 
92 bool Literal::isResource() const
93 {
94  return false;
95 }
96 
97 bool Literal::isProperty() const
98 {
99  return false;
100 }
101 
102 bool Literal::isLiteral() const
103 {
104  return true;
105 }
106 
107 bool Literal::isAnon() const
108 {
109  return false;
110 }
111 
112 bool Literal::isSequence() const
113 {
114  return false;
115 }
116 
117 QString Literal::text() const
118 {
119  return d ? d->text : QString();
120 }
121 
122 Literal::operator QString() const
123 {
124  return d ? d->text : QString();
125 }
126 
127 void Literal::setModel(const Model & /*model*/)
128 {
129 }
130 
131 void Literal::setId(unsigned int id)
132 {
133  d->id = id;
134 }
135 
136 } // namespace RDF
137 } // namespace Syndication
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Jun 6 2023 03:56:27 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.