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_DOCUMENT_H |
9 | #define SYNDICATION_RDF_DOCUMENT_H |
10 | |
11 | #include <syndication/rdf/resourcewrapper.h> |
12 | |
13 | #include <syndication/specificdocument.h> |
14 | |
15 | #include <memory> |
16 | |
17 | template<class T> |
18 | class QList; |
19 | |
20 | namespace Syndication |
21 | { |
22 | namespace RDF |
23 | { |
24 | class Document; |
25 | class Model; |
26 | class DublinCore; |
27 | class Image; |
28 | class Item; |
29 | class SyndicationInfo; |
30 | class TextInput; |
31 | //@cond PRIVATE |
32 | typedef QSharedPointer<Document> DocumentPtr; |
33 | //@endcond |
34 | |
35 | /** |
36 | * Document implementation for RDF, representing an RSS 1.0 feed. |
37 | * |
38 | * @author Frank Osterfeld |
39 | */ |
40 | class Document : public Syndication::SpecificDocument, public ResourceWrapper |
41 | { |
42 | friend class ::Syndication::RDF::Model; |
43 | |
44 | public: |
45 | /** |
46 | * creates a wrapper wrapping a null resource |
47 | */ |
48 | Document(); |
49 | |
50 | /** |
51 | * creates a document by wrapping a channel resource |
52 | * |
53 | * @param resource the channel resource to wrap |
54 | */ |
55 | explicit Document(ResourcePtr resource); |
56 | |
57 | /** |
58 | * creates a copy of another document |
59 | * |
60 | * @param other the document to copy |
61 | */ |
62 | Document(const Document &other); |
63 | |
64 | /** |
65 | * destructor |
66 | */ |
67 | ~Document() override; |
68 | |
69 | /** |
70 | * compares two documents. Two documents are equal if they wrap |
71 | * the same resource. See ResourceWrapper::operator==() |
72 | * |
73 | * @param other the document to compare to |
74 | */ |
75 | bool operator==(const Document &other) const; |
76 | |
77 | /** |
78 | * assigns another document |
79 | * |
80 | * @param other the document to assign |
81 | */ |
82 | Document &operator=(const Document &other); |
83 | |
84 | /** |
85 | * Used by visitors for double dispatch. See DocumentVisitor |
86 | * for more information. |
87 | * @param visitor the visitor calling the method |
88 | */ |
89 | bool accept(DocumentVisitor *visitor) override; |
90 | |
91 | /** |
92 | * returns whether this document is valid or not. |
93 | * Invalid documents do not contain any useful |
94 | * information. |
95 | */ |
96 | bool isValid() const override; |
97 | |
98 | /** |
99 | * title of the feed (required) |
100 | * |
101 | * @return feed title as TODO: define format |
102 | */ |
103 | QString title() const; |
104 | |
105 | /** |
106 | * A brief description of the channel's content, function, source, etc. |
107 | * |
108 | * @return TODO: define format etc. |
109 | */ |
110 | QString description() const; |
111 | |
112 | /** |
113 | * The URL to which an HTML rendering of the channel title will link, |
114 | * commonly the parent site's home or news page. |
115 | */ |
116 | QString link() const; |
117 | |
118 | /** |
119 | * returns a dublin core description of the document. |
120 | */ |
121 | DublinCore dc() const; |
122 | |
123 | /** |
124 | * returns syndication information describing how often this feed |
125 | * is updated. |
126 | */ |
127 | SyndicationInfo syn() const; |
128 | |
129 | /** |
130 | * list of items contained in this feed |
131 | */ |
132 | QList<Item> items() const; |
133 | |
134 | /** |
135 | * An image to be associated with an HTML rendering of the channel. |
136 | */ |
137 | Image image() const; |
138 | |
139 | /** |
140 | * An optional text input element associated with the channel |
141 | */ |
142 | TextInput textInput() const; |
143 | //@cond PRIVATE |
144 | /** |
145 | * @internal |
146 | * checks the format of titles and returns the results |
147 | * |
148 | * @param containsMarkup whether the heuristic found HTML markup in |
149 | * titles |
150 | */ |
151 | void getItemTitleFormatInfo(bool *containsMarkup) const; |
152 | |
153 | /** |
154 | * @internal |
155 | * checks the format of descriptions and returns the results |
156 | * |
157 | * @param containsMarkup whether the heuristic found HTML markup in |
158 | * descriptions |
159 | */ |
160 | void getItemDescriptionFormatInfo(bool *containsMarkup) const; |
161 | //@endcond PRIVATE |
162 | |
163 | /** |
164 | * Returns a description of the document for debugging purposes. |
165 | * |
166 | * @return debug string |
167 | */ |
168 | QString debugInfo() const override; |
169 | |
170 | private: |
171 | class Private; |
172 | std::unique_ptr<Private> const d; |
173 | }; |
174 | |
175 | } // namespace RDF |
176 | } // namespace Syndication |
177 | |
178 | #endif // SYNDICATION_RDF_DOCUMENT_H |
179 | |