-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencontentparser.cpp
54 lines (46 loc) · 1.65 KB
/
encontentparser.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "encontentparser.h"
#include <QDebug>
EnContentParser::EnContentParser()
{
}
bool EnContentParser::startElement(const QString &,
const QString &,
const QString &qName,
const QXmlAttributes &attrs){
mTagContent.push(QString());
if(qName == "en-media" && getAttributeValue(attrs, "type").startsWith("image")){
accepted += "\n<" + qName;
for(int i = 0; i < attrs.count(); i++){
accepted += ' ' + attrs.qName(i) + "=\"" + attrs.value(i) + '"';
}
accepted += ">\n";
}
accepted += "\n<" + qName;
for(int i = 0; i < attrs.count(); i++){
accepted += ' ' + attrs.qName(i) + "=\"" + attrs.value(i) + '"';
}
accepted += ">\n";
//qDebug() << /*QString('\t', level) + */qName + " (" + attrString + " )";
return true;
}
bool EnContentParser::characters(const QString& characters){
mTagContent.last() += characters;
return true;
}
bool EnContentParser::endElement(const QString&, const QString&, const QString& qName){
accepted += "\n</" + qName + ">\n";
mTagContent.pop();
return true;
}
bool EnContentParser::fatalError(const QXmlParseException& exception){
qDebug() << "Line:" << exception.lineNumber()
<< ", Column:" << exception.columnNumber()
<< ", Message:" << exception.message();
return false;
}
QString EnContentParser::getAttributeValue(const QXmlAttributes& attrs, const QString& attr){
for(int i = 0; i < attrs.count(); i++)
if(attrs.qName(i) == attr)
return attrs.value(i);
return QString();
}