File indexing completed on 2024-02-25 04:06:36

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 #include <memory>
0015 
0016 namespace Syndication
0017 {
0018 class DocumentSource;
0019 
0020 namespace RSS2
0021 {
0022 class Document;
0023 
0024 /**
0025  * Parser implementation for the RSS 0.9x/2.0 format family
0026  *
0027  * @author Frank Osterfeld
0028  */
0029 class Parser : public Syndication::AbstractParser
0030 {
0031 public:
0032     /** default constructor */
0033     Parser();
0034 
0035     /** destructor */
0036     ~Parser() override;
0037 
0038     /**
0039      * checks whether a document source looks like an RSS0.9x/2.0 document
0040      *
0041      * @param source a document source to check
0042      * @return @c true if the source looks like an RSS2 document
0043      */
0044     bool accept(const DocumentSource &source) const override;
0045 
0046     /**
0047      * creates an RSS2 wrapper for a document source.
0048      * The wrapper will only return useful values if the source is really
0049      * RSS 0.9x/2.0, so call accept() before to check.
0050      *
0051      * @param source the source to wrap
0052      * @return A Syndication::RSS2::Document instance wrapping the XML
0053      * source, or a null document (not a null pointer!) if there is no @c
0054      * &lt;channel> root element in the source.
0055      */
0056     Syndication::SpecificDocumentPtr parse(const DocumentSource &source) const override;
0057 
0058     /**
0059      * returns the format string of this parser implementation, which is
0060      * "rss2".
0061      *
0062      * @return @c "rss2"
0063      */
0064     QString format() const override;
0065 
0066 private:
0067     Parser(const Parser &other);
0068     Parser &operator=(const Parser &other);
0069 
0070     class ParserPrivate;
0071     std::unique_ptr<ParserPrivate> const d;
0072 };
0073 
0074 } // namespace RSS2
0075 } // namespace Syndication
0076 
0077 #endif // SYNDICATION_RSS2_PARSER_H