Syndication

literal.h
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#ifndef SYNDICATION_RDF_LITERAL_H
9#define SYNDICATION_RDF_LITERAL_H
10
11#include <QString>
12#include <syndication/rdf/node.h>
13
14namespace Syndication
15{
16namespace RDF
17{
18class Literal;
19
20//@cond PRIVATE
21typedef QSharedPointer<Literal> LiteralPtr;
22//@endcond
23
24/**
25 * a node type representing simple string values. Literals can
26 * be object of statement, but neither subject nor predicate.
27 */
28class Literal : public Node
29{
30public:
31 /**
32 * creates a null literal. text() will return a null string.
33 */
34 Literal();
35
36 /**
37 * copies a literal node
38 *
39 * @param other the literal node to copy
40 */
41 Literal(const Literal &other);
42
43 /**
44 * creates a new literal node with a given text
45 *
46 * @param text the literal string
47 */
48 explicit Literal(const QString &text);
49
50 /**
51 * destructor
52 */
53 ~Literal() override;
54
55 /**
56 * assigns another literal
57 *
58 * @param other the literal to assign
59 */
60 virtual Literal &operator=(const Literal &other);
61
62 /**
63 * two literal nodes are equal iff their text _and_ ID's
64 * are equal.
65 */
66 bool operator==(const Literal &other) const;
67
68 /**
69 * clones the literal node.
70 */
71 Literal *clone() const override;
72
73 /**
74 * Used by visitors for double dispatch. See NodeVisitor
75 * for more information.
76 * @param visitor the visitor calling the method
77 * @param ptr a shared pointer object for this node
78 */
79 void accept(NodeVisitor *visitor, NodePtr ptr) override;
80
81 /**
82 * returns whether this node is a null node
83 */
84 bool isNull() const override;
85
86 /**
87 * the identifier of this node. the ID is unique per model
88 * and set by the associated model at creation time.
89 */
90 unsigned int id() const override;
91
92 /**
93 * returns false, as a literal is not a resource
94 */
95 bool isResource() const override;
96 /**
97 * returns false, as a literal is not a property
98 */
99 bool isProperty() const override;
100
101 /**
102 * returns true for literals
103 */
104 bool isLiteral() const override;
105
106 /**
107 * returns false, literals are not anonymous resources
108 */
109 bool isAnon() const override;
110
111 /**
112 * returns false, literals are not sequences
113 */
114 bool isSequence() const override;
115
116 /**
117 * implicit conversion to string. returns text()
118 */
119 virtual operator QString() const;
120
121 /**
122 * the string value of the literal
123 */
124 QString text() const override;
125
126 /**
127 * used in Model
128 * @internal
129 */
130 void setModel(const Model &model) override;
131
132 /**
133 * used in Model
134 * @internal
135 */
136 void setId(unsigned int id) override;
137
138private:
139 class LiteralPrivate;
142};
143
144} // namespace RDF
145} // namespace Syndication
146
147#endif // SYNDICATION_RDF_LITERAL_H
a node type representing simple string values.
Definition literal.h:29
Literal()
creates a null literal.
Definition literal.cpp:27
virtual Literal & operator=(const Literal &other)
assigns another literal
Definition literal.cpp:62
bool isNull() const override
returns whether this node is a null node
Definition literal.cpp:77
bool isSequence() const override
returns false, literals are not sequences
Definition literal.cpp:107
~Literal() override
destructor
Definition literal.cpp:58
bool isLiteral() const override
returns true for literals
Definition literal.cpp:97
void accept(NodeVisitor *visitor, NodePtr ptr) override
Used by visitors for double dispatch.
Definition literal.cpp:43
bool isAnon() const override
returns false, literals are not anonymous resources
Definition literal.cpp:102
QString text() const override
the string value of the literal
Definition literal.cpp:112
bool isProperty() const override
returns false, as a literal is not a property
Definition literal.cpp:92
void setId(unsigned int id) override
used in Model
Definition literal.cpp:126
bool operator==(const Literal &other) const
two literal nodes are equal iff their text and ID's are equal.
Definition literal.cpp:68
void setModel(const Model &model) override
used in Model
Definition literal.cpp:122
Literal * clone() const override
clones the literal node.
Definition literal.cpp:38
unsigned int id() const override
the identifier of this node.
Definition literal.cpp:82
bool isResource() const override
returns false, as a literal is not a resource
Definition literal.cpp:87
An RDF model, a set of RDF statements.
Definition model.h:37
Visitor interface, following the Visitor design pattern.
Definition nodevisitor.h:42
an RDF node, abstract baseclass for all RDF node types, like resources and literals
Definition node.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:57:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.