Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rssparser.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by ljp                                             *
00003  *   lpotter@trolltech.com                                                 *
00004  *                                                                         *
00005  *   This program may be distributed under the terms of the Q Public       *
00006  *   License as defined by Trolltech AS of Norway and appearing in the     *
00007  *   file LICENSE.QPL included in the packaging of this file.              *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  *
00012  ***************************************************************************/
00013 
00014 /* RSS required tags:
00015     title,link,description
00016 */
00017 /* RSS optional tags:
00018     language,copyright,managingEditor,webMaster,pubDate,lastBuildDate,category,generator,docs,cloud,ttl,
00019     image,rating,textInput,skipHours,skipDays
00020 */
00021 /*
00022   podcast tags
00023   <rss xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" version="2.0">
00024   title,link,copyright,pubDate,enclosure,guid,itunes:author,itunes:block,itunes:category,itunes:duration,itunes:explicit,itunes:keywords,itunes:owner,itunes:subtitle,itunes:summary
00025 */
00026 
00027 #ifndef RSSPARSER_H
00028 #define RSSPARSER_H
00029 
00030 #include <qxml.h>
00031 #include <qstringlist.h>
00032 #include <qvector.h>
00033 #include <qstringlist.h>
00034 #include <qlist.h>
00035 
00036 class QString;
00037 
00038 class rssImage {
00039 public:
00040    QString url;
00041    QString title;
00042    int width;
00043    int height;
00044    QString description;
00045 };
00046 
00047 class rssItem {
00048  public:
00049   QString title;
00050         QString description;
00051   QString link;
00052   QString pubdate;
00053   QVector <rssImage> rssImageTags;
00054   QList<QStringList> attributes; //tags with atttributes
00055 };
00056 
00057 class rssChannel {
00058  public:
00059   QString title;
00060         QString description;
00061   QString link;
00062   QString pubdate;
00063   QString copyright;
00064   QString language;
00065   QVector <rssImage> rssImageTags;
00066   QVector <rssItem> rssItems;
00067   QList<QStringList> attributes; //tags with atttributes
00068 };
00069 
00070 class RssParser : public QXmlDefaultHandler
00071 {
00072 public:
00073    RssParser();
00074    ~RssParser();
00075          QString errorMessage;
00076 
00077          QVector<rssItem> &getItems();
00078          QStringList getChannelInfo();
00079    int getSize();
00080 
00081 private:
00082 
00083          enum Tag {
00084                          NoneTag = 0,
00085                          TitleTag = 1,
00086                          NewItemTag = 2,
00087                          DescriptionTag = 3,
00088                          LinkTag = 4,
00089        pubDateTag = 5,
00090 /*
00091        ImageTag = 6, 
00092        UrlTag = 7,
00093        WidthTag = 8,
00094        HeightTag = 9,
00095  */
00096          };
00097          Tag tag;
00098 
00099 //   QVector <rssItem> rssItems;
00100    QStringList channelInfo;
00101          rssItem *Item;
00102          rssChannel *channel;
00103          rssImage *image;
00104          
00105          bool isItem;
00106    QStringList tokenNames;
00107          QString htmlString;
00108 
00109 protected:
00110 
00111    bool startElement( const QString&, const QString&, const QString& ,const QXmlAttributes& );
00112    bool endElement( const QString&, const QString&, const QString& );
00113          bool characters( const QString &);
00114 
00115          bool warning(const QXmlParseException &);
00116          bool error(const QXmlParseException &);
00117          bool fatalError(const QXmlParseException &);
00118          
00119          QString itemTitle, itemLink, itemDescription;
00120 };
00121 
00122 #endif

Generated on Sat Nov 5 16:15:43 2005 for OPIE by  doxygen 1.4.2