16 #ifndef _BASEHANDLER_H 17 #define _BASEHANDLER_H 40 virtual bool handleStartElement(
const QString &
name,
42 virtual bool handleEndElement(
const QString &name) = 0;
56 : m_parent(parent), m_handler(h) {}
58 {
if (m_parent) (m_parent->*m_handler)(attrib); }
66 typedef void (
T::*Handler)();
70 : m_parent(parent), m_handler(h) {}
72 {
if (m_parent) (m_parent->*m_handler)(); }
84 m_startHandlers.setAutoDelete(
TRUE);
85 m_endHandlers.setAutoDelete(
TRUE);
93 m_startHandlers.insert(key,
new StartElementHandlerT);
98 m_startHandlers.insert(key,
new StartElementHandlerT(obj,handler));
103 m_endHandlers.insert(key,
new EndElementHandlerT);
108 m_endHandlers.insert(key,
new EndElementHandlerT(obj,handler));
135 BaseHandler() : m_skipCount(0), m_delegateHandler(0), m_fallBackHandler(0)
141 ASSERT(m_delegateHandler==0);
155 if (m_delegateHandler)
157 return m_delegateHandler->startElement(namespaceURI,localName,name,attrib);
159 if (!m_skipUntil.isEmpty())
161 if (m_skipUntil==name) m_skipCount++;
162 debug(1,
"line %d, col %d: skipping start tag %s count=%d\n",
163 s_theLocator->lineNumber(),s_theLocator->columnNumber(),
164 name.
data(),m_skipCount);
174 else if (!m_fallBackHandler ||
175 !m_fallBackHandler->handleStartElement(name,attrib)
178 debug(1,
"line %d, col %d: found unexpected tag `%s', skipping until matching end tag\n",
179 s_theLocator->lineNumber(),s_theLocator->columnNumber(),
189 if (m_delegateHandler)
191 return m_delegateHandler->endElement(namespaceURI,localName,name);
194 if (name==m_skipUntil)
197 debug(1,
"line %d, col %d: skipping end tag %s count=%d\n",
198 s_theLocator->lineNumber(),s_theLocator->columnNumber(),
199 name.
data(),m_skipCount);
206 else if (m_skipUntil.isEmpty())
214 else if (m_fallBackHandler)
216 m_fallBackHandler->handleEndElement(name);
225 if (m_delegateHandler)
227 return m_delegateHandler->skippedEntity(s);
230 debug(1,
"line %d, col %d: Skipped unhandled entity %s\n",
231 s_theLocator->lineNumber(),s_theLocator->columnNumber(),
241 if (m_delegateHandler)
243 return m_delegateHandler->characters(ch);
258 return m_delegateHandler;
263 m_fallBackHandler =
h;
268 return m_fallBackHandler;
273 debug(2,
"setDocumentLocator(%p)\n",locator);
274 s_theLocator = locator;
bool skippedEntity(const QString &s)
virtual ~BaseFallBackHandler()
ElementMapper< T >::EndElementHandlerT EndElementHandlerT
The QXmlLocator class provides the XML handler classes with information about the actual parsing posi...
ElementMapper< T >::EndElementHandlerT EndElementHandlerT
QXmlDefaultHandler * m_delegateHandler
QDict< StartElementHandlerT > m_startHandlers
QDict< EndElementHandlerT > m_endHandlers
QXmlDefaultHandler * delegate() const
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &name)
StartElementHandler StartElementHandlerT
void setDocumentLocator(QXmlLocator *locator)
virtual bool characters(const QString &ch)
static QXmlLocator * s_theLocator
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
IFallBackHandler * fallBackHandler() const
void operator()(const QXmlAttributes &attrib)
StartElementHandler(T *parent, Handler h)
void addStartHandler(const char *key, T *obj, void(T::*handler)(const QXmlAttributes &))
virtual QXmlDefaultHandler * delegate() const =0
const char * data() const
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &name, const QXmlAttributes &attrib)
virtual void setDelegate(QXmlDefaultHandler *delegate)=0
EndElementHandler EndElementHandlerT
The QXmlDefaultHandler class provides a default implementation of all XML handler classes...
IFallBackHandler * m_fallBackHandler
bool handleStartElement(const QString &name, const QXmlAttributes &attrib)
ElementMapper< T >::StartElementHandlerT StartElementHandlerT
void setFallBackHandler(IFallBackHandler *h)
ElementMapper< T >::StartElementHandlerT StartElementHandlerT
The QXmlAttributes class provides XML attributes.
static msg_handler handler
void addStartHandler(const char *key)
bool handleEndElement(const QString &name)
virtual bool startDocument()
void addEndHandler(const char *key, T *obj, void(T::*handler)())
def parent(G, child, parent_type)
EndElementHandler(T *parent, Handler h)
void setDelegate(QXmlDefaultHandler *delegate)
void addEndHandler(const char *key)
virtual ~IFallBackHandler()