1/*
2 This file is part of the syndication library
3 SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "literal.h"
9#include "nodevisitor.h"
10
11namespace Syndication
12{
13namespace RDF
14{
15class SYNDICATION_NO_EXPORT Literal::LiteralPrivate
16{
17public:
18 QString text;
19 unsigned int id;
20
21 bool operator==(const LiteralPrivate &other) const
22 {
23 return text == other.text;
24 }
25};
26
27Literal::Literal()
28 : d()
29{
30}
31
32Literal::Literal(const Literal &other)
33 : Node(other)
34{
35 d = other.d;
36}
37
38Literal *Literal::clone() const
39{
40 return new Literal(*this);
41}
42
43void 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
51Literal::Literal(const QString &text)
52 : d(new LiteralPrivate)
53{
54 d->text = text;
55 d->id = idCounter++;
56}
57
58Literal::~Literal()
59{
60}
61
62Literal &Literal::operator=(const Literal &other)
63{
64 d = other.d;
65 return *this;
66}
67
68bool Literal::operator==(const Literal &other) const
69{
70 if (!d || !other.d) {
71 return d == other.d;
72 }
73
74 return *d == *(other.d);
75}
76
77bool Literal::isNull() const
78{
79 return !d;
80}
81
82unsigned int Literal::id() const
83{
84 return d ? d->id : 0;
85}
86
87bool Literal::isResource() const
88{
89 return false;
90}
91
92bool Literal::isProperty() const
93{
94 return false;
95}
96
97bool Literal::isLiteral() const
98{
99 return true;
100}
101
102bool Literal::isAnon() const
103{
104 return false;
105}
106
107bool Literal::isSequence() const
108{
109 return false;
110}
111
112QString Literal::text() const
113{
114 return d ? d->text : QString();
115}
116
117Literal::operator QString() const
118{
119 return d ? d->text : QString();
120}
121
122void Literal::setModel(const Model & /*model*/)
123{
124}
125
126void Literal::setId(unsigned int id)
127{
128 d->id = id;
129}
130
131} // namespace RDF
132} // namespace Syndication
133

source code of syndication/src/rdf/literal.cpp