Syndication

sequence.cpp
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 "sequence.h"
9#include "node.h"
10#include "nodevisitor.h"
11
12#include <QList>
13#include <QString>
14
15namespace Syndication
16{
17namespace RDF
18{
19class SYNDICATION_NO_EXPORT Sequence::SequencePrivate
20{
21public:
22 QList<NodePtr> items;
23};
24
26 : Resource()
27 , d()
28{
29}
30
32 : Resource(uri)
33 , d(new SequencePrivate)
34{
35}
36
38 : Resource(other)
39{
40 *this = other;
41}
42
46void Sequence::accept(NodeVisitor *visitor, NodePtr ptr)
47{
48 SequencePtr sptr = ptr.staticCast<Sequence>();
49 if (!visitor->visitSequence(sptr)) {
50 Resource::accept(visitor, ptr);
51 }
52}
53
55{
56 return new Sequence(*this);
57}
58
60{
62 d = other.d;
63 return *this;
64}
65
66void Sequence::append(NodePtr node)
67{
68 if (d) {
69 d->items.append(node);
70 }
71}
72
74{
75 return d ? d->items : QList<NodePtr>();
76}
77
79{
80 return true;
81}
82
83} // namespace RDF
84} // namespace Syndication
Visitor interface, following the Visitor design pattern.
Definition nodevisitor.h:42
virtual bool visitSequence(SequencePtr seq)
reimplement this method to handle sequences.
Resources are the entities in the RDF graph.
Definition resource.h:37
void accept(NodeVisitor *visitor, NodePtr ptr) override
Used by visitors for double dispatch.
Definition resource.cpp:128
Resource & operator=(const Resource &other)
assigns a resource
Definition resource.cpp:71
Sequence container, a sequence contains an ordered list of RDF nodes.
Definition sequence.h:32
virtual QList< NodePtr > items() const
the list of the list items in the sequence, in the specified order
Definition sequence.cpp:73
Sequence * clone() const override
creates a copy of the sequence
Definition sequence.cpp:54
virtual void append(NodePtr node)
appends a node at the end of the sequence
Definition sequence.cpp:66
Sequence()
creates a null sequence
Definition sequence.cpp:25
virtual Sequence & operator=(const Sequence &other)
assigns another sequence
Definition sequence.cpp:59
void accept(NodeVisitor *visitor, NodePtr ptr) override
Used by visitors for double dispatch.
Definition sequence.cpp:46
~Sequence() override
destructor
Definition sequence.cpp:43
bool isSequence() const override
returns true
Definition sequence.cpp:78
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.