File indexing completed on 2024-12-08 03:45:04
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_ITEM_H 0009 #define SYNDICATION_RDF_ITEM_H 0010 0011 #include <syndication/rdf/document.h> 0012 #include <syndication/rdf/resourcewrapper.h> 0013 0014 #include <syndication/specificitem.h> 0015 0016 #include <memory> 0017 0018 class QString; 0019 0020 namespace Syndication 0021 { 0022 class SpecificItemVisitor; 0023 0024 namespace RDF 0025 { 0026 class DublinCore; 0027 class Item; 0028 0029 /** 0030 * An RSS 1.0 item. 0031 * (It is a convenience wrapper for the 0032 * underlying RDF resource, which can be accessed via resource()). 0033 * 0034 * @author Frank Osterfeld 0035 */ 0036 class Item : public ResourceWrapper, public SpecificItem 0037 { 0038 public: 0039 /** 0040 * creates an item object wrapping a null resource, isNull() is 0041 * @c true. 0042 */ 0043 Item(); 0044 0045 /** 0046 * Creates an item wrapping the given resource 0047 * @param resource resource to wrap, should be of type 0048 * of rss1:item, otherwise the wrapper will not return useful 0049 * information. 0050 * @param doc the document this item is part of. Used by Document 0051 */ 0052 explicit Item(ResourcePtr resource, DocumentPtr doc = DocumentPtr()); 0053 0054 /** 0055 * copies an item 0056 * 0057 * @param other item to copy 0058 */ 0059 Item(const Item &other); 0060 0061 /** 0062 * virtual destructor 0063 */ 0064 ~Item() override; 0065 0066 /** 0067 * assigns another item 0068 * 0069 * @param other the item to assign 0070 */ 0071 Item &operator=(const Item &other); 0072 0073 /** 0074 * compares two item instances. Two instances are equal, 0075 * if the wrapped resources are equal. See ResourceWrapper::operator==() 0076 * for details. 0077 * 0078 * @param other the item to compare this item to 0079 */ 0080 bool operator==(const Item &other) const; 0081 0082 /** 0083 * interface for item visitors. See SpecificItemVisitor for 0084 * more information. 0085 * 0086 * @param visitor a visitor visiting this object 0087 */ 0088 bool accept(SpecificItemVisitor *visitor) override; 0089 0090 /** 0091 * The item's title (required). 0092 * 0093 * @return The item's title as HTML, or a null string if not specified 0094 */ 0095 QString title() const; 0096 0097 /** 0098 * A brief description/abstract of the item. 0099 * if encodedContent() is not provided, this can also contain the full 0100 * content. 0101 * 0102 * @return description as HTML, or a null string if not specified 0103 */ 0104 QString description() const; 0105 0106 /** 0107 * The item's URL, usually pointing to a website containing the 0108 * full content (news article, blog entry etc.). 0109 * 0110 * @return the link 0111 */ 0112 QString link() const; 0113 0114 /** 0115 * returns a dublin core description of this 0116 * item (including metadata such as item author 0117 * or subject) 0118 */ 0119 DublinCore dc() const; 0120 0121 /** 0122 * returns content (@c content:encoded) as HTML. 0123 * 0124 * @return content as HTML, or a null string if not specified 0125 */ 0126 QString encodedContent() const; 0127 0128 //@cond PRIVATE 0129 /** 0130 * @internal 0131 * returns the title unmodified 0132 * used by Document 0133 */ 0134 QString originalTitle() const; 0135 0136 /** 0137 * @internal 0138 * returns the description unmodified 0139 * used by Document 0140 */ 0141 QString originalDescription() const; 0142 0143 //@endcond 0144 0145 /** 0146 * Returns a description of the item for debugging purposes. 0147 * 0148 * @return debug string 0149 */ 0150 QString debugInfo() const; 0151 0152 private: 0153 class Private; 0154 std::unique_ptr<Private> const d; 0155 }; 0156 0157 } // namespace RDF 0158 } // namespace Syndication 0159 0160 #endif // SYNDICATION_RDF_ITEM_H