Qtopia library API Documentation

xmlreader.h

00001 /**********************************************************************
00002 ** Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of the Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
00018 **
00019 **********************************************************************/
00020 #ifndef XMLREADER_H
00021 #define XMLREADER_H
00022 
00023 #include <qstring.h>
00024 #include <qxml.h>
00025 #include <qmap.h>
00026 
00027 class Node
00028 {
00029 public:
00030     Node();
00031     ~Node();
00032 
00033     void addChild( Node *child );
00034 
00035     void setAttributes( const QXmlAttributes &a );
00036     QMap<QString, QString> attributeMap();
00037     QString attribute( const QString& name );
00038 
00039     Node *nextNode() const { return next; }
00040     Node *prevNode() const { return prev; }
00041     Node *parentNode() const { return parent; }
00042     Node *lastChild() const { return last; }
00043     Node *firstChild() const { return first; }
00044 
00045     void setTagName( const QString &s ) { tagN = s; }
00046     QString tagName() const { return tagN; }
00047     void setData( const QString &s ) { dt = s; }
00048     QString data() const { return dt; }
00049     QString subData(const QString& tag) const;
00050     void appendData( const QString s ) { dt += s; }
00051 
00052 
00053 private:
00054     QMap<QString, QString> attributes;
00055     QString dt, tagN;
00056 
00057     Node *parent, *prev, *next, *first, *last;
00058 };
00059 
00060 class XmlHandlerPrivate;
00061 class XmlHandler : public QXmlDefaultHandler
00062 {
00063 public:
00064     XmlHandler();
00065     ~XmlHandler();
00066 
00067     bool startDocument();
00068     bool endDocument();
00069     bool startElement( const QString &ns, const QString &ln, const QString &qName,
00070                const QXmlAttributes &attr );
00071     bool endElement( const QString &ns, const QString &ln, const QString &qName );
00072     bool characters( const QString &ch );
00073 
00074     Node *firstNode() const { return tree; }
00075 
00076 private:
00077     Node *node, *tree;
00078     XmlHandlerPrivate *d;
00079 };
00080 
00081 
00082 
00083 #endif
KDE Logo
This file is part of the documentation for OPIE Version 1.5.5.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:09 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001