Isis 3 Programmer Reference
XmlStackedHandlerReader.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "XmlStackedHandlerReader.h"
8 
9 #include <QDebug>
10 #include <QStack>
11 
12 #include "XmlStackedHandler.h"
13 
14 namespace Isis {
15  XmlStackedHandlerReader::XmlStackedHandlerReader() {
16  m_contentHandlers = NULL;
17  m_contentHandlers = new QStack<XmlStackedHandler *>;
18  }
19 
20 
21  XmlStackedHandlerReader::~XmlStackedHandlerReader() {
22  delete m_contentHandlers;
23  m_contentHandlers = NULL;
24  }
25 
26 
27  void XmlStackedHandlerReader::popContentHandler() {
28  m_contentHandlers->pop();
29 
30  if (m_contentHandlers->size()) {
31  m_contentHandlers->top()->setReader(this);
32  setContentHandler(m_contentHandlers->top());
33  }
34  else {
35  setContentHandler(NULL);
36  }
37  }
38 
39 
56  XmlStackedHandler *old = topContentHandler();
57 
58  newHandler->setReader(this);
59  m_contentHandlers->push(newHandler);
60 
61  setContentHandler(m_contentHandlers->top());
62 
63  if (old) {
64  // Switch to newHandler and continue parsing
65  // This will call newHandler->startElement(...)
66  old->switchToNewHandler(topContentHandler());
67  }
68  }
69 
70 
71  XmlStackedHandler *XmlStackedHandlerReader::topContentHandler() {
72  XmlStackedHandler *result = NULL;
73 
74  if (m_contentHandlers->size())
75  result = m_contentHandlers->top();
76 
77  return result;
78  }
79 }
80 
QStack
This is free and unencumbered software released into the public domain.
Definition: Calculator.h:17
Isis::XmlStackedHandlerReader::pushContentHandler
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
Definition: XmlStackedHandlerReader.cpp:55
Isis::XmlStackedHandler
XML Handler that parses XMLs in a stack-oriented way.
Definition: XmlStackedHandler.h:118
Isis::XmlStackedHandler::switchToNewHandler
void switchToNewHandler(XmlStackedHandler *nextHandler)
Switch to a new content handler and continue processing using the new handler.
Definition: XmlStackedHandler.cpp:38
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16