MuseScore  3.4
Music composition and notation
xmlreader.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2004-2011 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __XML_H__
14 #define __XML_H__
15 
16 #include <QFile>
17 #include <QByteArray>
18 #include <QString>
19 #include <QPointF>
20 #include <QRectF>
21 #include <QSizeF>
22 #include <QXmlStreamReader>
23 
24 //---------------------------------------------------------
25 // XmlReader
26 //---------------------------------------------------------
27 
28 class XmlReader : public QXmlStreamReader {
29  QString docName; // used for error reporting
30 
31  public:
32  XmlReader(QFile*);
33  XmlReader(const QByteArray& d) : QXmlStreamReader(d) {}
34  XmlReader(QIODevice* d) : QXmlStreamReader(d) {}
35  XmlReader(const QString& d) : QXmlStreamReader(d) {}
36 
37  void unknown() const;
38  void error(const QString& s) const;
39 
40  void error(int, int);
41 
42  // attribute helper routines:
43  QString attribute(const char* s) const { return attributes().value(s).toString(); }
44  QString attribute(const char* s, const QString&) const;
45  int intAttribute(const char* s, int _default = 0, int base = 10) const;
46  double doubleAttribute(const char* s) const;
47  double doubleAttribute(const char* s, double _default) const;
48  bool hasAttribute(const char* s) const;
49 
50  int readInt() { return readElementText().toInt(); }
51  int readInt(bool* ok) { return readElementText().toInt(ok); }
52  double readDouble() { return readElementText().toDouble(); }
53  QPointF readPoint();
54  QSizeF readSize();
55  QRectF readRect();
56 
57  void setDocName(const QString& s) { docName = s; }
58  };
59 
60 #endif
61 
bool hasAttribute(const char *s) const
Definition: xmlreader.cpp:71
int intAttribute(const char *s, int _default=0, int base=10) const
Definition: xmlreader.cpp:29
QRectF readRect()
Definition: xmlreader.cpp:108
QString docName
Definition: xmlreader.h:29
XmlReader(QFile *)
Definition: xmlreader.cpp:19
XmlReader(QIODevice *d)
Definition: xmlreader.h:34
double doubleAttribute(const char *s) const
Definition: xmlreader.cpp:42
QString attribute(const char *s) const
Definition: xmlreader.h:43
int readInt(bool *ok)
Definition: xmlreader.h:51
void unknown() const
Definition: xmlreader.cpp:125
void setDocName(const QString &s)
Definition: xmlreader.h:57
double readDouble()
Definition: xmlreader.h:52
QPointF readPoint()
Definition: xmlreader.cpp:80
XmlReader(const QByteArray &d)
Definition: xmlreader.h:33
XmlReader(const QString &d)
Definition: xmlreader.h:35
Definition: xmlreader.h:28
QSizeF readSize()
Definition: xmlreader.cpp:94
void error(const QString &s) const
Definition: xmlreader.cpp:138
int readInt()
Definition: xmlreader.h:50