SciDAVis  1.D4
XmlStreamReader.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : XmlStreamReader.h
3  Project : SciDAVis
4  Description : XML stream parser that supports errors as well as warnings
5  --------------------------------------------------------------------
6  Copyright : (C) 2008-2009 Tilman Benkert (thzs*gmx.net)
7  (replace * with @ in the email addresses)
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef XML_STREAM_READER_H
30 #define XML_STREAM_READER_H
31 
32 #include <QXmlStreamReader>
33 #include <QString>
34 #include <QStringList>
35 #include "lib/macros.h"
36 
38 
41 class XmlStreamReader : public QXmlStreamReader
42 {
43  public:
45  XmlStreamReader(QIODevice * device);
46  XmlStreamReader(const QByteArray & data);
47  XmlStreamReader(const QString & data);
48  XmlStreamReader(const char * data);
49 
50  QStringList warningStrings() const;
51  bool hasWarnings() const;
52  void raiseWarning(const QString & message = QString());
53  void raiseError(const QString & message = QString());
54  CLASS_ACCESSOR(QString, d_error_prefix, errorPrefix, ErrorPrefix);
55  CLASS_ACCESSOR(QString, d_error_postfix, errorPostfix, ErrorPostfix);
56  CLASS_ACCESSOR(QString, d_warning_prefix, warningPrefix, WarningPrefix);
57  CLASS_ACCESSOR(QString, d_warning_postfix, warningPostfix, WarningPostfix);
58 
60 
65  bool skipToNextTag();
67 
72  bool skipToEndElement();
73 
75 
80  int readAttributeInt(const QString & name, bool * ok);
81 
82  private:
83  QStringList d_warnings;
84  QString d_error_prefix;
85  QString d_error_postfix;
88 
89  void init();
90 };
91 
92 #endif // XML_STREAM_READER_H