Isis 3 Programmer Reference
IsisXMLMultipleValues.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include <string>
8 
9 #include <xercesc/util/PlatformUtils.hpp>
10 #include <xercesc/sax2/SAX2XMLReader.hpp>
11 
12 #include "IsisXMLMultipleValues.h"
13 #include "IsisXMLChTrans.h"
14 
15 using namespace std;
16 
17 // Constructors
18 
19 IsisXMLMultipleValues::IsisXMLMultipleValues(char *PencodingName,
20  bool &PexpandNamespaces,
21  XERCES::SAX2XMLReader* &Pparser,
22  std::vector<QString> *PmultipleValues) {
23 
24  encodingName = PencodingName;
25  expandNamespaces = PexpandNamespaces;
26  parser = Pparser;
27  multipleValues = PmultipleValues;
28 
29  prevDocHandler = parser->getContentHandler();
30  prevErrorHandler = parser->getErrorHandler();
31 
32  parser->setContentHandler(this);
33  parser->setErrorHandler(this);
34 
35  generalHandler = NULL;
36  ignoreHandler = NULL;
37 }
38 
39 IsisXMLMultipleValues::~IsisXMLMultipleValues() {
40  if(generalHandler != NULL) delete generalHandler;
41  if(ignoreHandler != NULL) delete ignoreHandler;
42 }
43 
44 
45 // IsisXMLMultipleValues: Overrides of the SAX DocumentHandler interface
46 void IsisXMLMultipleValues::characters(const XMLCh *const chars,
47  const XMLSize_t length) {}
48 
49 
50 void IsisXMLMultipleValues::endElement(const XMLCh *const uri,
51  const XMLCh *const localname,
52  const XMLCh *const qname) {
53  parser->setContentHandler(prevDocHandler);
54  parser->setErrorHandler(prevErrorHandler);
55 }
56 
57 
58 void IsisXMLMultipleValues::startElement(const XMLCh *const uri,
59  const XMLCh *const localname,
60  const XMLCh *const qname,
61  const XERCES::Attributes &attributes) {
62 
63  if((string)XERCES::XMLString::transcode(localname) == (string)"item") {
64  if(generalHandler != NULL) {
65  delete generalHandler;
66  generalHandler = NULL;
67  }
68  unsigned int index = multipleValues->size();
69  multipleValues->resize(index + 1);
70  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
71  parser, &(*multipleValues)[index]);
72  }
73  else {
74  if(ignoreHandler != NULL) {
75  delete ignoreHandler;
76  ignoreHandler = NULL;
77  }
78  ignoreHandler = new IsisXMLIgnore(encodingName, expandNamespaces, parser,
79  (string)XERCES::XMLString::transcode(localname));
80  }
81 }
IsisXMLHandler
This is free and unencumbered software released into the public domain.
Definition: IsisXMLHandler.h:18
std
Namespace for the standard library.
IsisXMLIgnore
This is free and unencumbered software released into the public domain.
Definition: IsisXMLIgnore.h:18