Isis 3 Programmer Reference
IsisXMLMultipleValues.cpp
Go to the documentation of this file.
1 
24 #include <string>
25 
26 #include <xercesc/util/PlatformUtils.hpp>
27 #include <xercesc/sax2/SAX2XMLReader.hpp>
28 
29 #include "IsisXMLMultipleValues.h"
30 #include "IsisXMLChTrans.h"
31 
32 using namespace std;
33 
34 // Constructors
35 
36 IsisXMLMultipleValues::IsisXMLMultipleValues(char *PencodingName,
37  bool &PexpandNamespaces,
38  XERCES::SAX2XMLReader* &Pparser,
39  std::vector<QString> *PmultipleValues) {
40 
41  encodingName = PencodingName;
42  expandNamespaces = PexpandNamespaces;
43  parser = Pparser;
44  multipleValues = PmultipleValues;
45 
46  prevDocHandler = parser->getContentHandler();
47  prevErrorHandler = parser->getErrorHandler();
48 
49  parser->setContentHandler(this);
50  parser->setErrorHandler(this);
51 
52  generalHandler = NULL;
53  ignoreHandler = NULL;
54 }
55 
56 IsisXMLMultipleValues::~IsisXMLMultipleValues() {
57  if(generalHandler != NULL) delete generalHandler;
58  if(ignoreHandler != NULL) delete ignoreHandler;
59 }
60 
61 
62 // IsisXMLMultipleValues: Overrides of the SAX DocumentHandler interface
63 void IsisXMLMultipleValues::characters(const XMLCh *const chars,
64  const XMLSize_t length) {}
65 
66 
67 void IsisXMLMultipleValues::endElement(const XMLCh *const uri,
68  const XMLCh *const localname,
69  const XMLCh *const qname) {
70  parser->setContentHandler(prevDocHandler);
71  parser->setErrorHandler(prevErrorHandler);
72 }
73 
74 
75 void IsisXMLMultipleValues::startElement(const XMLCh *const uri,
76  const XMLCh *const localname,
77  const XMLCh *const qname,
78  const XERCES::Attributes &attributes) {
79 
80  if((string)XERCES::XMLString::transcode(localname) == (string)"item") {
81  if(generalHandler != NULL) {
82  delete generalHandler;
83  generalHandler = NULL;
84  }
85  unsigned int index = multipleValues->size();
86  multipleValues->resize(index + 1);
87  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
88  parser, &(*multipleValues)[index]);
89  }
90  else {
91  if(ignoreHandler != NULL) {
92  delete ignoreHandler;
93  ignoreHandler = NULL;
94  }
95  ignoreHandler = new IsisXMLIgnore(encodingName, expandNamespaces, parser,
96  (string)XERCES::XMLString::transcode(localname));
97  }
98 }
Namespace for the standard library.