File indexing completed on 2024-04-28 15:34:26

0001 /*
0002     This file is part of the syndication library
0003     SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef SYNDICATION_RSS2_PARSER_H
0009 #define SYNDICATION_RSS2_PARSER_H
0010 
0011 #include <syndication/abstractparser.h>
0012 #include <syndication/rss2/document.h>
0013 
0014 namespace Syndication
0015 {
0016 class DocumentSource;
0017 
0018 namespace RSS2
0019 {
0020 class Document;
0021 
0022 /**
0023  * Parser implementation for the RSS 0.9x/2.0 format family
0024  *
0025  * @author Frank Osterfeld
0026  */
0027 class SYNDICATION_EXPORT Parser : public Syndication::AbstractParser
0028 {
0029 public:
0030     /** default constructor */
0031     Parser();
0032 
0033     /** destructor */
0034     ~Parser() override;
0035 
0036     /**
0037      * checks whether a document source looks like an RSS0.9x/2.0 document
0038      *
0039      * @param source a document source to check
0040      * @return @c true if the source looks like an RSS2 document
0041      */
0042     bool accept(const DocumentSource &source) const override;
0043 
0044     /**
0045      * creates an RSS2 wrapper for a document source.
0046      * The wrapper will only return useful values if the source is really
0047      * RSS 0.9x/2.0, so call accept() before to check.
0048      *
0049      * @param source the source to wrap
0050      * @return A Syndication::RSS2::Document instance wrapping the XML
0051      * source, or a null document (not a null pointer!) if there is no @c
0052      * &lt;channel> root element in the source.
0053      */
0054     Syndication::SpecificDocumentPtr parse(const DocumentSource &source) const override;
0055 
0056     /**
0057      * returns the format string of this parser implementation, which is
0058      * "rss2".
0059      *
0060      * @return @c "rss2"
0061      */
0062     QString format() const override;
0063 
0064 private:
0065     Parser(const Parser &other);
0066     Parser &operator=(const Parser &other);
0067 
0068     class ParserPrivate;
0069     ParserPrivate *const d;
0070 };
0071 
0072 } // namespace RSS2
0073 } // namespace Syndication
0074 
0075 #endif // SYNDICATION_RSS2_PARSER_H