File indexing completed on 2024-06-23 04:03:33
0001 /* 0002 * parser.h - parse an XMPP "document" 0003 * Copyright (C) 2003 Justin Karneges 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Lesser General Public 0007 * License as published by the Free Software Foundation; either 0008 * either version 2 0009 of the License, or (at your option) any later version.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General Public 0017 * License along with this library; if not, write to the Free Software 0018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0019 * 0020 */ 0021 0022 #ifndef PARSER_H 0023 #define PARSER_H 0024 0025 #include <qdom.h> 0026 #include <qxml.h> 0027 0028 namespace XMPP 0029 { 0030 class Parser 0031 { 0032 public: 0033 Parser(); 0034 ~Parser(); 0035 0036 class Event 0037 { 0038 public: 0039 enum Type { DocumentOpen, DocumentClose, Element, Error }; 0040 Event(); 0041 Event(const Event &); 0042 Event & operator=(const Event &); 0043 ~Event(); 0044 0045 bool isNull() const; 0046 int type() const; 0047 0048 // for document open 0049 QString nsprefix(const QString &s=QString()) const; 0050 0051 // for document open / close 0052 QString namespaceURI() const; 0053 QString localName() const; 0054 QString qName() const; 0055 QXmlAttributes atts() const; 0056 0057 // for element 0058 QDomElement element() const; 0059 0060 // for any 0061 QString actualString() const; 0062 0063 // setup 0064 void setDocumentOpen(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts, const QStringList &nsnames, const QStringList &nsvalues); 0065 void setDocumentClose(const QString &namespaceURI, const QString &localName, const QString &qName); 0066 void setElement(const QDomElement &elem); 0067 void setError(); 0068 void setActualString(const QString &); 0069 0070 private: 0071 class Private; 0072 Private *d; 0073 }; 0074 0075 void reset(); 0076 void appendData(const QByteArray &a); 0077 Event readNext(); 0078 QByteArray unprocessed() const; 0079 QString encoding() const; 0080 0081 private: 0082 class Private; 0083 Private *d; 0084 }; 0085 } 0086 0087 #endif