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;
140 typedef QSharedPointer<LiteralPrivate> LiteralPrivatePtr;
141 LiteralPrivatePtr d;
142};
143
144} // namespace RDF
145} // namespace Syndication
146
147#endif // SYNDICATION_RDF_LITERAL_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:15 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.