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