TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkabstractxml.h
Go to the documentation of this file.
1 #ifndef TTKABSTRACTXML_H
2 #define TTKABSTRACTXML_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2024 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QFile>
23 #include <QTextStream>
24 #include <QtXml/QDomDocument>
25 
26 #include "ttktime.h"
28 
33 {
34  QString m_key;
35  QVariant m_value;
36 
37  TTKXmlAttr() = default;
38  TTKXmlAttr(const QString &key, const QVariant &value)
39  : m_key(key),
40  m_value(value)
41  {
42 
43  }
44 };
46 
47 
52 {
53  TTKXmlAttrList m_attrs;
54  QString m_text;
55 
57  : m_attrs(),
58  m_text()
59  {
60 
61  }
62 };
64 
65 
70 {
71 public:
75  explicit TTKXmlHelper(const QDomNode &root);
76 
80  void load();
84  bool hasNext();
85 
89  QDomNode next() const;
93  QString nodeName(const QString &name) const;
94 
95 private:
96  QDomNode m_root, m_current;
97  QSet<QString> m_nodeNames;
98 
99 };
100 
101 
106 {
108 public:
112  TTKAbstractXml();
116  virtual ~TTKAbstractXml();
117 
121  bool load(const QString &name);
125  void save() const;
129  bool reset();
130 
134  bool fromFile(const QString &name);
138  bool fromString(const QString &data);
142  bool fromByteArray(const QByteArray &data);
143 
147  QString toString() const;
151  QByteArray toByteArray() const;
152 
156  void createProcessingInstruction() const;
157 
161  QString readAttributeByTagName(const QString &tagName, const QString &attrName = "value") const;
165  QString readTextByTagName(const QString &tagName) const;
169  TTKXmlNode readNodeByTagName(const QString &tagName) const;
170 
174  QStringList readMultiAttributeByTagName(const QString &tagName, const QString &attrName = "value") const;
178  QStringList readMultiTextByTagName(const QString &tagName) const;
182  TTKXmlNodeList readMultiNodeByTagName(const QString &tagName) const;
183 
187  QDomElement createRoot(const QString &node) const;
191  QDomElement createRoot(const QString &node, const TTKXmlAttr &attr) const;
195  QDomElement createRoot(const QString &node, const TTKXmlAttrList &attrs) const;
196 
200  QDomElement writeDomElement(QDomElement &element, const QString &node) const;
204  QDomElement writeDomElement(QDomElement &element, const QString &node, const QString &text) const;
208  QDomElement writeDomElement(QDomElement &element, const QString &node, const TTKXmlNode &attr) const;
212  QDomElement writeDomElement(QDomElement &element, const QString &node, const TTKXmlAttr &attr) const;
216  QDomElement writeDomElement(QDomElement &element, const QString &node, const TTKXmlAttr &attr, const QString &text) const;
217 
221  QDomElement writeDomMultiElement(QDomElement &element, const QString &node, const TTKXmlNode &attrs) const;
225  QDomElement writeDomMultiElement(QDomElement &element, const QString &node, const TTKXmlAttrList &attrs) const;
229  QDomElement writeDomMultiElement(QDomElement &element, const QString &node, const TTKXmlAttrList &attrs, const QString &text) const;
230 
234  void writeAttribute(QDomElement &element, const TTKXmlAttr &attr) const;
238  void writeAttribute(QDomElement &element, const TTKXmlAttrList &attr) const;
239 
240 protected:
241  QFile *m_file;
242  QDomDocument *m_document;
243 
244 };
245 
246 #endif // TTKABSTRACTXML_H
QString m_key
#define TTK_MODULE_EXPORT
QDomNode m_root
The class of the ttk xml interface.
QDomDocument * m_document
static constexpr wchar_t key[]
QSet< QString > m_nodeNames
TTKXmlAttr(const QString &key, const QVariant &value)
const char * name
Definition: http_parser.c:458
TTK_DECLARE_LIST(TTKXmlAttr)
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:152
The class of the ttk xml attribute.
TTKXmlAttrList m_attrs
The class of the ttk xml hepler.
The class of the ttk xml node.
TTK_MODULE_EXPORT QString toString(Record type)
QVariant m_value
QString m_text