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