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