Public Types | Public Member Functions | Protected Attributes | List of all members
BaseHandler< T > Class Template Reference

#include <basehandler.h>

Inheritance diagram for BaseHandler< T >:
QXmlDefaultHandler ElementMapper< T > LocatorContainer IBaseHandler QXmlContentHandler QXmlErrorHandler QXmlDTDHandler QXmlEntityResolver QXmlLexicalHandler QXmlDeclHandler

Public Types

typedef ElementMapper< T >::StartElementHandlerT StartElementHandlerT
 
typedef ElementMapper< T >::EndElementHandlerT EndElementHandlerT
 
- Public Types inherited from ElementMapper< T >
typedef StartElementHandler StartElementHandlerT
 
typedef EndElementHandler EndElementHandlerT
 

Public Member Functions

 BaseHandler ()
 
virtual ~BaseHandler ()
 
virtual bool startDocument ()
 
virtual bool startElement (const QString &namespaceURI, const QString &localName, const QString &name, const QXmlAttributes &attrib)
 
virtual bool endElement (const QString &namespaceURI, const QString &localName, const QString &name)
 
bool skippedEntity (const QString &s)
 
virtual bool characters (const QString &ch)
 
void setDelegate (QXmlDefaultHandler *delegate)
 
QXmlDefaultHandlerdelegate () const
 
void setFallBackHandler (IFallBackHandler *h)
 
IFallBackHandlerfallBackHandler () const
 
void setDocumentLocator (QXmlLocator *locator)
 
- Public Member Functions inherited from QXmlDefaultHandler
 QXmlDefaultHandler ()
 
virtual ~QXmlDefaultHandler ()
 
void setDocumentLocator (QXmlLocator *locator)
 
bool startDocument ()
 
bool endDocument ()
 
bool startPrefixMapping (const QString &prefix, const QString &uri)
 
bool endPrefixMapping (const QString &prefix)
 
bool startElement (const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
 
bool endElement (const QString &namespaceURI, const QString &localName, const QString &qName)
 
bool characters (const QString &ch)
 
bool ignorableWhitespace (const QString &ch)
 
bool processingInstruction (const QString &target, const QString &data)
 
bool skippedEntity (const QString &name)
 
bool warning (const QXmlParseException &exception)
 
bool error (const QXmlParseException &exception)
 
bool fatalError (const QXmlParseException &exception)
 
bool notationDecl (const QString &name, const QString &publicId, const QString &systemId)
 
bool unparsedEntityDecl (const QString &name, const QString &publicId, const QString &systemId, const QString &notationName)
 
bool resolveEntity (const QString &publicId, const QString &systemId, QXmlInputSource *&ret)
 
bool startDTD (const QString &name, const QString &publicId, const QString &systemId)
 
bool endDTD ()
 
bool startCDATA ()
 
bool endCDATA ()
 
bool comment (const QString &ch)
 
bool attributeDecl (const QString &eName, const QString &aName, const QString &type, const QString &valueDefault, const QString &value)
 
bool internalEntityDecl (const QString &name, const QString &value)
 
bool externalEntityDecl (const QString &name, const QString &publicId, const QString &systemId)
 
QString errorString ()
 
- Public Member Functions inherited from QXmlContentHandler
virtual ~QXmlContentHandler ()
 
- Public Member Functions inherited from QXmlErrorHandler
virtual ~QXmlErrorHandler ()
 
- Public Member Functions inherited from QXmlDTDHandler
virtual ~QXmlDTDHandler ()
 
- Public Member Functions inherited from QXmlEntityResolver
virtual ~QXmlEntityResolver ()
 
- Public Member Functions inherited from QXmlLexicalHandler
virtual ~QXmlLexicalHandler ()
 
- Public Member Functions inherited from QXmlDeclHandler
virtual ~QXmlDeclHandler ()
 
- Public Member Functions inherited from ElementMapper< T >
 ElementMapper ()
 
virtual ~ElementMapper ()
 
void addStartHandler (const char *key)
 
void addStartHandler (const char *key, T *obj, void(T::*handler)(const QXmlAttributes &))
 
void addEndHandler (const char *key)
 
void addEndHandler (const char *key, T *obj, void(T::*handler)())
 
- Public Member Functions inherited from IBaseHandler
virtual ~IBaseHandler ()
 

Protected Attributes

QString m_curString
 
QString m_skipUntil
 
int m_skipCount
 
QXmlDefaultHandlerm_delegateHandler
 
IFallBackHandlerm_fallBackHandler
 
- Protected Attributes inherited from ElementMapper< T >
QDict< StartElementHandlerTm_startHandlers
 
QDict< EndElementHandlerTm_endHandlers
 

Additional Inherited Members

- Static Public Attributes inherited from LocatorContainer
static QXmlLocators_theLocator =0
 

Detailed Description

template<class T>
class BaseHandler< T >

Definition at line 126 of file basehandler.h.

Member Typedef Documentation

template<class T>
typedef ElementMapper<T>::EndElementHandlerT BaseHandler< T >::EndElementHandlerT

Definition at line 133 of file basehandler.h.

Definition at line 132 of file basehandler.h.

Constructor & Destructor Documentation

template<class T>
BaseHandler< T >::BaseHandler ( )
inline

Definition at line 135 of file basehandler.h.

136  {
137  }
QXmlDefaultHandler * m_delegateHandler
Definition: basehandler.h:281
IFallBackHandler * m_fallBackHandler
Definition: basehandler.h:282
template<class T>
virtual BaseHandler< T >::~BaseHandler ( )
inlinevirtual

Definition at line 139 of file basehandler.h.

140  {
142  }
QXmlDefaultHandler * m_delegateHandler
Definition: basehandler.h:281
#define ASSERT(x)
Definition: qglobal.h:590

Member Function Documentation

template<class T>
virtual bool BaseHandler< T >::characters ( const QString ch)
inlinevirtual

called when a number of characters are received by the parser.

Parameters
chthe characters.

Implements QXmlContentHandler.

Definition at line 239 of file basehandler.h.

240  {
241  if (m_delegateHandler)
242  {
243  return m_delegateHandler->characters(ch);
244  }
245 
246  //printf("Found characters \"%s\"\n",ch.data());
247  m_curString+=ch;
248  return TRUE;
249  }
QXmlDefaultHandler * m_delegateHandler
Definition: basehandler.h:281
bool characters(const QString &ch)
Definition: qxml.cpp:1441
QString m_curString
Definition: basehandler.h:278
const bool TRUE
Definition: qglobal.h:371
template<class T>
QXmlDefaultHandler* BaseHandler< T >::delegate ( ) const
inlinevirtual

Implements IBaseHandler.

Definition at line 256 of file basehandler.h.

257  {
258  return m_delegateHandler;
259  }
QXmlDefaultHandler * m_delegateHandler
Definition: basehandler.h:281
template<class T>
virtual bool BaseHandler< T >::endElement ( const QString namespaceURI,
const QString localName,
const QString qName 
)
inlinevirtual

The reader calls this function when he has parsed an end element tag.

If this function returns FALSE the reader will stop parsing and will report an error. The reader will use the function errorString() to get the error message that will be used for reporting the error.

See also the namespace description.

See also
startElement()

Implements QXmlContentHandler.

Definition at line 187 of file basehandler.h.

188  {
189  if (m_delegateHandler)
190  {
191  return m_delegateHandler->endElement(namespaceURI,localName,name);
192  }
193 
194  if (name==m_skipUntil)
195  {
196  m_skipCount--;
197  debug(1,"line %d, col %d: skipping end tag %s count=%d\n",
199  name.data(),m_skipCount);
200  if (m_skipCount==0)
201  {
202  m_skipUntil="";
203  }
204  //printf("found end tag %s\n",name.data());
205  }
206  else if (m_skipUntil.isEmpty())
207  {
209  if (handler)
210  {
211  (*handler)();
212  //printf("found end tag %s\n",name.data());
213  }
214  else if (m_fallBackHandler)
215  {
217  }
218  }
219  m_curString="";
220  return TRUE;
221  }
static QCString name
Definition: declinfo.cpp:673
ElementMapper< T >::EndElementHandlerT EndElementHandlerT
Definition: basehandler.h:133
bool isEmpty() const
Definition: qstring.h:682
QXmlDefaultHandler * m_delegateHandler
Definition: basehandler.h:281
static QXmlLocator * s_theLocator
Definition: basehandler.h:121
QString m_skipUntil
Definition: basehandler.h:279
int lineNumber()
Definition: qxml.cpp:292
IFallBackHandler * m_fallBackHandler
Definition: basehandler.h:282
const char * data() const
Definition: qcstring.h:207
virtual bool handleEndElement(const QString &name)=0
int columnNumber()
Definition: qxml.cpp:284
QString m_curString
Definition: basehandler.h:278
static msg_handler handler
Definition: qglobal.cpp:234
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Definition: qxml.cpp:1432
const bool TRUE
Definition: qglobal.h:371
template<class T>
IFallBackHandler* BaseHandler< T >::fallBackHandler ( ) const
inline

Definition at line 266 of file basehandler.h.

267  {
268  return m_fallBackHandler;
269  }
IFallBackHandler * m_fallBackHandler
Definition: basehandler.h:282
template<class T>
void BaseHandler< T >::setDelegate ( QXmlDefaultHandler delegate)
inlinevirtual

Implements IBaseHandler.

Definition at line 251 of file basehandler.h.

252  {
254  }
QXmlDefaultHandler * m_delegateHandler
Definition: basehandler.h:281
QXmlDefaultHandler * delegate() const
Definition: basehandler.h:256
template<class T>
void BaseHandler< T >::setDocumentLocator ( QXmlLocator locator)
inlinevirtual

The reader calls this function before he starts parsing the document. The argument locator is a pointer to a QXmlLocator which allows the application to get the actual position of the parsing in the document.

Do not destroy the locator; it is destroyed when the reader is destroyed (do not use the locator after the reader got destroyed).

Implements QXmlContentHandler.

Definition at line 271 of file basehandler.h.

272  {
273  debug(2,"setDocumentLocator(%p)\n",locator);
274  s_theLocator = locator;
275  }
static QXmlLocator * s_theLocator
Definition: basehandler.h:121
template<class T>
void BaseHandler< T >::setFallBackHandler ( IFallBackHandler h)
inline

Definition at line 261 of file basehandler.h.

262  {
264  }
IFallBackHandler * m_fallBackHandler
Definition: basehandler.h:282
template<class T>
bool BaseHandler< T >::skippedEntity ( const QString name)
inlinevirtual

Some readers may skip entities if they have not seen the declarations (e.g. because they are in an external DTD). If they do so they will report it by calling this function.

If this function returns FALSE the reader will stop parsing and will report an error. The reader will use the function errorString() to get the error message that will be used for reporting the error.

Implements QXmlContentHandler.

Definition at line 223 of file basehandler.h.

224  {
225  if (m_delegateHandler)
226  {
228  }
229 
230  debug(1,"line %d, col %d: Skipped unhandled entity %s\n",
232  s.data());
233  return TRUE;
234  }
QXmlDefaultHandler * m_delegateHandler
Definition: basehandler.h:281
static QXmlLocator * s_theLocator
Definition: basehandler.h:121
bool skippedEntity(const QString &name)
Definition: qxml.cpp:1466
int lineNumber()
Definition: qxml.cpp:292
const char * data() const
Definition: qcstring.h:207
int columnNumber()
Definition: qxml.cpp:284
static QCString * s
Definition: config.cpp:1042
const bool TRUE
Definition: qglobal.h:371
template<class T>
virtual bool BaseHandler< T >::startDocument ( )
inlinevirtual

The reader calls this function when he starts parsing the document. The reader will call this function only once before any other functions in this class or in the QXmlDTDHandler class are called (except QXmlContentHandler::setDocumentLocator()).

If this function returns FALSE the reader will stop parsing and will report an error. The reader will use the function errorString() to get the error message that will be used for reporting the error.

See also
endDocument()

Implements QXmlContentHandler.

Definition at line 144 of file basehandler.h.

145  {
146  return TRUE;
147  }
const bool TRUE
Definition: qglobal.h:371
template<class T>
virtual bool BaseHandler< T >::startElement ( const QString namespaceURI,
const QString localName,
const QString qName,
const QXmlAttributes atts 
)
inlinevirtual

The reader calls this function when he has parsed a start element tag.

There will be a corresponding endElement() call when the corresponding end element tag was read. The startElement() and endElement() calls are always nested correctly. Empty element tags (e.g. <a/>) are reported by startElement() directly followed by a call to endElement().

The attribute list provided will contain only attributes with explicit values. The attribute list will contain attributes used for namespace declaration (i.e. attributes starting with xmlns) only if the namespace-prefix property of the reader is TRUE.

The argument uri is the namespace URI, or the empty string if the element has no namespace URI or if namespace processing is not being performed, localName is the local name (without prefix), or the empty string if namespace processing is not being performed, qName is the qualified name (with prefix), or the empty string if qualified names are not available and atts are the attributes attached to the element. If there are no attributes, atts is an empty attributes object

If this function returns FALSE the reader will stop parsing and will report an error. The reader will use the function errorString() to get the error message that will be used for reporting the error.

See also the namespace description.

See also
endElement()

Implements QXmlContentHandler.

Definition at line 149 of file basehandler.h.

154  {
155  if (m_delegateHandler)
156  {
157  return m_delegateHandler->startElement(namespaceURI,localName,name,attrib);
158  }
159  if (!m_skipUntil.isEmpty()) // skip mode
160  {
161  if (m_skipUntil==name) m_skipCount++;
162  debug(1,"line %d, col %d: skipping start tag %s count=%d\n",
164  name.data(),m_skipCount);
165  return TRUE;
166  }
167 
169  if (handler)
170  {
171  (*handler)(attrib);
172  //printf("found start tag %s\n",name.data());
173  }
174  else if (!m_fallBackHandler ||
176  )
177  {
178  debug(1,"line %d, col %d: found unexpected tag `%s', skipping until matching end tag\n",
180  name.data());
181  m_skipUntil = name;
182  m_skipCount=1;
183  }
184  return TRUE;
185  }
static QCString name
Definition: declinfo.cpp:673
bool isEmpty() const
Definition: qstring.h:682
QXmlDefaultHandler * m_delegateHandler
Definition: basehandler.h:281
virtual bool handleStartElement(const QString &name, const QXmlAttributes &attrib)=0
static QXmlLocator * s_theLocator
Definition: basehandler.h:121
QString m_skipUntil
Definition: basehandler.h:279
int lineNumber()
Definition: qxml.cpp:292
IFallBackHandler * m_fallBackHandler
Definition: basehandler.h:282
const char * data() const
Definition: qcstring.h:207
int columnNumber()
Definition: qxml.cpp:284
ElementMapper< T >::StartElementHandlerT StartElementHandlerT
Definition: basehandler.h:132
bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Definition: qxml.cpp:1423
static msg_handler handler
Definition: qglobal.cpp:234
const bool TRUE
Definition: qglobal.h:371

Member Data Documentation

template<class T>
QString BaseHandler< T >::m_curString
protected

Definition at line 278 of file basehandler.h.

template<class T>
QXmlDefaultHandler* BaseHandler< T >::m_delegateHandler
protected

Definition at line 281 of file basehandler.h.

template<class T>
IFallBackHandler* BaseHandler< T >::m_fallBackHandler
protected

Definition at line 282 of file basehandler.h.

template<class T>
int BaseHandler< T >::m_skipCount
protected

Definition at line 280 of file basehandler.h.

template<class T>
QString BaseHandler< T >::m_skipUntil
protected

Definition at line 279 of file basehandler.h.


The documentation for this class was generated from the following file: