File indexing completed on 2023-09-24 04:15:34
0001 /* 0002 This file is part of the syndication library 0003 SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef SYNDICATION_RDF_DOCUMENT_H 0009 #define SYNDICATION_RDF_DOCUMENT_H 0010 0011 #include <syndication/rdf/resourcewrapper.h> 0012 0013 #include <syndication/specificdocument.h> 0014 0015 template<class T> 0016 class QList; 0017 0018 namespace Syndication 0019 { 0020 namespace RDF 0021 { 0022 class Document; 0023 class Model; 0024 class DublinCore; 0025 class Image; 0026 class Item; 0027 class SyndicationInfo; 0028 class TextInput; 0029 //@cond PRIVATE 0030 typedef QSharedPointer<Document> DocumentPtr; 0031 //@endcond 0032 0033 /** 0034 * Document implementation for RDF, representing an RSS 1.0 feed. 0035 * 0036 * @author Frank Osterfeld 0037 */ 0038 class SYNDICATION_EXPORT Document : public Syndication::SpecificDocument, public ResourceWrapper 0039 { 0040 friend class ::Syndication::RDF::Model; 0041 0042 public: 0043 /** 0044 * creates a wrapper wrapping a null resource 0045 */ 0046 Document(); 0047 0048 /** 0049 * creates a document by wrapping a channel resource 0050 * 0051 * @param resource the channel resource to wrap 0052 */ 0053 explicit Document(ResourcePtr resource); 0054 0055 /** 0056 * creates a copy of another document 0057 * 0058 * @param other the document to copy 0059 */ 0060 Document(const Document &other); 0061 0062 /** 0063 * destructor 0064 */ 0065 ~Document() override; 0066 0067 /** 0068 * compares two documents. Two documents are equal if they wrap 0069 * the same resource. See ResourceWrapper::operator==() 0070 * 0071 * @param other the document to compare to 0072 */ 0073 bool operator==(const Document &other) const; 0074 0075 /** 0076 * assigns another document 0077 * 0078 * @param other the document to assign 0079 */ 0080 Document &operator=(const Document &other); 0081 0082 /** 0083 * Used by visitors for double dispatch. See DocumentVisitor 0084 * for more information. 0085 * @param visitor the visitor calling the method 0086 */ 0087 bool accept(DocumentVisitor *visitor) override; 0088 0089 /** 0090 * returns whether this document is valid or not. 0091 * Invalid documents do not contain any useful 0092 * information. 0093 */ 0094 bool isValid() const override; 0095 0096 /** 0097 * title of the feed (required) 0098 * 0099 * @return feed title as TODO: define format 0100 */ 0101 QString title() const; 0102 0103 /** 0104 * A brief description of the channel's content, function, source, etc. 0105 * 0106 * @return TODO: define format etc. 0107 */ 0108 QString description() const; 0109 0110 /** 0111 * The URL to which an HTML rendering of the channel title will link, 0112 * commonly the parent site's home or news page. 0113 */ 0114 QString link() const; 0115 0116 /** 0117 * returns a dublin core description of the document. 0118 */ 0119 DublinCore dc() const; 0120 0121 /** 0122 * returns syndication information describing how often this feed 0123 * is updated. 0124 */ 0125 SyndicationInfo syn() const; 0126 0127 /** 0128 * list of items contained in this feed 0129 */ 0130 QList<Item> items() const; 0131 0132 /** 0133 * An image to be associated with an HTML rendering of the channel. 0134 */ 0135 Image image() const; 0136 0137 /** 0138 * An optional text input element associated with the channel 0139 */ 0140 TextInput textInput() const; 0141 //@cond PRIVATE 0142 /** 0143 * @internal 0144 * checks the format of titles and returns the results 0145 * 0146 * @param containsMarkup whether the heuristic found HTML markup in 0147 * titles 0148 */ 0149 void getItemTitleFormatInfo(bool *containsMarkup) const; 0150 0151 /** 0152 * @internal 0153 * checks the format of descriptions and returns the results 0154 * 0155 * @param containsMarkup whether the heuristic found HTML markup in 0156 * descriptions 0157 */ 0158 void getItemDescriptionFormatInfo(bool *containsMarkup) const; 0159 //@endcond PRIVATE 0160 0161 /** 0162 * Returns a description of the document for debugging purposes. 0163 * 0164 * @return debug string 0165 */ 0166 QString debugInfo() const override; 0167 0168 private: 0169 class Private; 0170 Private *const d; 0171 }; 0172 0173 } // namespace RDF 0174 } // namespace Syndication 0175 0176 #endif // SYNDICATION_RDF_DOCUMENT_H