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 "rssvocab.h" |
9 | #include "property.h" |
10 | |
11 | #include <QCoreApplication> |
12 | #include <QString> |
13 | |
14 | namespace Syndication |
15 | { |
16 | namespace RDF |
17 | { |
18 | class SYNDICATION_NO_EXPORT RSSVocab::RSSVocabPrivate |
19 | { |
20 | public: |
21 | QString namespaceURI; |
22 | PropertyPtr title; |
23 | PropertyPtr link; |
24 | PropertyPtr description; |
25 | PropertyPtr name; |
26 | PropertyPtr url; |
27 | PropertyPtr image; |
28 | ResourcePtr channel; |
29 | ResourcePtr item; |
30 | PropertyPtr items; |
31 | PropertyPtr textinput; |
32 | |
33 | static RSSVocab *sSelf; |
34 | static void cleanupRSSVocab() |
35 | { |
36 | delete sSelf; |
37 | sSelf = nullptr; |
38 | } |
39 | }; |
40 | RSSVocab *RSSVocab::RSSVocabPrivate::sSelf = nullptr; |
41 | |
42 | RSSVocab::RSSVocab() |
43 | : d(new RSSVocabPrivate) |
44 | { |
45 | QString ns = QStringLiteral("http://purl.org/rss/1.0/"); |
46 | |
47 | d->namespaceURI = ns; |
48 | |
49 | d->title = PropertyPtr(new Property(ns + QLatin1String("title"))); |
50 | d->link = PropertyPtr(new Property(ns + QLatin1String("link"))); |
51 | d->description = PropertyPtr(new Property(ns + QLatin1String("description"))); |
52 | d->name = PropertyPtr(new Property(ns + QLatin1String("name"))); |
53 | d->url = PropertyPtr(new Property(ns + QLatin1String("url"))); |
54 | d->image = PropertyPtr(new Property(ns + QLatin1String("image"))); |
55 | d->textinput = PropertyPtr(new Property(ns + QLatin1String("textinput"))); |
56 | d->items = PropertyPtr(new Property(ns + QLatin1String("items"))); |
57 | d->channel = ResourcePtr(new Resource(ns + QLatin1String("channel"))); |
58 | d->item = ResourcePtr(new Resource(ns + QLatin1String("item"))); |
59 | } |
60 | |
61 | RSSVocab::~RSSVocab() = default; |
62 | |
63 | RSSVocab *RSSVocab::self() |
64 | { |
65 | static RSSVocabPrivate p; |
66 | if (!p.sSelf) { |
67 | p.sSelf = new RSSVocab; |
68 | qAddPostRoutine(RSSVocabPrivate::cleanupRSSVocab); |
69 | } |
70 | return p.sSelf; |
71 | } |
72 | |
73 | const QString &RSSVocab::namespaceURI() const |
74 | { |
75 | return d->namespaceURI; |
76 | } |
77 | |
78 | PropertyPtr RSSVocab::title() const |
79 | { |
80 | return d->title; |
81 | } |
82 | |
83 | PropertyPtr RSSVocab::description() const |
84 | { |
85 | return d->description; |
86 | } |
87 | |
88 | PropertyPtr RSSVocab::link() const |
89 | { |
90 | return d->link; |
91 | } |
92 | |
93 | PropertyPtr RSSVocab::name() const |
94 | { |
95 | return d->name; |
96 | } |
97 | |
98 | PropertyPtr RSSVocab::url() const |
99 | { |
100 | return d->url; |
101 | } |
102 | |
103 | PropertyPtr RSSVocab::image() const |
104 | { |
105 | return d->image; |
106 | } |
107 | |
108 | PropertyPtr RSSVocab::textinput() const |
109 | { |
110 | return d->textinput; |
111 | } |
112 | |
113 | PropertyPtr RSSVocab::items() const |
114 | { |
115 | return d->items; |
116 | } |
117 | |
118 | ResourcePtr RSSVocab::item() const |
119 | { |
120 | return d->item; |
121 | } |
122 | |
123 | ResourcePtr RSSVocab::channel() const |
124 | { |
125 | return d->channel; |
126 | } |
127 | |
128 | class SYNDICATION_NO_EXPORT RSS09Vocab::RSS09VocabPrivate |
129 | { |
130 | public: |
131 | QString namespaceURI; |
132 | PropertyPtr title; |
133 | PropertyPtr link; |
134 | PropertyPtr description; |
135 | PropertyPtr name; |
136 | PropertyPtr url; |
137 | PropertyPtr image; |
138 | ResourcePtr channel; |
139 | ResourcePtr item; |
140 | PropertyPtr textinput; |
141 | QStringList properties; |
142 | QStringList classes; |
143 | |
144 | static RSS09Vocab *sSelf; |
145 | static void cleanupRSS09Vocab() |
146 | { |
147 | delete sSelf; |
148 | sSelf = nullptr; |
149 | } |
150 | }; |
151 | RSS09Vocab *RSS09Vocab::RSS09VocabPrivate::sSelf = nullptr; |
152 | |
153 | RSS09Vocab::RSS09Vocab() |
154 | : d(new RSS09VocabPrivate) |
155 | { |
156 | QString ns = QStringLiteral("http://my.netscape.com/rdf/simple/0.9/"); |
157 | |
158 | d->namespaceURI = ns; |
159 | |
160 | d->title = PropertyPtr(new Property(ns + QLatin1String("title"))); |
161 | d->properties.append(t: d->title->uri()); |
162 | d->link = PropertyPtr(new Property(ns + QLatin1String("link"))); |
163 | d->properties.append(t: d->link->uri()); |
164 | d->description = PropertyPtr(new Property(ns + QLatin1String("description"))); |
165 | d->properties.append(t: d->description->uri()); |
166 | d->name = PropertyPtr(new Property(ns + QLatin1String("name"))); |
167 | d->properties.append(t: d->name->uri()); |
168 | d->url = PropertyPtr(new Property(ns + QLatin1String("url"))); |
169 | d->properties.append(t: d->url->uri()); |
170 | d->image = PropertyPtr(new Property(ns + QLatin1String("image"))); |
171 | d->properties.append(t: d->image->uri()); |
172 | d->textinput = PropertyPtr(new Property(ns + QLatin1String("textinput"))); |
173 | d->properties.append(t: d->textinput->uri()); |
174 | d->item = ResourcePtr(new Resource(ns + QLatin1String("item"))); |
175 | d->classes.append(t: d->item->uri()); |
176 | d->channel = ResourcePtr(new Resource(ns + QLatin1String("channel"))); |
177 | d->classes.append(t: d->channel->uri()); |
178 | } |
179 | |
180 | RSS09Vocab::~RSS09Vocab() = default; |
181 | |
182 | RSS09Vocab *RSS09Vocab::self() |
183 | { |
184 | if (!RSS09VocabPrivate::sSelf) { |
185 | RSS09VocabPrivate::sSelf = new RSS09Vocab; |
186 | qAddPostRoutine(RSS09VocabPrivate::cleanupRSS09Vocab); |
187 | } |
188 | return RSS09VocabPrivate::sSelf; |
189 | } |
190 | |
191 | const QString &RSS09Vocab::namespaceURI() const |
192 | { |
193 | return d->namespaceURI; |
194 | } |
195 | |
196 | PropertyPtr RSS09Vocab::title() const |
197 | { |
198 | return d->title; |
199 | } |
200 | |
201 | PropertyPtr RSS09Vocab::description() const |
202 | { |
203 | return d->description; |
204 | } |
205 | |
206 | PropertyPtr RSS09Vocab::link() const |
207 | { |
208 | return d->link; |
209 | } |
210 | |
211 | PropertyPtr RSS09Vocab::name() const |
212 | { |
213 | return d->name; |
214 | } |
215 | |
216 | PropertyPtr RSS09Vocab::url() const |
217 | { |
218 | return d->url; |
219 | } |
220 | |
221 | PropertyPtr RSS09Vocab::image() const |
222 | { |
223 | return d->image; |
224 | } |
225 | |
226 | PropertyPtr RSS09Vocab::textinput() const |
227 | { |
228 | return d->textinput; |
229 | } |
230 | |
231 | ResourcePtr RSS09Vocab::item() const |
232 | { |
233 | return d->item; |
234 | } |
235 | |
236 | ResourcePtr RSS09Vocab::channel() const |
237 | { |
238 | return d->channel; |
239 | } |
240 | |
241 | QStringList RSS09Vocab::classes() const |
242 | { |
243 | return d->classes; |
244 | } |
245 | |
246 | QStringList RSS09Vocab::properties() const |
247 | { |
248 | return d->properties; |
249 | } |
250 | |
251 | } // namespace RDF |
252 | } // namespace Syndication |
253 |