[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenonbeta/kdom/parser/qxml
From: Nikolas Zimmermann <wildfox () kde ! org>
Date: 2004-06-27 13:53:31
Message-ID: 20040627135331.395ED9918 () office ! kde ! org
[Download RAW message or body]
CVS commit by wildfox:
Incremental parsing support for qxml
A QXmlIncrementalSource.cc 1.1 [LGPL (v2+)]
A QXmlIncrementalSource.h 1.1 [LGPL (v2+)]
M +1 -1 Makefile.am 1.6
M +27 -9 QXmlParser.cc 1.37
M +7 -0 QXmlParser.h 1.20
--- kdenonbeta/kdom/parser/qxml/Makefile.am #1.5:1.6
@@ -3,5 +3,5 @@
kde_module_LTLIBRARIES = libkdomparserqxml.la
-libkdomparserqxml_la_SOURCES = QXmlParser.cc QXmlParserFactory.cc
+libkdomparserqxml_la_SOURCES = QXmlParser.cc QXmlParserFactory.cc \
QXmlIncrementalSource.cc libkdomparserqxml_la_LDFLAGS = -module $(KDE_PLUGIN) \
$(all_libraries) libkdomparserqxml_la_LIBADD = $(top_builddir)/kdom/libkdom.la \
$(top_builddir)/kdom/parser/libkdomparser.la
--- kdenonbeta/kdom/parser/qxml/QXmlParser.cc #1.36:1.37
@@ -33,4 +33,10 @@ using namespace KDOM;
QXmlParser::QXmlParser(const KURL &url) : Parser(url), QXmlDefaultHandler()
{
+ m_reader.setContentHandler(this);
+ m_reader.setLexicalHandler(this);
+ m_reader.setEntityResolver(this);
+ m_reader.setErrorHandler(this);
+ m_reader.setDeclHandler(this);
+ m_reader.setDTDHandler(this);
}
@@ -42,7 +48,27 @@ void QXmlParser::startParsing(bool incre
{
connect(this, SIGNAL(loadingFinished(QBuffer *)), \
SLOT(slotLoadingFinished(QBuffer *))); +
+ if(incremental)
+ {
+ connect(this, SIGNAL(feedData(const QByteArray &, bool)), this, \
SLOT(slotFeedData(const QByteArray &, bool))); + \
m_reader.parse(&m_source, true); + }
+
Parser::startParsing(incremental);
}
+void QXmlParser::slotFeedData(const QByteArray &data, bool eof)
+{
+ m_source.appendXML(data);
+
+ if(eof)
+ {
+ m_source.setFinished(true);
+ emit parsingFinished(false, "");
+ }
+ else
+ m_reader.parseContinue();
+}
+
void QXmlParser::slotLoadingFinished(QBuffer *buffer)
{
@@ -53,14 +79,6 @@ void QXmlParser::slotLoadingFinished(QBu
}
- QXmlSimpleReader reader;
QXmlInputSource inputSource(buffer);
-
- reader.setContentHandler(this);
- reader.setLexicalHandler(this);
- reader.setEntityResolver(this);
- reader.setErrorHandler(this);
- reader.setDeclHandler(this);
- reader.setDTDHandler(this);
- reader.parse(&inputSource);
+ m_reader.parse(&inputSource);
}
--- kdenonbeta/kdom/parser/qxml/QXmlParser.h #1.19:1.20
@@ -28,4 +28,6 @@
#include <kdom/parser/KDOMParser.h>
+#include "QXmlIncrementalSource.h"
+
namespace KDOM
{
@@ -47,4 +49,5 @@ namespace KDOM
public slots:
void slotLoadingFinished(QBuffer *buffer);
+ void slotFeedData(const QByteArray &data, bool eof); \
protected:
@@ -73,4 +76,8 @@ namespace KDOM
virtual bool error(const QXmlParseException &exception);
virtual bool fatalError(const QXmlParseException &exception);
+
+ private:
+ QXmlSimpleReader m_reader;
+ QXmlIncrementalSource m_source;
};
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic