Isis 3 Programmer Reference
XmlStackedHandler.cpp
1 #include "IsisDebug.h"
2 #include "XmlStackedHandler.h"
3 
4 #include <QDebug>
5 #include <QStack>
6 #include <QXmlParseException>
7 
8 #include "XmlStackedHandlerReader.h"
9 
10 namespace Isis {
11  XmlStackedHandler::XmlStackedHandler() {
12  m_reader = NULL;
13  m_depth = 0;
14  }
15 
16 
17  XmlStackedHandler::~XmlStackedHandler() {
18  m_reader = NULL;
19  m_depth = 0;
20  }
21 
22 
23  void XmlStackedHandler::setReader(XmlStackedHandlerReader *reader) {
24  m_reader = reader;
25  }
26 
27 
33  nextHandler->startElement(m_lastStartNamespaceURI, m_lastStartLocalName,
34  m_lastStartQName, m_lastStartAtts);
35  }
36 
37 
38  bool XmlStackedHandler::startElement(const QString &namespaceURI, const QString &localName,
39  const QString &qName, const QXmlAttributes &atts) {
40  m_lastStartNamespaceURI = namespaceURI;
41  m_lastStartLocalName = localName;
42  m_lastStartQName = qName;
43  m_lastStartAtts = atts;
44  m_depth++;
45 
46  return true;
47  }
48 
49  bool XmlStackedHandler::endElement(const QString &namespaceURI, const QString &localName,
50  const QString &qName) {
51  m_depth--;
52 
53  ASSERT(m_depth >= 0);
54  if (m_depth == 0 && reader()) {
55  reader()->popContentHandler();
56 
57  if (reader()->topContentHandler())
58  reader()->topContentHandler()->endElement(namespaceURI, localName, qName);
59  }
60 
61  return true;
62  }
63 
64  XmlStackedHandlerReader *XmlStackedHandler::reader() {
65  return m_reader;
66  }
67 
68 
69  const XmlStackedHandlerReader *XmlStackedHandler::reader() const {
70  return m_reader;
71  }
72 
73 
74  bool XmlStackedHandler::fatalError(const QXmlParseException &exception) {
75  qDebug() << "Parse error at line " << exception.lineNumber()
76  << ", " << "column " << exception.columnNumber() << ": "
77  << qPrintable(exception.message());
78  return false;
79  }
80 
81 }
XML Handler that parses XMLs in a stack-oriented way.
void switchToNewHandler(XmlStackedHandler *nextHandler)
Switch to a new content handler and continue processing using the new handler.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31