Isis 3 Programmer Reference
IsisXMLParameter.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 "IString.h"
15 
16 #include "IsisXMLParameter.h"
17 #include "IsisXMLChTrans.h"
18 
19 using namespace std;
20 
21 // Constructors
22 
23 IsisXMLParameter::IsisXMLParameter(char *PencodingName,
24  bool &PexpandNamespaces,
25  XERCES::SAX2XMLReader* &Pparser,
26  IsisParameterData *Pparameter) {
27 
28  encodingName = PencodingName;
29  expandNamespaces = PexpandNamespaces;
30  parser = Pparser;
31  parameter = Pparameter;
32 
33  prevDocHandler = parser->getContentHandler();
34  prevErrorHandler = parser->getErrorHandler();
35 
36  parser->setContentHandler(this);
37  parser->setErrorHandler(this);
38 
39  generalHandler = NULL;
40  multipleValuesHandler = NULL;
41  ignoreHandler = NULL;
42  listHandler = NULL;
43  helpersHandler = NULL;
44 }
45 
46 IsisXMLParameter::~IsisXMLParameter() {
47  if(generalHandler != NULL) {
48  delete generalHandler;
49  generalHandler = NULL;
50  }
51  if(multipleValuesHandler != NULL) {
52  delete multipleValuesHandler;
53  multipleValuesHandler = NULL;
54  }
55  if(ignoreHandler != NULL) {
56  delete ignoreHandler;
57  ignoreHandler = NULL;
58  }
59  if(listHandler != NULL) {
60  delete listHandler;
61  listHandler = NULL;
62  }
63  if(helpersHandler != NULL) {
64  delete helpersHandler;
65  helpersHandler = NULL;
66  }
67 }
68 
69 
70 // IsisXMLParameter: Overrides of the SAX DocumentHandler interface
71 void IsisXMLParameter::characters(const XMLCh *const chars,
72  const XMLSize_t length) {}
73 
74 
75 void IsisXMLParameter::endElement(const XMLCh *const uri,
76  const XMLCh *const localname,
77  const XMLCh *const qname) {
78  if((string)XERCES::XMLString::transcode(localname) != "list") {
79  parser->setContentHandler(prevDocHandler);
80  parser->setErrorHandler(prevErrorHandler);
81  }
82 }
83 
84 void IsisXMLParameter::startElement(const XMLCh *const uri,
85  const XMLCh *const localname,
86  const XMLCh *const qname,
87  const XERCES::Attributes &attributes) {
88  if((string)XERCES::XMLString::transcode(localname) == (string)"type") {
89  if(generalHandler != NULL) {
90  delete generalHandler;
91  generalHandler = NULL;
92  }
93  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
94  parser, &parameter->type);
95  }
96  else if((string)XERCES::XMLString::transcode(localname) == (string)"brief") {
97  if(generalHandler != NULL) {
98  delete generalHandler;
99  generalHandler = NULL;
100  }
101  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
102  parser, &parameter->brief);
103  }
104  else if((string)XERCES::XMLString::transcode(localname) == (string)"description") {
105  if(generalHandler != NULL) {
106  delete generalHandler;
107  generalHandler = NULL;
108  }
109  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
110  parser, &parameter->description);
111  }
112  else if((string)XERCES::XMLString::transcode(localname) == (string)"default") {
113  if(multipleValuesHandler != NULL) {
114  delete multipleValuesHandler;
115  multipleValuesHandler = NULL;
116  }
117  multipleValuesHandler = new IsisXMLMultipleValues(encodingName, expandNamespaces,
118  parser, &parameter->defaultValues);
119  }
120  else if((string)XERCES::XMLString::transcode(localname) == (string)"internalDefault") {
121  if(generalHandler != NULL) {
122  delete generalHandler;
123  generalHandler = NULL;
124  }
125  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces, parser,
126  &parameter->internalDefault);
127  }
128  else if((string)XERCES::XMLString::transcode(localname) == (string)"count") {
129  if(generalHandler != NULL) {
130  delete generalHandler;
131  generalHandler = NULL;
132  }
133  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces, parser,
134  &parameter->count);
135  }
136  else if((string)XERCES::XMLString::transcode(localname) == (string)"list") {
137  }
138  else if((string)XERCES::XMLString::transcode(localname) == (string)"option") {
139  if(listHandler != NULL) {
140  delete listHandler;
141  listHandler = NULL;
142  }
143  unsigned int index = parameter->listOptions.size();
144  parameter->listOptions.resize(index + 1);
145  QString lo = XERCES::XMLString::transcode(attributes.getValue((XMLSize_t)0));
146  lo = lo.toUpper();
147  parameter->listOptions[index].value = lo;
148  listHandler = new IsisXMLList(encodingName, expandNamespaces, parser,
149  &parameter->listOptions[index]);
150  }
151  else if((string)XERCES::XMLString::transcode(localname) == (string)"minimum") {
152  if(generalHandler != NULL) {
153  delete generalHandler;
154  generalHandler = NULL;
155  }
156  QString mi = XERCES::XMLString::transcode(attributes.getValue((XMLSize_t)0));
157  parameter->minimum_inclusive = mi.toLower();
158  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces,
159  parser, &parameter->minimum);
160  }
161  else if((string)XERCES::XMLString::transcode(localname) == (string)"maximum") {
162  if(generalHandler != NULL) {
163  delete generalHandler;
164  generalHandler = NULL;
165  }
166  QString mi = XERCES::XMLString::transcode(attributes.getValue((XMLSize_t)0));
167  parameter->maximum_inclusive = mi.toLower();
168  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces, parser,
169  &parameter->maximum);
170  }
171  else if((string)XERCES::XMLString::transcode(localname) == (string)"greaterThan") {
172  if(multipleValuesHandler != NULL) {
173  delete multipleValuesHandler;
174  multipleValuesHandler = NULL;
175  }
176  multipleValuesHandler = new IsisXMLMultipleValues(encodingName, expandNamespaces,
177  parser, &parameter->greaterThan);
178  }
179  else if((string)XERCES::XMLString::transcode(localname) == (string)"greaterThanOrEqual") {
180  if(multipleValuesHandler != NULL) {
181  delete multipleValuesHandler;
182  multipleValuesHandler = NULL;
183  }
184  multipleValuesHandler = new IsisXMLMultipleValues(encodingName, expandNamespaces,
185  parser, &parameter->greaterThanOrEqual);
186  }
187  else if((string)XERCES::XMLString::transcode(localname) == (string)"lessThan") {
188  if(multipleValuesHandler != NULL) {
189  delete multipleValuesHandler;
190  multipleValuesHandler = NULL;
191  }
192  multipleValuesHandler = new IsisXMLMultipleValues(encodingName, expandNamespaces,
193  parser, &parameter->lessThan);
194  }
195  else if((string)XERCES::XMLString::transcode(localname) == (string)"lessThanOrEqual") {
196  if(multipleValuesHandler != NULL) {
197  delete multipleValuesHandler;
198  multipleValuesHandler = NULL;
199  }
200  multipleValuesHandler = new IsisXMLMultipleValues(encodingName, expandNamespaces,
201  parser, &parameter->lessThanOrEqual);
202  }
203  else if((string)XERCES::XMLString::transcode(localname) == (string)"notEqual") {
204  if(multipleValuesHandler != NULL) {
205  delete multipleValuesHandler;
206  multipleValuesHandler = NULL;
207  }
208  multipleValuesHandler = new IsisXMLMultipleValues(encodingName, expandNamespaces,
209  parser, &parameter->notEqual);
210  }
211  else if((string)XERCES::XMLString::transcode(localname) == (string)"odd") {
212  if(generalHandler != NULL) {
213  delete generalHandler;
214  generalHandler = NULL;
215  }
216  parameter->odd = "TRUE";
217  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces, parser);
218 
219  }
220  else if((string)XERCES::XMLString::transcode(localname) == (string)"exclusions") {
221  if(multipleValuesHandler != NULL) {
222  delete multipleValuesHandler;
223  multipleValuesHandler = NULL;
224  }
225  multipleValuesHandler = new IsisXMLMultipleValues(encodingName, expandNamespaces,
226  parser, &parameter->exclude);
227  }
228  else if((string)XERCES::XMLString::transcode(localname) == (string)"inclusions") {
229  if(multipleValuesHandler != NULL) {
230  delete multipleValuesHandler;
231  multipleValuesHandler = NULL;
232  }
233  multipleValuesHandler = new IsisXMLMultipleValues(encodingName, expandNamespaces,
234  parser, &parameter->include);
235  }
236  else if((string)XERCES::XMLString::transcode(localname) == (string)"filter") {
237  if(generalHandler != NULL) {
238  delete generalHandler;
239  generalHandler = NULL;
240  }
241  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces, parser, &parameter->filter);
242  }
243  else if((string)XERCES::XMLString::transcode(localname) == (string)"defaultPath") {
244  if(generalHandler != NULL) {
245  delete generalHandler;
246  generalHandler = NULL;
247  }
248  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces, parser,
249  &parameter->path);
250  }
251  else if((string)XERCES::XMLString::transcode(localname) == (string)"fileMode") {
252  if(generalHandler != NULL) {
253  delete generalHandler;
254  generalHandler = NULL;
255  }
256  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces, parser, &parameter->fileMode);
257  }
258  else if((string)XERCES::XMLString::transcode(localname) == (string)"pixelType") {
259  if(generalHandler != NULL) {
260  delete generalHandler;
261  generalHandler = NULL;
262  }
263  generalHandler = new IsisXMLHandler(encodingName, expandNamespaces, parser, &parameter->pixelType);
264  }
265  else if((string)XERCES::XMLString::transcode(localname) == (string)"helpers") {
266  if(helpersHandler != NULL) {
267  delete helpersHandler;
268  helpersHandler = NULL;
269  }
270  helpersHandler = new IsisXMLHelpers(encodingName, expandNamespaces, parser,
271  &parameter->helpers);
272  }
273  else {
274  if(ignoreHandler != NULL) {
275  delete ignoreHandler;
276  ignoreHandler = NULL;
277  }
278  ignoreHandler = new IsisXMLIgnore(encodingName, expandNamespaces, parser,
279  (string)XERCES::XMLString::transcode(localname));
280  }
281 }
IsisXMLHelpers
This is free and unencumbered software released into the public domain.
Definition: IsisXMLHelpers.h:18
IsisParameterData
Definition: IsisAmlData.h:53
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
IsisXMLMultipleValues
This is free and unencumbered software released into the public domain.
Definition: IsisXMLMultipleValues.h:18
IsisXMLList
This is free and unencumbered software released into the public domain.
Definition: IsisXMLList.h:18