| 1 | //============================================================================= |
| 2 | // MuseScore sftools |
| 3 | // |
| 4 | // Copyright (C) 2004-2011 Werner Schweer |
| 5 | // |
| 6 | // This work is free software; you can redistribute it and/or |
| 7 | // modify it under the terms of the GNU Library General Public |
| 8 | // License as published by the Free Software Foundation; either |
| 9 | // version 2 of the License, or (at your option) any later version. |
| 10 | // |
| 11 | // In addition, as a special exception, licensor gives permission to |
| 12 | // link the code of this work with the OpenSSL Library (or with modified |
| 13 | // versions of OpenSSL that use the same license as OpenSSL), and |
| 14 | // distribute linked combinations including the two. You must obey the |
| 15 | // GNU General Public License in all respects for all of the code used |
| 16 | // other than OpenSSL. If you modify this file, you may extend this |
| 17 | // exception to your version of the file, but you are not obligated to |
| 18 | // do so. If you do not wish to do so, delete this exception statement |
| 19 | // from your version. (This exception is necessary should this work be |
| 20 | // included in a GPL-licenced work.) |
| 21 | // |
| 22 | // See COPYING.LIB for the licence text and disclaimer of warranty. |
| 23 | //============================================================================= |
| 24 | |
| 25 | #ifndef __XML_H__ |
| 26 | #define __XML_H__ |
| 27 | |
| 28 | #include <QtCore/Qt> |
| 29 | #include <QtCore/QTextStream> |
| 30 | #include <QtCore/QString> |
| 31 | #include <QtXml/QDomElement> |
| 32 | |
| 33 | //--------------------------------------------------------- |
| 34 | // Xml |
| 35 | //--------------------------------------------------------- |
| 36 | |
| 37 | class Xml : public QTextStream { |
| 38 | static const int BS = 2048; |
| 39 | |
| 40 | QList<QString> stack; |
| 41 | void putLevel(); |
| 42 | |
| 43 | public: |
| 44 | Xml(QIODevice* dev); |
| 45 | Xml(); |
| 46 | |
| 47 | void header(); |
| 48 | |
| 49 | void stag(const QString&); |
| 50 | void etag(); |
| 51 | |
| 52 | void tagE(const QString&); |
| 53 | void tagE(const char* format, ...); |
| 54 | void ntag(const char* name); |
| 55 | void netag(const char* name); |
| 56 | |
| 57 | void tag(const QString&, QVariant data); |
| 58 | void tag(const char* name, const char* s) { tag(name, QVariant(s)); } |
| 59 | void tag(const char* name, const QString& s) { tag(name, QVariant(s)); } |
| 60 | void tag(const char* name, const QWidget*); |
| 61 | |
| 62 | void writeHtml(const QString& s); |
| 63 | void dump(int len, const unsigned char* p); |
| 64 | |
| 65 | static QString xmlString(const QString&); |
| 66 | static void htmlToString(const QDomElement&, int level, QString*); |
| 67 | static QString htmlToString(const QDomElement&); |
| 68 | }; |
| 69 | |
| 70 | extern QString docName; |
| 71 | extern void domError(const QDomElement&); |
| 72 | extern void domNotImplemented(const QDomElement&); |
| 73 | #endif |