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