Isis 3 Programmer Reference
XmlStackedHandlerReader.cpp
1 #include "XmlStackedHandlerReader.h"
2 
3 #include <QDebug>
4 #include <QStack>
5 
6 #include "XmlStackedHandler.h"
7 
8 namespace Isis {
9  XmlStackedHandlerReader::XmlStackedHandlerReader() {
10  m_contentHandlers = NULL;
11  m_contentHandlers = new QStack<XmlStackedHandler *>;
12  }
13 
14 
15  XmlStackedHandlerReader::~XmlStackedHandlerReader() {
16  delete m_contentHandlers;
17  m_contentHandlers = NULL;
18  }
19 
20 
21  void XmlStackedHandlerReader::popContentHandler() {
22  m_contentHandlers->pop();
23 
24  if (m_contentHandlers->size()) {
25  m_contentHandlers->top()->setReader(this);
26  setContentHandler(m_contentHandlers->top());
27  }
28  else {
29  setContentHandler(NULL);
30  }
31  }
32 
33 
50  XmlStackedHandler *old = topContentHandler();
51 
52  newHandler->setReader(this);
53  m_contentHandlers->push(newHandler);
54 
55  setContentHandler(m_contentHandlers->top());
56 
57  if (old) {
58  // Switch to newHandler and continue parsing
59  // This will call newHandler->startElement(...)
60  old->switchToNewHandler(topContentHandler());
61  }
62  }
63 
64 
65  XmlStackedHandler *XmlStackedHandlerReader::topContentHandler() {
66  XmlStackedHandler *result = NULL;
67 
68  if (m_contentHandlers->size())
69  result = m_contentHandlers->top();
70 
71  return result;
72  }
73 }
74 
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
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