Line data Source code
1 : #include <alma/ASDMBinaries/SDMDataObjectParser.h>
2 : #include <iostream>
3 : #include <sstream>
4 : #include <string>
5 : #include <algorithm>
6 : #include <vector>
7 : #include <iterator>
8 :
9 : using namespace AtmPhaseCorrectionMod;
10 : using namespace AxisNameMod;
11 : using namespace BasebandNameMod;
12 : using namespace CorrelationModeMod;
13 : using namespace CorrelatorTypeMod;
14 : using namespace NetSidebandMod;
15 : using namespace PrimitiveDataTypeMod;
16 : using namespace ProcessorTypeMod;
17 : using namespace SpectralResolutionTypeMod;
18 : using namespace StokesParameterMod;
19 :
20 : using namespace std;
21 :
22 : namespace asdmbinaries {
23 :
24 : // Names of XML elements/attributes in an sdmDataHeader.
25 :
26 : #ifndef WITHOUT_BOOST
27 : const boost::regex HeaderParser::PROJECTPATH3("([0-9]+)/([0-9]+)/([0-9]+)/");
28 : #else
29 : const std::regex HeaderParser::PROJECTPATH3("([0-9]+)/([0-9]+)/([0-9]+)/");
30 : #endif
31 : const string HeaderParser::SDMDATAHEADER = "sdmDataHeader";
32 : const string HeaderParser::SCHEMAVERSION = "schemaVersion";
33 : const string HeaderParser::BYTEORDER = "byteOrder";
34 : const string HeaderParser::PROJECTPATH = "projectPath";
35 : const string HeaderParser::STARTTIME = "startTime";
36 : const string HeaderParser::DATAOID = "dataOID";
37 : const string HeaderParser::XLINKHREF = "href";
38 : const string HeaderParser::XLINKTITLE = "title";
39 : const string HeaderParser::DIMENSIONALITY = "dimensionality";
40 : const string HeaderParser::NUMTIME = "numTime";
41 : const string HeaderParser::EXECBLOCK = "execBlock";
42 : const string HeaderParser::EXECBLOCKNUM = "execBlockNum";
43 : const string HeaderParser::SCANNUM = "scanNum";
44 : const string HeaderParser::SUBSCANNUM = "subscanNum";
45 : const string HeaderParser::NUMANTENNA = "numAntenna";
46 : const string HeaderParser::CORRELATIONMODE = "correlationMode";
47 : const string HeaderParser::SPECTRALRESOLUTION = "spectralResolution";
48 : const string HeaderParser::PROCESSORTYPE = "processorType";
49 : const string HeaderParser::DATASTRUCT = "dataStruct";
50 : const string HeaderParser::APC = "apc";
51 : const string HeaderParser::REF = "ref";
52 : const string HeaderParser::BASEBAND = "baseband";
53 : const string HeaderParser::NAME = "name";
54 : const string HeaderParser::SPECTRALWINDOW = "spectralWindow";
55 : const string HeaderParser::SW = "sw";
56 : const string HeaderParser::SWBB = "swbb";
57 : const string HeaderParser::CROSSPOLPRODUCTS = "crossPolProducts";
58 : const string HeaderParser::SDPOLPRODUCTS = "sdPolProducts";
59 : const string HeaderParser::SCALEFACTOR = "scaleFactor";
60 : const string HeaderParser::NUMSPECTRALPOINT = "numSpectralPoint";
61 : const string HeaderParser::NUMBIN = "numBin";
62 : const string HeaderParser::SIDEBAND = "sideband";
63 : const string HeaderParser::IMAGE = "image";
64 : const string HeaderParser::FLAGS = "flags";
65 : const string HeaderParser::ACTUALTIMES = "actualTimes";
66 : const string HeaderParser::ACTUALDURATIONS = "actualDurations";
67 : const string HeaderParser::ZEROLAGS = "zeroLags";
68 : const string HeaderParser::CORRELATORTYPE = "correlatorType";
69 : const string HeaderParser::CROSSDATA = "crossData";
70 : const string HeaderParser::AUTODATA = "autoData";
71 : const string HeaderParser::NORMALIZED = "normalized";
72 : const string HeaderParser::SIZE = "size";
73 : const string HeaderParser::AXES = "axes";
74 : const string HeaderParser::TYPE = "type";
75 :
76 :
77 : // Names of XML elements/attributes in an sdmSubsetDataHeader with dimensionality==1 (Correlator)
78 :
79 : #ifndef WITHOUT_BOOST
80 : const boost::regex SDMDataObjectParser::PROJECTPATH3("([0-9]+)/([0-9]+)/([0-9]+)/");
81 : const boost::regex SDMDataObjectParser::PROJECTPATH4("([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/");
82 : const boost::regex SDMDataObjectParser::PROJECTPATH5("([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/");
83 : #else
84 : const std::regex SDMDataObjectParser::PROJECTPATH3("([0-9]+)/([0-9]+)/([0-9]+)/");
85 : const std::regex SDMDataObjectParser::PROJECTPATH4("([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/");
86 : const std::regex SDMDataObjectParser::PROJECTPATH5("([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/");
87 : #endif
88 :
89 :
90 : const string CorrSubsetHeaderParser::SDMDATASUBSETHEADER = "sdmDataSubsetHeader";
91 : const string CorrSubsetHeaderParser::PROJECTPATH = "projectPath";
92 : const string CorrSubsetHeaderParser::SCHEDULEPERIODTIME = "schedulePeriodTime";
93 : const string CorrSubsetHeaderParser::TIME = "time";
94 : const string CorrSubsetHeaderParser::INTERVAL = "interval";
95 : const string CorrSubsetHeaderParser::DATASTRUCT = "dataStruct";
96 : const string CorrSubsetHeaderParser::REF = "ref";
97 : const string CorrSubsetHeaderParser::ABORTOBSERVATION = "abortObservation";
98 : const string CorrSubsetHeaderParser::ABORTTIME = "stopTime";
99 : const string CorrSubsetHeaderParser::ABORTREASON = "abortReason";
100 : const string CorrSubsetHeaderParser::XLINKHREF = "href";
101 : const string CorrSubsetHeaderParser::DATAREF = "dataRef";
102 : const string CorrSubsetHeaderParser::FLAGSREF = "flags";
103 : const string CorrSubsetHeaderParser::ACTUALTIMESREF = "actualTimes";
104 : const string CorrSubsetHeaderParser::ACTUALDURATIONSREF = "actualDurations";
105 : const string CorrSubsetHeaderParser::ZEROLAGSREF = "zeroLags";
106 : const string CorrSubsetHeaderParser::CROSSDATAREF = "crossData";
107 : const string CorrSubsetHeaderParser::AUTODATAREF = "autoData";
108 : const string CorrSubsetHeaderParser::TYPE = "type";
109 :
110 : // Names of XML elements/attributes in an sdmSubsetDataHeader with dimensionality==0 (TP)
111 : #ifndef WITHOUT_BOOST
112 : const boost::regex TPSubsetHeaderParser::PROJECTPATH3("([0-9]+)/([0-9]+)/([0-9]+)/");
113 : #else
114 : const std::regex TPSubsetHeaderParser::PROJECTPATH3("([0-9]+)/([0-9]+)/([0-9]+)/");
115 : #endif
116 : const string TPSubsetHeaderParser::SDMDATASUBSETHEADER = "sdmDataSubsetHeader";
117 : const string TPSubsetHeaderParser::PROJECTPATH = "projectPath";
118 : const string TPSubsetHeaderParser::SCHEDULEPERIODTIME = "schedulePeriodTime";
119 : const string TPSubsetHeaderParser::TIME = "time";
120 : const string TPSubsetHeaderParser::INTERVAL = "interval";
121 : const string TPSubsetHeaderParser::DATASTRUCT = "dataStruct";
122 : const string TPSubsetHeaderParser::REF = "ref";
123 : const string TPSubsetHeaderParser::DATAREF = "dataRef";
124 : const string TPSubsetHeaderParser::XLINKHREF = "href";
125 : const string TPSubsetHeaderParser::FLAGSREF = "flags";
126 : const string TPSubsetHeaderParser::ACTUALTIMESREF = "actualTimes";
127 : const string TPSubsetHeaderParser::ACTUALDURATIONSREF = "actualDurations";
128 : const string TPSubsetHeaderParser::AUTODATAREF = "autoData";
129 :
130 : // HeaderParser methods.
131 933 : HeaderParser::HeaderParser(){
132 933 : doc = NULL;
133 933 : }
134 :
135 933 : HeaderParser::~HeaderParser() {
136 933 : if (doc != NULL) xmlFreeDoc(doc);
137 933 : }
138 :
139 0 : void HeaderParser::parseFile(const string& filename, SDMDataObject& sdmDataObject){
140 0 : if (doc != NULL) xmlFreeDoc(doc);
141 0 : doc = xmlReadFile(filename.c_str(), NULL, XML_PARSE_NOBLANKS);
142 0 : if (doc == NULL) {
143 0 : throw SDMDataObjectParserException("The file '"+filename+"' could not be transformed into a DOM structure");
144 : }
145 :
146 0 : xmlNode* root_element = xmlDocGetRootElement(doc);
147 0 : parseSDMDataHeader(root_element, sdmDataObject);
148 0 : }
149 :
150 2951 : void HeaderParser::parseMemory(const string& buffer, SDMDataObject& sdmDataObject) {
151 2951 : if (doc != NULL) xmlFreeDoc(doc);
152 2951 : doc = xmlReadMemory(buffer.data(), buffer.size(), "SDMDataHeader.xml", NULL, XML_PARSE_NOBLANKS );
153 2951 : if (doc == NULL) {
154 0 : throw SDMDataObjectParserException("The buffer containing the XML document could not be transformed into a DOM structure");
155 : }
156 :
157 2951 : xmlNode* root_element = xmlDocGetRootElement(doc);
158 2951 : parseSDMDataHeader(root_element, sdmDataObject);
159 2951 : }
160 :
161 0 : void HeaderParser::reset() {
162 0 : if (doc)
163 0 : xmlFreeDoc(doc);
164 :
165 0 : doc = NULL;
166 0 : }
167 :
168 2951 : void HeaderParser::parseSDMDataHeader(xmlNode* a_node, SDMDataObject& sdmDataObject){
169 : //cout << "Entering parseSDMDataHeader" << endl;
170 : // Look up for the <sdmDataHeader ... element.
171 2951 : SDMDataObjectParser::isElement(a_node, HeaderParser::SDMDATAHEADER);
172 :
173 : // And parse some of its attributes.
174 2951 : sdmDataObject.schemaVersion_ = SDMDataObjectParser::parseIntAttr(a_node, HeaderParser::SCHEMAVERSION);
175 2951 : sdmDataObject.byteOrder_ = SDMDataObjectParser::parseByteOrderAttr(a_node, HeaderParser::BYTEORDER);
176 :
177 :
178 : // Look up for its projectPath attribute
179 : // and determine execBlockNum, scanNum and subscanNum from its projectPath attribute.
180 2951 : vector<unsigned int> v = SDMDataObjectParser::parseProjectPath(a_node, 3);
181 2951 : sdmDataObject.execBlockNum_ = v.at(0);
182 2951 : sdmDataObject.scanNum_ = v.at(1);
183 2951 : sdmDataObject.subscanNum_ = v.at(2);
184 :
185 : // Traverse the children.
186 2951 : xmlNode* child = a_node->children;
187 :
188 : // Look up for the <startTime... child
189 2951 : sdmDataObject.startTime(parseStartTime(child));
190 :
191 : // Look up for the <dataOID... child
192 2951 : child = child->next;
193 2951 : sdmDataObject.dataOID(parseDataOID(child));
194 :
195 : // ...and its title attribute
196 2951 : sdmDataObject.title(SDMDataObjectParser::parseStringAttr(child, HeaderParser::XLINKTITLE));
197 :
198 : // Look up for the <dimensionality...
199 2951 : child = child->next;
200 2951 : unsigned int dimensionality = parseDimensionality(child);
201 2951 : sdmDataObject.dimensionality(dimensionality);
202 :
203 2951 : if ( dimensionality == 0 ) {
204 : // Look up for numTime... only if dimensionality == 0
205 883 : sdmDataObject.numTime((unsigned int) parseNumTime(child) );
206 : }
207 :
208 : // Look up for the <execBlock... child
209 2951 : child = child->next;
210 2951 : parseExecBlock(child, sdmDataObject);
211 :
212 : // Look up for the <numAntenna... child
213 2951 : child = child->next;
214 2951 : int numAntenna = parseNumAntenna(child); //cout << child->name << "=" << numAntenna << endl;
215 2951 : sdmDataObject.numAntenna((unsigned int) numAntenna);
216 :
217 : // Look up for the <correlationMode> ... child
218 2951 : child = child->next;
219 2951 : parseCorrelationMode(child, sdmDataObject);
220 :
221 : // Look up for the <spectralResolution> ... child
222 2951 : child = child->next;
223 2951 : parseSpectralResolution(child, sdmDataObject);
224 :
225 : // Look up for child <processorType> ... child
226 2951 : child = child->next;
227 2951 : parseProcessorType(child, sdmDataObject);
228 :
229 : // Look up for the <dataStruct> ... child
230 2951 : child = child->next;
231 2951 : parseDataStruct(child, sdmDataObject);
232 :
233 : //cout << "Exiting parseSDMDataHeader" << endl;
234 2951 : }
235 :
236 : // void HeaderParser::parseProjectPath(xmlNode* a_node, SDMDataObject& sdmDataObject) {
237 : // string projectPath = SDMDataObjectParser::parseStringAttr(a_node, HeaderParser::PROJECTPATH);
238 :
239 : // boost::cmatch what;
240 :
241 : // if (boost::regex_match(projectPath.c_str(), what,PROJECTPATH3) && what[0].matched) {
242 : // sdmDataObject.execBlockNum(::atoi(what[1].first));
243 : // sdmDataObject.scanNum(::atoi(what[2].first));
244 : // sdmDataObject.subscanNum(::atoi(what[3].first));
245 : // }
246 : // else
247 : // throw SDMDataObjectParserException("HeaderParser::parseProjectPath: Invalid string for projectPath '" + projectPath + "'");
248 : // }
249 :
250 2951 : long long HeaderParser::parseStartTime(xmlNode* a_node){
251 2951 : SDMDataObjectParser::isElement(a_node, HeaderParser::STARTTIME);
252 2951 : return SDMDataObjectParser::parseLongLong(a_node->children);
253 : }
254 :
255 2951 : string HeaderParser::parseDataOID(xmlNode* a_node) {
256 2951 : SDMDataObjectParser::isElement(a_node, HeaderParser::DATAOID);
257 :
258 : // Look for attribute
259 2951 : string dataOID = SDMDataObjectParser::parseStringAttr(a_node, HeaderParser::XLINKHREF);
260 2951 : return dataOID;
261 : }
262 :
263 2951 : int HeaderParser::parseDimensionality(xmlNode* a_node) {
264 : //cout << "Entering parseDimensionality with " << a_node->name << endl;
265 2951 : if (SDMDataObjectParser::testElement(a_node, HeaderParser::DIMENSIONALITY)) {
266 2068 : return SDMDataObjectParser::parseInt(a_node->children);
267 : }
268 : else
269 883 : return 0;
270 : }
271 :
272 883 : int HeaderParser::parseNumTime(xmlNode* a_node) {
273 883 : SDMDataObjectParser::isElement(a_node, HeaderParser::NUMTIME);
274 883 : return SDMDataObjectParser::parseInt(a_node->children);
275 : }
276 :
277 2951 : void HeaderParser::parseExecBlock(xmlNode* a_node, SDMDataObject& sdmDataObject){
278 : //cout << "Entering parseExecBlock with " << a_node << endl;
279 :
280 2951 : SDMDataObjectParser::isElement(a_node, HeaderParser::EXECBLOCK);
281 :
282 : // Look up for the execBlockUID attribute.
283 2951 : sdmDataObject.execBlockUID(SDMDataObjectParser::parseStringAttr(a_node, HeaderParser::XLINKHREF));
284 2951 : }
285 :
286 0 : int HeaderParser::parseExecBlockNum(xmlNode* a_node){
287 0 : SDMDataObjectParser::isElement(a_node, HeaderParser::EXECBLOCKNUM);
288 0 : return SDMDataObjectParser::parseInt(a_node->children);
289 : }
290 :
291 0 : int HeaderParser::parseScanNum(xmlNode* a_node){
292 0 : SDMDataObjectParser::isElement(a_node, HeaderParser::SCANNUM);
293 0 : return SDMDataObjectParser::parseInt(a_node->children);
294 : }
295 :
296 0 : int HeaderParser::parseSubscanNum(xmlNode* a_node){
297 0 : SDMDataObjectParser::isElement(a_node, HeaderParser::SUBSCANNUM);
298 0 : return SDMDataObjectParser::parseInt(a_node->children);
299 : }
300 :
301 2951 : int HeaderParser::parseNumAntenna(xmlNode* a_node){
302 2951 : SDMDataObjectParser::isElement(a_node, HeaderParser::NUMANTENNA);
303 2951 : return SDMDataObjectParser::parseInt(a_node->children);
304 : }
305 :
306 2951 : void HeaderParser::parseCorrelationMode(xmlNode* a_node, SDMDataObject& sdmDataObject) {
307 2951 : SDMDataObjectParser::isElement(a_node, HeaderParser::CORRELATIONMODE);
308 2951 : sdmDataObject.correlationMode_ = SDMDataObjectParser::parseLiteral<CorrelationMode, CCorrelationMode>(a_node->children);
309 2951 : }
310 :
311 2951 : void HeaderParser::parseSpectralResolution(xmlNode* a_node, SDMDataObject& sdmDataObject) {
312 2951 : SDMDataObjectParser::isElement(a_node, HeaderParser::SPECTRALRESOLUTION);
313 2951 : sdmDataObject.spectralResolutionType_ = SDMDataObjectParser::parseLiteral<SpectralResolutionType, CSpectralResolutionType>(a_node->children);
314 2951 : }
315 :
316 2951 : void HeaderParser::parseProcessorType(xmlNode* a_node, SDMDataObject& sdmDataObject) {
317 2951 : SDMDataObjectParser::isElement(a_node, HeaderParser::PROCESSORTYPE);
318 2951 : sdmDataObject.processorType_ = SDMDataObjectParser::parseLiteral<ProcessorType, CProcessorType>(a_node->children);
319 2951 : }
320 :
321 2951 : void HeaderParser::parseDataStruct(xmlNode* a_node, SDMDataObject& sdmDataObject){
322 : //cout << "Entering parseDataStruct with " << a_node->name << endl;
323 2951 : SDMDataObjectParser::isElement(a_node, HeaderParser::DATASTRUCT);
324 :
325 2951 : SDMDataObject::DataStruct dataStruct;
326 :
327 2951 : switch (sdmDataObject.correlationMode()) {
328 2147 : case AUTO_ONLY:
329 2147 : break;
330 :
331 804 : case CROSS_ONLY:
332 : case CROSS_AND_AUTO:
333 804 : dataStruct.apc_ = SDMDataObjectParser::parseStringsAttr<AtmPhaseCorrection, CAtmPhaseCorrection>(a_node, HeaderParser::APC);
334 804 : break;
335 : }
336 :
337 : // Traverse the children
338 :
339 : // BaseBands...
340 2951 : xmlNode* child = a_node->children;
341 5902 : vector <SDMDataObject::Baseband> basebands;
342 11618 : while (SDMDataObjectParser::testElement(child, HeaderParser::BASEBAND)) {
343 8667 : basebands.push_back(parseBaseband(child, sdmDataObject ));
344 8667 : child = child->next;
345 : }
346 :
347 2951 : dataStruct.basebands_ = (basebands);
348 :
349 : // Now that all the spectral windows are read set the associations between spectral windows.
350 : // We have recorded the id and image attributes when they are present in private strings in each spectralWindow.
351 : //
352 :
353 : // I want a map to associate a string of the form "<int>_<int>" to a string of the form "<int>_<int>"
354 : // and I define an entry in this map for each spectralWindow with an strSw_ non empty, the value
355 : // associated is of the form <int>_<int> where the two integers are the coordinates
356 : // (baseband index, spectralWindow index in the baseband)
357 : //
358 5902 : map<string, string> id2int_int;
359 5902 : ostringstream oss;
360 :
361 5902 : string key, value;
362 11618 : for (unsigned int ibb = 0; ibb < dataStruct.basebands_.size(); ibb++) {
363 8667 : vector<SDMDataObject::SpectralWindow>& spws = dataStruct.basebands_.at(ibb).spectralWindows_;
364 17693 : for (unsigned int ispw = 0; ispw < spws.size(); ispw++) {
365 :
366 9026 : oss.str("");
367 9026 : oss << ibb << " " << ispw;
368 9026 : value = oss.str();
369 :
370 9026 : oss.str("");
371 9026 : oss << ibb << " " << spws.at(ispw).strSw();
372 9026 : key = oss.str();
373 :
374 9026 : id2int_int[key] = value;
375 :
376 : }
377 : }
378 :
379 :
380 : // Now re scan all the spectralWindows and look for the ones with an strImage_ non empty.
381 : // and define the associations.
382 : //
383 5902 : istringstream iss;
384 2951 : map<string, string>::iterator iter;
385 : int ibbImage, ispwImage;
386 11618 : for (unsigned int ibb = 0; ibb < dataStruct.basebands_.size(); ibb++) {
387 8667 : vector<SDMDataObject::SpectralWindow>& spws = dataStruct.basebands_.at(ibb).spectralWindows_;
388 17693 : for (unsigned int ispw = 0; ispw < spws.size(); ispw++) {
389 9026 : string image = spws.at(ispw).strImage();
390 9026 : if (image.size() > 0) {
391 0 : oss.str("");
392 0 : oss << ibb << " " << image;
393 0 : key = oss.str();
394 0 : if ((iter = id2int_int.find(key)) != id2int_int.end()) {
395 0 : iss.str(iter->second);
396 0 : iss >> ibbImage;
397 0 : iss >> ispwImage;
398 0 : dataStruct.imageSPW(ibb, ispw, ispwImage);
399 : }
400 : else {
401 0 : oss.str("");
402 0 : oss << "In baseband #" << ibb << " the spectral window #" << ispw << " refers to non defined image ('" << image << "')";
403 0 : throw SDMDataObjectParserException(oss.str());
404 : }
405 : }
406 9026 : }
407 : }
408 :
409 : // Metadata attachments.
410 :
411 : // flags (optional)
412 2951 : if (SDMDataObjectParser::testElement(child, HeaderParser::FLAGS)) {
413 2782 : dataStruct.flags_ = (parseBinaryPart(child, HeaderParser::FLAGS));
414 2782 : child = child->next;
415 : }
416 :
417 : // actualTimes (optional)
418 2951 : if (SDMDataObjectParser::testElement(child, HeaderParser::ACTUALTIMES)) {
419 1994 : dataStruct.actualTimes_ = (parseBinaryPart(child, HeaderParser::ACTUALTIMES));
420 1994 : child = child->next;
421 : }
422 :
423 : // actualDurations (optional)
424 2951 : if (SDMDataObjectParser::testElement(child, HeaderParser::ACTUALDURATIONS)) {
425 1994 : dataStruct.actualDurations_ = (parseBinaryPart(child, HeaderParser::ACTUALDURATIONS));
426 1994 : child = child->next;
427 : }
428 :
429 : // Binary attachments elements...
430 2951 : switch (sdmDataObject.correlationMode()) {
431 74 : case CROSS_ONLY :
432 74 : dataStruct.crossData_ = (parseBinaryPart(child, HeaderParser::CROSSDATA));
433 74 : child = child->next;
434 74 : break;
435 :
436 2147 : case AUTO_ONLY :
437 2147 : dataStruct.autoData_ = (parseAutoDataBinaryPart(child, HeaderParser::AUTODATA));
438 2147 : child = child->next;
439 2147 : break;
440 :
441 730 : case CROSS_AND_AUTO :
442 730 : dataStruct.crossData_ = (parseBinaryPart(child, HeaderParser::CROSSDATA));
443 730 : child = child->next;
444 730 : dataStruct.autoData_ = (parseAutoDataBinaryPart(child, HeaderParser::AUTODATA));
445 730 : child = child->next;
446 730 : break;
447 : }
448 :
449 : /*
450 : // zeroLags (mandatory in FULL_RESOLUTION)
451 : if (sdmDataObject.spectralResolutionType() == FULL_RESOLUTION) {
452 : dataStruct.zeroLags_ = (parseBinaryPart(child, HeaderParser::ZEROLAGS));
453 : child = child->next;
454 : }
455 : // (and optional in CHANNEL_AVERAGE)
456 : else if (sdmDataObject.spectralResolutionType() == CHANNEL_AVERAGE) {
457 : if (SDMDataObjectParser::testElement(child, HeaderParser::ZEROLAGS)) {
458 : dataStruct.zeroLags_ = (parseBinaryPart(child, HeaderParser::ZEROLAGS));
459 : child = child->next;
460 : }
461 : }
462 : */
463 :
464 : // zeroLags are allowed only with a non FX correlator.
465 2951 : if (SDMDataObjectParser::testElement(child, HeaderParser::ZEROLAGS)) {
466 : // Reject zeroLags if the context does not allow them
467 460 : if (sdmDataObject.processorType_ != CORRELATOR)
468 0 : throw SDMDataObjectParserException("zeroLags are not expected with the declared processor type ('" +
469 0 : CProcessorType::name(sdmDataObject.processorType_) + "')");
470 :
471 :
472 460 : dataStruct.zeroLags_ = (parseZeroLagsBinaryPart(child, HeaderParser::ZEROLAGS));
473 :
474 : // Reject zeroLags if the context does not allow them ... again
475 :
476 460 : if (dataStruct.zeroLags_.correlatorType_ == FX)
477 0 : throw SDMDataObjectParserException ("zeroLags are not expected with the declared correlator type ('" +
478 0 : CCorrelatorType::name(dataStruct.zeroLags_.correlatorType_) + "')");
479 :
480 460 : child = child->next;
481 : }
482 :
483 2951 : sdmDataObject.dataStruct_ = (dataStruct);
484 2951 : }
485 :
486 8667 : SDMDataObject::Baseband HeaderParser::parseBaseband(xmlNode* a_node, SDMDataObject& sdmDataObject){
487 8667 : SDMDataObject::Baseband bb;
488 8667 : SDMDataObjectParser::isElement(a_node, HeaderParser::BASEBAND);
489 :
490 8667 : bb.name_ = (SDMDataObjectParser::parseStringAttr<BasebandName, CBasebandName>(a_node, HeaderParser::NAME));
491 :
492 : // Traverse the children (spectralWindow).
493 8667 : xmlNode* child = a_node->children;
494 8667 : vector<SDMDataObject::SpectralWindow> spw;
495 8667 : parseSpectralWindow(child, sdmDataObject, spw);
496 8667 : bb.spectralWindows(spw);
497 :
498 17334 : return bb;
499 8667 : }
500 :
501 8667 : void HeaderParser::parseSpectralWindow(xmlNode* a_node, SDMDataObject& sdmDataObject , vector<SDMDataObject::SpectralWindow>& spectralWindow){
502 17693 : for (xmlNode* cur_node = a_node; cur_node; cur_node = cur_node->next) {
503 9026 : SDMDataObjectParser::isElement(a_node, HeaderParser::SPECTRALWINDOW);
504 :
505 : //Look for attributes
506 9026 : vector<StokesParameter> crossPolProducts;
507 9026 : vector<StokesParameter> sdPolProducts;
508 : float scaleFactor;
509 : int numSpectralPoint;
510 : int numBin;
511 : NetSideband sideband;
512 :
513 9026 : SDMDataObject::SpectralWindow spw;
514 :
515 :
516 9026 : string dummy = SDMDataObjectParser::parseStringAttr(cur_node, HeaderParser::SWBB);
517 :
518 9026 : switch (sdmDataObject.correlationMode()) {
519 :
520 74 : case CROSS_ONLY:
521 74 : crossPolProducts = SDMDataObjectParser::parseStringsAttr<StokesParameter, CStokesParameter>(cur_node, HeaderParser::CROSSPOLPRODUCTS );
522 74 : scaleFactor = SDMDataObjectParser::parseFloatAttr(cur_node, HeaderParser::SCALEFACTOR );
523 74 : numSpectralPoint = SDMDataObjectParser::parseIntAttr(cur_node, HeaderParser::NUMSPECTRALPOINT );
524 74 : numBin = SDMDataObjectParser::parseIntAttr(cur_node, HeaderParser::NUMBIN );
525 74 : sideband = SDMDataObjectParser::parseStringAttr<NetSideband, CNetSideband>(cur_node, HeaderParser::SIDEBAND);
526 148 : spw = SDMDataObject::SpectralWindow(crossPolProducts,
527 : scaleFactor,
528 : (unsigned int)numSpectralPoint,
529 : (unsigned int)numBin,
530 74 : sideband);
531 74 : break;
532 :
533 5939 : case AUTO_ONLY:
534 5939 : sdPolProducts = SDMDataObjectParser::parseStringsAttr<StokesParameter, CStokesParameter>(cur_node, HeaderParser::SDPOLPRODUCTS );
535 5939 : numSpectralPoint = SDMDataObjectParser::parseIntAttr(cur_node, HeaderParser::NUMSPECTRALPOINT );
536 5939 : numBin = SDMDataObjectParser::parseIntAttr(cur_node, HeaderParser::NUMBIN );
537 5939 : sideband = SDMDataObjectParser::parseStringAttr<NetSideband, CNetSideband>(cur_node, HeaderParser::SIDEBAND);
538 11878 : spw = SDMDataObject::SpectralWindow(sdPolProducts,
539 : (unsigned int)numSpectralPoint,
540 : (unsigned int)numBin,
541 5939 : sideband);
542 5939 : break;
543 :
544 3013 : case CROSS_AND_AUTO:
545 3013 : crossPolProducts = SDMDataObjectParser::parseStringsAttr<StokesParameter, CStokesParameter>(cur_node, HeaderParser::CROSSPOLPRODUCTS );
546 3013 : sdPolProducts = SDMDataObjectParser::parseStringsAttr<StokesParameter, CStokesParameter>(cur_node, HeaderParser::SDPOLPRODUCTS );
547 3013 : scaleFactor = SDMDataObjectParser::parseFloatAttr(cur_node, HeaderParser::SCALEFACTOR );
548 3013 : numSpectralPoint = SDMDataObjectParser::parseIntAttr(cur_node, HeaderParser::NUMSPECTRALPOINT );
549 3013 : numBin = SDMDataObjectParser::parseIntAttr(cur_node, HeaderParser::NUMBIN );
550 3013 : sideband = SDMDataObjectParser::parseStringAttr<NetSideband, CNetSideband>(cur_node, HeaderParser::SIDEBAND);
551 6026 : spw = SDMDataObject::SpectralWindow(crossPolProducts,
552 : sdPolProducts,
553 : scaleFactor,
554 : (unsigned int)numSpectralPoint,
555 : (unsigned int)numBin,
556 3013 : sideband);
557 3013 : break;
558 : }
559 :
560 9026 : spw.strSw(SDMDataObjectParser::parseStringAttr(cur_node, HeaderParser::SW));
561 9026 : if (SDMDataObjectParser::hasAttr(cur_node, HeaderParser::IMAGE))
562 0 : spw.strImage(SDMDataObjectParser::parseStringAttr(cur_node, HeaderParser::IMAGE));
563 :
564 9026 : spectralWindow.push_back(spw);
565 :
566 9026 : }
567 8667 : }
568 :
569 7574 : SDMDataObject::BinaryPart HeaderParser::parseBinaryPart(xmlNode* a_node, const string& attachmentName) {
570 7574 : SDMDataObjectParser::isElement(a_node, attachmentName);
571 :
572 7574 : return SDMDataObject::BinaryPart(SDMDataObjectParser::parseIntAttr(a_node, HeaderParser::SIZE),
573 22722 : SDMDataObjectParser::parseStringsAttr<AxisName, CAxisName>(a_node, HeaderParser::AXES));
574 : }
575 :
576 2877 : SDMDataObject::AutoDataBinaryPart HeaderParser::parseAutoDataBinaryPart(xmlNode* a_node, const string& attachmentName) {
577 2877 : SDMDataObjectParser::isElement(a_node, attachmentName);
578 :
579 2877 : return SDMDataObject::AutoDataBinaryPart(SDMDataObjectParser::parseIntAttr(a_node, HeaderParser::SIZE),
580 2877 : SDMDataObjectParser::parseStringsAttr<AxisName, CAxisName>(a_node, HeaderParser::AXES),
581 8631 : SDMDataObjectParser::parseBoolAttr(a_node, HeaderParser::NORMALIZED));
582 : }
583 :
584 460 : SDMDataObject::ZeroLagsBinaryPart HeaderParser::parseZeroLagsBinaryPart(xmlNode* a_node, const string& attachmentName) {
585 460 : SDMDataObjectParser::isElement(a_node, attachmentName);
586 :
587 460 : return SDMDataObject::ZeroLagsBinaryPart(SDMDataObjectParser::parseIntAttr(a_node, HeaderParser::SIZE),
588 460 : SDMDataObjectParser::parseStringsAttr<AxisName, CAxisName>(a_node, HeaderParser::AXES),
589 1380 : SDMDataObjectParser::parseStringAttr<CorrelatorType, CCorrelatorType>(a_node, HeaderParser::CORRELATORTYPE));
590 : }
591 :
592 : // CorrSubsetHeaderParser methods.
593 :
594 933 : CorrSubsetHeaderParser::CorrSubsetHeaderParser() {
595 933 : doc = NULL;
596 933 : }
597 :
598 933 : CorrSubsetHeaderParser::~CorrSubsetHeaderParser() {
599 933 : if (doc != NULL) xmlFreeDoc(doc);
600 933 : }
601 :
602 :
603 0 : void CorrSubsetHeaderParser::parseFile(const string& filename, SDMDataSubset& sdmCorrDataSubset){
604 0 : if (doc != NULL) xmlFreeDoc(doc);
605 0 : doc = xmlReadFile(filename.c_str(), NULL, XML_PARSE_NOBLANKS);
606 0 : if (doc == NULL) {
607 0 : throw SDMDataObjectParserException("The file '"+filename+"' could not be transformed into a DOM structure");
608 : }
609 :
610 0 : xmlNode* root_element = xmlDocGetRootElement(doc);
611 0 : parseSDMDataSubsetHeader(root_element, sdmCorrDataSubset);
612 0 : }
613 :
614 41201 : void CorrSubsetHeaderParser::parseMemory(const string& buffer, SDMDataSubset& sdmCorrDataSubset) {
615 41201 : if (doc != NULL) xmlFreeDoc(doc);
616 41201 : doc = xmlReadMemory(buffer.data(), buffer.size(), "SDMDataHeader.xml", NULL, XML_PARSE_NOBLANKS);
617 41201 : if (doc == NULL) {
618 0 : throw SDMDataObjectParserException("The buffer containing the XML document could not be transformed into a DOM structure");
619 : }
620 :
621 41201 : xmlNode* root_element = xmlDocGetRootElement(doc);
622 41201 : parseSDMDataSubsetHeader(root_element, sdmCorrDataSubset );
623 41201 : };
624 :
625 41201 : void CorrSubsetHeaderParser::parseSDMDataSubsetHeader(xmlNode* a_node, SDMDataSubset& sdmCorrDataSubset) {
626 : // Look up for <sdmSubsetDataHeader...
627 41201 : SDMDataObjectParser::isElement(a_node, SDMDATASUBSETHEADER);
628 :
629 : // Project path.
630 41201 : vector<unsigned int> v;
631 41201 : v = SDMDataObjectParser::parseProjectPath(a_node); // v should contain 4 (integration) or 5 (subintegration) elements.
632 :
633 : // Check conformity of execBlockNum, scanNum and subscanNum.
634 :
635 41201 : if (v.at(0) != sdmCorrDataSubset.owner()->execBlockNum()
636 41201 : || v.at(1) != sdmCorrDataSubset.owner()->scanNum()
637 82402 : || v.at(2) != sdmCorrDataSubset.owner()->subscanNum())
638 0 : throw SDMDataObjectParserException("The project path of this data subset '"
639 0 : +SDMDataObjectParser::parseStringAttr(a_node, PROJECTPATH)
640 0 : +"' is not compatible with the project path announced in the global header"
641 0 : +" '"+sdmCorrDataSubset.owner()->projectPath()+"'");
642 :
643 : // Determine integrationNum [, subintegrationNum]
644 41201 : sdmCorrDataSubset.integrationNum_ = v.at(3);
645 41201 : sdmCorrDataSubset.subintegrationNum_ = (v.size() == 5) ? v.at(4) : 0;
646 :
647 : // Traverse the children .
648 41201 : xmlNode* child = a_node->children;
649 :
650 : // <schedulePeriodTime...
651 41201 : parseSchedulePeriodTime(child, sdmCorrDataSubset);
652 :
653 : // <dataStruct...
654 41201 : child = child->next;
655 41201 : SDMDataObjectParser::isElement(child, CorrSubsetHeaderParser::DATASTRUCT);
656 41201 : sdmCorrDataSubset.dataStruct_ = SDMDataObjectParser::parseStringAttr(child, CorrSubsetHeaderParser::REF);
657 :
658 41201 : child = child->next;
659 41201 : if (SDMDataObjectParser::testElement(child, CorrSubsetHeaderParser::ABORTOBSERVATION)) {
660 : // Is it a cancelling [sub]integration ?
661 0 : sdmCorrDataSubset.aborted_ = true;
662 0 : parseAbortObservation(child, sdmCorrDataSubset);
663 : }
664 : else {
665 : // ... or a sequence of attachments description.
666 41201 : if (SDMDataObjectParser::testElement(child, FLAGSREF)) {
667 9385 : sdmCorrDataSubset.flagsREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
668 9385 : child = child->next;
669 : }
670 :
671 :
672 41201 : if (SDMDataObjectParser::testElement(child, ACTUALTIMESREF)) {
673 1468 : sdmCorrDataSubset.actualTimesREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
674 1468 : child = child->next;
675 : }
676 :
677 :
678 41201 : if (SDMDataObjectParser::testElement(child, ACTUALDURATIONSREF)) {
679 1468 : sdmCorrDataSubset.actualDurationsREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
680 1468 : child = child->next;
681 : }
682 :
683 41201 : switch (sdmCorrDataSubset.owner()->correlationMode()) {
684 112 : case CROSS_ONLY:
685 112 : SDMDataObjectParser::isElement(child, CROSSDATAREF);
686 112 : sdmCorrDataSubset.crossDataREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
687 112 : sdmCorrDataSubset.crossDataType_ = SDMDataObjectParser::parseStringAttr<PrimitiveDataType, CPrimitiveDataType>(child, CorrSubsetHeaderParser::TYPE);
688 112 : child = child->next;
689 112 : break;
690 :
691 13370 : case AUTO_ONLY:
692 13370 : SDMDataObjectParser::isElement(child, AUTODATAREF);
693 13370 : sdmCorrDataSubset.autoDataREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
694 13370 : child = child->next;
695 13370 : break;
696 :
697 27719 : case CROSS_AND_AUTO:
698 27719 : SDMDataObjectParser::isElement(child, CROSSDATAREF);
699 27719 : sdmCorrDataSubset.crossDataREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
700 27719 : sdmCorrDataSubset.crossDataType_ = SDMDataObjectParser::parseStringAttr<PrimitiveDataType, CPrimitiveDataType>(child, CorrSubsetHeaderParser::TYPE);
701 27719 : child = child->next;
702 :
703 27719 : SDMDataObjectParser::isElement(child, AUTODATAREF);
704 27719 : sdmCorrDataSubset.autoDataREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
705 27719 : child = child->next;
706 27719 : break;
707 : }
708 : /*
709 : if (sdmCorrDataSubset.owner()->spectralResolutionType() != CHANNEL_AVERAGE) {
710 : SDMDataObjectParser::isElement(child, ZEROLAGSREF);
711 : sdmCorrDataSubset.zeroLagsREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
712 : child = child->next;
713 : }
714 : */
715 :
716 : // zeroLags are optional in any case. Michel Caillat. 24 Jul 2008
717 41201 : if (SDMDataObjectParser::testElement(child, ZEROLAGSREF)) {
718 22231 : sdmCorrDataSubset.zeroLagsREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
719 22231 : child = child->next;
720 : }
721 : }
722 41201 : }
723 :
724 : // void CorrSubsetHeaderParser::parseProjectPath (xmlNode* a_node, SDMDataSubset& sdmCorrDataSubset) {
725 : // string projectPath = SDMDataObjectParser::parseStringAttr(a_node,CorrSubsetHeaderParser::PROJECTPATH);
726 :
727 : // boost::cmatch what;
728 : // unsigned int execBlockNum = 0;
729 : // unsigned int scanNum = 0;
730 : // unsigned int subscanNum = 0;
731 : // switch (sdmCorrDataSubset.owner()->spectralResolutionType()) {
732 : // case FULL_RESOLUTION:
733 : // if (boost::regex_match(projectPath.c_str(), what, SDMDataObjectParser::PROJECTPATH4) && what[0].matched) {
734 : // execBlockNum = ::atoi(what[1].first);
735 : // scanNum = ::atoi(what[2].first);
736 : // subscanNum = ::atoi(what[3].first);
737 : // sdmCorrDataSubset.integrationNum_ = ::atoi(what[4].first);
738 : // }
739 : // else
740 : // throw SDMDataObjectParserException("Invalid string for projectPath '" + projectPath + "'");
741 : // break;
742 :
743 : // case CHANNEL_AVERAGE:
744 : // if (boost::regex_match(projectPath.c_str(), what, SDMDataObjectParser::PROJECTPATH5) && what[0].matched) {
745 : // execBlockNum = ::atoi(what[1].first);
746 : // scanNum = ::atoi(what[2].first);
747 : // subscanNum = ::atoi(what[3].first);
748 : // sdmCorrDataSubset.integrationNum_ = ::atoi(what[4].first);
749 : // sdmCorrDataSubset.subintegrationNum_ = ::atoi(what[5].first);
750 : // }
751 : // else
752 : // throw SDMDataObjectParserException("Invalid string for projectPath '" + projectPath + "'");
753 : // break;
754 :
755 : // case BASEBAND_WIDE:
756 : // throw SDMDataObjectParserException("'"+CSpectralResolutionType::name(BASEBAND_WIDE)+"' cannot appear in this context.");
757 : // break;
758 : // }
759 :
760 : // if (execBlockNum != sdmCorrDataSubset.owner()->execBlockNum()
761 : // || scanNum != sdmCorrDataSubset.owner()->scanNum()
762 : // || subscanNum != sdmCorrDataSubset.owner()->subscanNum())
763 : // throw SDMDataObjectParserException("The project path of this data subset '"
764 : // +projectPath
765 : // +"' is not compatible with the project path announced in the global header"
766 : // +" '"+sdmCorrDataSubset.owner()->projectPath()+"'");
767 : // }
768 :
769 41201 : void CorrSubsetHeaderParser::parseSchedulePeriodTime(xmlNode* a_node, SDMDataSubset& sdmCorrDataSubset) {
770 41201 : SDMDataObjectParser::isElement(a_node, CorrSubsetHeaderParser::SCHEDULEPERIODTIME);
771 :
772 41201 : xmlNode* child = a_node->children;
773 : // <time...
774 41201 : sdmCorrDataSubset.time_ = parseTime(child);
775 :
776 : // <interval...
777 41201 : child = child->next;
778 41201 : sdmCorrDataSubset.interval_ = parseInterval(child);
779 41201 : }
780 :
781 41201 : long long CorrSubsetHeaderParser::parseTime(xmlNode* a_node) {
782 41201 : SDMDataObjectParser::isElement(a_node, CorrSubsetHeaderParser::TIME);
783 41201 : return SDMDataObjectParser::parseLongLong(a_node->children);
784 : }
785 :
786 :
787 41201 : long long CorrSubsetHeaderParser::parseInterval(xmlNode* a_node) {
788 41201 : SDMDataObjectParser::isElement(a_node, CorrSubsetHeaderParser::INTERVAL);
789 41201 : return SDMDataObjectParser::parseLongLong(a_node->children);
790 : }
791 :
792 :
793 0 : void CorrSubsetHeaderParser::parseAbortObservation(xmlNode* a_node, SDMDataSubset& sdmCorrDataSubset) {
794 0 : xmlNode* child = a_node->children;
795 :
796 : // <abortTime...
797 0 : SDMDataObjectParser::isElement(child, CorrSubsetHeaderParser::ABORTTIME);
798 0 : sdmCorrDataSubset.abortTime_ = SDMDataObjectParser::parseLongLong(child->children);
799 :
800 : // <abortReason...
801 0 : child = child->next;
802 0 : SDMDataObjectParser::isElement(child, CorrSubsetHeaderParser::ABORTREASON);
803 0 : sdmCorrDataSubset.abortReason_ = SDMDataObjectParser::parseString(child->children);
804 0 : }
805 :
806 0 : void CorrSubsetHeaderParser::parseCrossDataType(xmlNode* a_node, SDMDataSubset& sdmCorrDataSubset) {
807 0 : SDMDataObjectParser::isElement(a_node, CorrSubsetHeaderParser::TYPE);
808 0 : sdmCorrDataSubset.crossDataType(SDMDataObjectParser::parseLiteral<PrimitiveDataType, CPrimitiveDataType>(a_node->children));
809 0 : }
810 :
811 :
812 0 : void CorrSubsetHeaderParser::reset() {
813 0 : if (doc)
814 0 : xmlFreeDoc(doc);
815 :
816 0 : doc = NULL;
817 0 : }
818 :
819 :
820 : // TPSubsetHeaderParser methods.
821 :
822 933 : TPSubsetHeaderParser::TPSubsetHeaderParser() {
823 933 : doc = NULL;
824 933 : }
825 :
826 933 : TPSubsetHeaderParser::~TPSubsetHeaderParser() {
827 933 : if (doc != NULL) xmlFreeDoc(doc);
828 933 : }
829 :
830 :
831 0 : void TPSubsetHeaderParser::parseFile(const string& filename, SDMDataSubset& sdmTPDataSubset){
832 0 : if (doc != NULL) xmlFreeDoc(doc);
833 0 : doc = xmlReadFile(filename.c_str(), NULL, XML_PARSE_NOBLANKS);
834 0 : if (doc == NULL) {
835 0 : throw SDMDataObjectParserException("The file '"+filename+"' could not be transformed into a DOM structure");
836 : }
837 :
838 0 : xmlNode* root_element = xmlDocGetRootElement(doc);
839 0 : parseSDMDataSubsetHeader(root_element, sdmTPDataSubset);
840 :
841 0 : }
842 :
843 883 : void TPSubsetHeaderParser::parseMemory(const string& buffer, SDMDataSubset& sdmTPDataSubset) {
844 883 : if (doc != NULL) xmlFreeDoc(doc);
845 883 : doc = xmlReadMemory(buffer.data(), buffer.size(), "SDMDataHeader.xml", NULL, XML_PARSE_NOBLANKS);
846 883 : if (doc == NULL) {
847 0 : throw SDMDataObjectParserException("The buffer containing the XML document could not be transformed into a DOM structure");
848 : }
849 :
850 883 : xmlNode* root_element = xmlDocGetRootElement(doc);
851 883 : parseSDMDataSubsetHeader(root_element, sdmTPDataSubset);
852 883 : }
853 :
854 883 : void TPSubsetHeaderParser::parseSDMDataSubsetHeader(xmlNode* a_node, SDMDataSubset& sdmTPDataSubset) {
855 : // Look up for <sdmSubsetDataHeader...
856 883 : SDMDataObjectParser::isElement(a_node, TPSubsetHeaderParser::SDMDATASUBSETHEADER);
857 :
858 : // Project path.
859 883 : int pathLen = (sdmTPDataSubset.owner()->dimensionality() == 0) ? 3 : 4;
860 883 : vector<unsigned int> v = SDMDataObjectParser::parseProjectPath(a_node, pathLen);
861 :
862 : // Check conformity of execBlockNum, scanNum and subscanNum.
863 883 : if (v.at(0) != sdmTPDataSubset.owner()->execBlockNum()
864 883 : || v.at(1) != sdmTPDataSubset.owner()->scanNum()
865 1766 : || v.at(2) != sdmTPDataSubset.owner()->subscanNum())
866 0 : throw SDMDataObjectParserException("The project path of this data subset '"
867 0 : +SDMDataObjectParser::parseStringAttr(a_node, PROJECTPATH)
868 0 : +"' is not compatible with the project path announced in the global header"
869 0 : +" '"+sdmTPDataSubset.owner()->projectPath()+"'");
870 :
871 883 : if (pathLen == 4)
872 0 : sdmTPDataSubset.integrationNum_ = v.at(3);
873 :
874 : // Traverse the children...
875 883 : xmlNode* child = a_node->children;
876 :
877 : // <schedulePeriodTime...
878 883 : parseSchedulePeriodTime(child, sdmTPDataSubset);
879 :
880 : // <dataStruct...
881 883 : child = child->next;
882 883 : SDMDataObjectParser::isElement(child, TPSubsetHeaderParser::DATASTRUCT);
883 883 : sdmTPDataSubset.dataStruct_ = (SDMDataObjectParser::parseStringAttr(child, TPSubsetHeaderParser::REF));
884 :
885 883 : child = child->next;
886 : // Optional flags attachments.
887 883 : if (SDMDataObjectParser::testElement(child, FLAGSREF)) {
888 714 : sdmTPDataSubset.flagsREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
889 714 : child = child->next;
890 : }
891 :
892 883 : if (SDMDataObjectParser::testElement(child, ACTUALTIMESREF)) {
893 169 : sdmTPDataSubset.actualTimesREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
894 169 : child = child->next;
895 : }
896 :
897 883 : if (SDMDataObjectParser::testElement(child, ACTUALDURATIONSREF)) {
898 861 : sdmTPDataSubset.actualDurationsREF_ = SDMDataObjectParser::parseStringAttr(child, XLINKHREF);
899 861 : child = child->next;
900 : }
901 :
902 : // Look for mandatory autoData element.
903 883 : SDMDataObjectParser::isElement(child, AUTODATAREF);
904 883 : sdmTPDataSubset.autoDataREF_ = (SDMDataObjectParser::parseStringAttr(child, TPSubsetHeaderParser::XLINKHREF ));
905 883 : }
906 :
907 0 : void TPSubsetHeaderParser::parseProjectPath(xmlNode* a_node, SDMDataSubset& sdmTPDataSubset) {
908 0 : string projectPath = SDMDataObjectParser::parseStringAttr(a_node,TPSubsetHeaderParser::PROJECTPATH);
909 :
910 : #ifndef WITHOUT_BOOST
911 : boost::cmatch what;
912 : #else
913 0 : std::cmatch what;
914 : #endif
915 0 : unsigned int execBlockNum = 0;
916 0 : unsigned int scanNum = 0;
917 0 : unsigned int subscanNum = 0;
918 :
919 : #ifndef WITHOUT_BOOST
920 : if (boost::regex_match(projectPath.c_str(), what, PROJECTPATH3) && what[0].matched) {
921 : #else
922 0 : if (std::regex_match(projectPath.c_str(), what, PROJECTPATH3) && what[0].matched) {
923 : #endif
924 0 : execBlockNum = ::atoi(what[1].first);
925 0 : scanNum = ::atoi(what[2].first);
926 0 : subscanNum = ::atoi(what[3].first);
927 : }
928 : else
929 0 : throw SDMDataObjectParserException("Invalid string for projectPath '" + projectPath + "'");
930 :
931 0 : if (execBlockNum != sdmTPDataSubset.owner()->execBlockNum()
932 0 : || scanNum != sdmTPDataSubset.owner()->scanNum()
933 0 : || subscanNum != sdmTPDataSubset.owner()->subscanNum())
934 0 : throw SDMDataObjectParserException("The project path of this data subset '"
935 0 : +projectPath
936 0 : +"' is not compatible with the project path announced in the global header"
937 0 : +" '"+sdmTPDataSubset.owner()->projectPath()+"'");
938 0 : }
939 :
940 883 : void TPSubsetHeaderParser::parseSchedulePeriodTime(xmlNode* a_node, SDMDataSubset& sdmTPDataSubset) {
941 883 : SDMDataObjectParser::isElement(a_node, TPSubsetHeaderParser::SCHEDULEPERIODTIME);
942 :
943 883 : xmlNode* child = a_node->children;
944 : // <time...
945 883 : sdmTPDataSubset.time_ = parseTime(child);
946 :
947 : // <interval...
948 883 : child = child->next;
949 883 : sdmTPDataSubset.interval_ = parseInterval(child);
950 883 : }
951 :
952 883 : long long TPSubsetHeaderParser::parseTime(xmlNode* a_node) {
953 883 : SDMDataObjectParser::isElement(a_node, TPSubsetHeaderParser::TIME);
954 883 : return SDMDataObjectParser::parseLongLong(a_node->children);
955 : }
956 :
957 :
958 883 : long long TPSubsetHeaderParser::parseInterval(xmlNode* a_node) {
959 883 : SDMDataObjectParser::isElement(a_node, TPSubsetHeaderParser::INTERVAL);
960 883 : return SDMDataObjectParser::parseLongLong(a_node->children);
961 : }
962 : // SDMDataObject::TPSubsetHeaderParser:: methods.
963 :
964 :
965 : // SDMDataObjectHeaderParser:: methods.
966 336269 : void SDMDataObjectParser::isElement(xmlNode* a_node, const string& elementName) {
967 : //cout << "Entering isElement for " << a_node->name << endl;
968 672538 : if ((a_node == NULL) ||
969 672538 : (a_node->type != XML_ELEMENT_NODE) ||
970 336269 : (elementName.compare((const char*)a_node->name) != 0)) {
971 0 : ostringstream oss;
972 0 : oss << "Could not find '<" << elementName << "...";
973 0 : if ((a_node != NULL) && (a_node->type == XML_ELEMENT_NODE))
974 0 : oss << " ( I was given '<" << a_node->name <<"...')";
975 : else
976 0 : oss << " ( node is not an xml element ) " << endl;
977 :
978 0 : throw SDMDataObjectParserException(oss.str());
979 0 : }
980 : //cout << "Exiting isElement" << endl;
981 336269 : }
982 :
983 235027 : bool SDMDataObjectParser::testElement(xmlNode* a_node, const string& elementName) {
984 : //cout << "Entering testElement with " << elementName << " against " << a_node->name << endl;
985 213566 : bool result = ((a_node != NULL) &&
986 448593 : (a_node->type == XML_ELEMENT_NODE) &&
987 213566 : (elementName.compare((const char*)a_node->name) == 0));
988 235027 : return result;
989 : }
990 :
991 0 : void SDMDataObjectParser::inElements(xmlNode* a_node, const vector<string>& elementNames) {
992 0 : if (find(elementNames.begin(), elementNames.end(), string((char*) a_node->name)) == elementNames.end()) {
993 0 : ostringstream message;
994 0 : copy(elementNames.begin(), elementNames.end(), ostream_iterator<string>(message, " "));
995 0 : throw SDMDataObjectParserException("Could not find any of elements '" + message.str()+"' in " + string((const char*) a_node->name));
996 0 : }
997 0 : }
998 :
999 339716 : xmlAttr* SDMDataObjectParser::hasAttr(xmlNode* a_node, const string& attrName) {
1000 339716 : xmlAttr* result = 0;
1001 686357 : for (struct _xmlAttr* attr = a_node->properties; attr; attr = attr->next) {
1002 677331 : if (attrName.compare((const char*) attr->name) == 0) {
1003 330690 : result = attr;
1004 330690 : break;
1005 : }
1006 : }
1007 339716 : return result;
1008 : }
1009 :
1010 23754 : void SDMDataObjectParser::tokenize(const string& str,
1011 : vector<string>& tokens,
1012 : const string& delimiters) {
1013 : // Skip delimiters at beginning.
1014 23754 : string::size_type lastPos = str.find_first_not_of(delimiters, 0);
1015 : // Find first "non-delimiter".
1016 23754 : string::size_type pos = str.find_first_of(delimiters, lastPos);
1017 :
1018 85278 : while (string::npos != pos || string::npos != lastPos) {
1019 : // Found a token, add it to the vector.
1020 61524 : tokens.push_back(str.substr(lastPos, pos - lastPos));
1021 : // Skip delimiters. Note the "not_of"
1022 61524 : lastPos = str.find_first_not_of(delimiters, pos);
1023 : // Find next "non-delimiter"
1024 61524 : pos = str.find_first_of(delimiters, lastPos);
1025 : }
1026 23754 : }
1027 :
1028 :
1029 0 : void SDMDataObjectParser::tokenize(const string& str,
1030 : set<string>& tokens,
1031 : const string& delimiters) {
1032 : // Skip delimiters at beginning.
1033 0 : string::size_type lastPos = str.find_first_not_of(delimiters, 0);
1034 : // Find first "non-delimiter".
1035 0 : string::size_type pos = str.find_first_of(delimiters, lastPos);
1036 :
1037 0 : while (string::npos != pos || string::npos != lastPos) {
1038 : // Found a token, add it to the vector.
1039 0 : tokens.insert(str.substr(lastPos, pos - lastPos));
1040 : // Skip delimiters. Note the "not_of"
1041 0 : lastPos = str.find_first_not_of(delimiters, pos);
1042 : // Find next "non-delimiter"
1043 0 : pos = str.find_first_of(delimiters, lastPos);
1044 : }
1045 0 : }
1046 :
1047 55203 : string SDMDataObjectParser::substring(const string &s, int a, int b) {
1048 55203 : return s.substr(a,(b - a));
1049 : }
1050 :
1051 55203 : string SDMDataObjectParser::trim(const string& s) {
1052 55203 : unsigned int i = 0;
1053 55203 : while (s.at(i) == ' ' && i < s.length())
1054 0 : ++i;
1055 55203 : if (i == s.length())
1056 0 : return "";
1057 55203 : unsigned int j = s.length() - 1;
1058 55203 : while (s.at(j) == ' ' && j > i)
1059 0 : --j;
1060 55203 : return substring(s,i,j + 1);
1061 : }
1062 :
1063 0 : string SDMDataObjectParser::parseString(xmlNode* a_node) {
1064 0 : if ((a_node != NULL) && (a_node->next == NULL))
1065 0 : return string((const char*) a_node->content);
1066 :
1067 0 : throw SDMDataObjectParserException("Invalid node , can't be parsed into a long long");
1068 :
1069 : }
1070 :
1071 87119 : long long SDMDataObjectParser::parseLongLong(xmlNode* a_node) {
1072 87119 : if ((a_node != NULL) && (a_node->next == NULL)) {
1073 87119 : istringstream in;
1074 87119 : in.str((const char*) a_node->content);
1075 : long long x;
1076 87119 : in >> x;
1077 87119 : if (in.rdstate() == istream::failbit)
1078 0 : throw SDMDataObjectParserException("failed to parse '"+string((const char*)a_node->content)+"' as a long long in" + string((const char*)a_node->parent->name));
1079 87119 : return x;
1080 87119 : }
1081 :
1082 0 : throw SDMDataObjectParserException("Invalid node , can't be parsed into a long long");
1083 : }
1084 :
1085 37816 : int SDMDataObjectParser::parseInt(xmlNode* a_node) {
1086 : //cout << "Entering parseInt with " << a_node->content << endl;
1087 37816 : if ((a_node != NULL) && (a_node->next == NULL)) {
1088 : #ifndef WITHOUT_BOOST
1089 : const boost::regex UINT("[0-9]+");
1090 : boost::cmatch what;
1091 : if (boost::regex_match((char*)a_node->content, what, UINT)) {
1092 : return (::atoi(what[0].first));
1093 : }
1094 : #else
1095 37816 : const std::regex UINT("[0-9]+");
1096 37816 : std::cmatch what;
1097 37816 : if (std::regex_match((char*)a_node->content, what, UINT)) {
1098 75632 : return (::atoi(what[0].first));
1099 : }
1100 : #endif
1101 : else
1102 0 : throw SDMDataObjectParserException("failed to parse '"+string((const char*)a_node->content)+"' as an int in " + string((const char*)a_node->parent->name));
1103 37816 : }
1104 :
1105 0 : throw SDMDataObjectParserException("Invalid node , can't be parsed into an int");
1106 : }
1107 :
1108 2877 : bool SDMDataObjectParser::parseBool(xmlNode* a_node) {
1109 2877 : if ((a_node != NULL) && (a_node->next == NULL)) {
1110 : #ifndef WITHOUT_BOOST
1111 : const boost::regex TORF("true|false");
1112 : boost::cmatch what;
1113 : if (boost::regex_match((char*)a_node->content, what, TORF)) {
1114 : return ( *(what[0].first) == 't') ? true:false;
1115 : }
1116 : #else
1117 2877 : const std::regex TORF("true|false");
1118 2877 : std::cmatch what;
1119 2877 : if (std::regex_match((char*)a_node->content, what, TORF)) {
1120 5754 : return ( *(what[0].first) == 't') ? true:false;
1121 : }
1122 : #endif
1123 : else
1124 0 : throw SDMDataObjectParserException("failed to parse '"+string((const char*)a_node->content)+"' as an int in " + string((const char*)a_node->parent->name));
1125 2877 : }
1126 :
1127 0 : throw SDMDataObjectParserException("Invalid node , can't be parsed into an bool");
1128 : }
1129 :
1130 3087 : float SDMDataObjectParser::parseFloat(xmlNode* a_node) {
1131 3087 : if ((a_node != NULL) && (a_node->next == NULL)) {
1132 3087 : istringstream in;
1133 3087 : in.str((const char*) a_node->content);
1134 : float x;
1135 3087 : in >> x;
1136 3087 : if (in.rdstate() == istream::failbit)
1137 0 : throw SDMDataObjectParserException("failed to parse '"+string((const char*)a_node->content)+"' as a float in " + string((const char*)a_node->parent->name));
1138 3087 : return x;
1139 3087 : }
1140 :
1141 0 : throw SDMDataObjectParserException("Invalid node , can't be parsed into an float");
1142 : }
1143 :
1144 31914 : int SDMDataObjectParser::parseIntAttr(xmlNode* a_node, const string& attrName) {
1145 31914 : xmlAttr* attr = 0;
1146 :
1147 31914 : if ((attr = hasAttr(a_node, attrName))) {
1148 31914 : int result =parseInt(attr->children);
1149 31914 : return result;
1150 : }
1151 0 : else throw SDMDataObjectParserException("could not find attribute '" + attrName + "' in " + string((const char*)a_node->name));
1152 : }
1153 :
1154 2877 : bool SDMDataObjectParser::parseBoolAttr(xmlNode* a_node, const string& attrName) {
1155 2877 : xmlAttr* attr = 0;
1156 :
1157 2877 : if ((attr = hasAttr(a_node, attrName))) {
1158 2877 : bool result = parseBool(attr->children);
1159 2877 : return result;
1160 : }
1161 0 : else throw SDMDataObjectParserException("could not find attribute '" + attrName + "' in " + string((const char*)a_node->name));
1162 : }
1163 :
1164 3087 : float SDMDataObjectParser::parseFloatAttr(xmlNode* a_node, const string& attrName) {
1165 3087 : xmlAttr* attr = 0;
1166 :
1167 3087 : if ((attr = hasAttr(a_node, attrName))) {
1168 3087 : float result = parseFloat(attr->children);
1169 : //cout << attr->name << " = " << result << endl;
1170 3087 : return result;
1171 : }
1172 0 : else throw SDMDataObjectParserException("could not find attribute '" + attrName + "' in " + string((const char*)a_node->name));
1173 : }
1174 :
1175 :
1176 223074 : string SDMDataObjectParser::parseStringAttr(xmlNode* a_node, const string& attrName) {
1177 : //cout << "Entering parseStringAttr with " << attrName << " in " << a_node->name << endl;
1178 223074 : xmlAttr* attr = 0;
1179 :
1180 223074 : if ((attr = hasAttr(a_node, attrName))) {
1181 223074 : string result = string((const char*)attr->children->content);
1182 : //cout << attr->name << " = " << result << endl;
1183 446148 : return result;
1184 223074 : }
1185 0 : else throw SDMDataObjectParserException("could not find attribute '" + attrName + "' in " + string((const char*)a_node->name));
1186 : }
1187 :
1188 :
1189 0 : vector<string> SDMDataObjectParser::parseStringsAttr(xmlNode* a_node, const string& attrName) {
1190 0 : xmlAttr* attr = 0;
1191 :
1192 0 : if ((attr = hasAttr(a_node, attrName))) {
1193 0 : vector<string> result;
1194 0 : tokenize((const char*)attr->children->content, result);
1195 : //cout << attr->name << " = '"; copy(result.begin(), result.end(), ostream_iterator<string>(cout, " ")); cout << "'" << endl;
1196 0 : return result;
1197 0 : }
1198 0 : else throw SDMDataObjectParserException("could not find attribute '" + attrName + "' in " + string((const char*)a_node->name));
1199 : }
1200 :
1201 0 : set<string> SDMDataObjectParser::parseStringSetAttr(xmlNode* a_node, const string& attrName) {
1202 0 : xmlAttr* attr = 0;
1203 :
1204 0 : if ((attr = hasAttr(a_node, attrName))) {
1205 0 : set<string> result;
1206 0 : tokenize((const char*)attr->children->content, result);
1207 : //cout << attr->name << " = '"; copy(result.begin(), result.end(), ostream_iterator<string>(cout, " ")); cout << "'" << endl;
1208 0 : return result;
1209 0 : }
1210 0 : else throw SDMDataObjectParserException("could not find attribute '" + attrName + "' in " + string((const char*)a_node->name));
1211 : }
1212 :
1213 :
1214 3834 : vector<unsigned int> SDMDataObjectParser::parseProjectPath(xmlNode* a_node, unsigned int len) {
1215 3834 : string projectPath = SDMDataObjectParser::parseStringAttr(a_node, HeaderParser::PROJECTPATH);
1216 3834 : vector<unsigned int> result;
1217 3834 : bool matched = true;
1218 : #ifndef WITHOUT_BOOST
1219 : boost::cmatch what;
1220 : switch (len) {
1221 : case 3: matched = boost::regex_match(projectPath.c_str(), what, PROJECTPATH3); break;
1222 : case 4: matched = boost::regex_match(projectPath.c_str(), what, PROJECTPATH4); break;
1223 : case 5: matched = boost::regex_match(projectPath.c_str(), what, PROJECTPATH5); break;
1224 : #else
1225 3834 : std::cmatch what;
1226 3834 : switch (len) {
1227 3834 : case 3: matched = std::regex_match(projectPath.c_str(), what, PROJECTPATH3); break;
1228 0 : case 4: matched = std::regex_match(projectPath.c_str(), what, PROJECTPATH4); break;
1229 0 : case 5: matched = std::regex_match(projectPath.c_str(), what, PROJECTPATH5); break;
1230 : #endif
1231 0 : default: throw SDMDataObjectParserException ("internal error in method 'parseProjectPath'. The parameter 'len' has a value out of the range [3,5]");
1232 : }
1233 :
1234 3834 : if (!matched)
1235 0 : throw SDMDataObjectException("'" + projectPath + "' is an invalid string for a 'projectPath' attribute");
1236 :
1237 15336 : for (unsigned int i = 0; i < len; i++) {
1238 11502 : result.push_back(::atoi(what[i+1].first));
1239 : }
1240 7668 : return result;
1241 3834 : }
1242 :
1243 : #ifndef WITHOUT_BOOST
1244 : const boost::regex SDMDataObjectParser::PROJECTPATH4OR5("([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+/)?");
1245 : #else
1246 : const std::regex SDMDataObjectParser::PROJECTPATH4OR5("([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+/)?");
1247 : #endif
1248 41201 : vector<unsigned int> SDMDataObjectParser::parseProjectPath(xmlNode* a_node) {
1249 41201 : string projectPath = SDMDataObjectParser::parseStringAttr(a_node, HeaderParser::PROJECTPATH);
1250 41201 : vector<unsigned int> result;
1251 :
1252 41201 : bool matched = true;
1253 :
1254 : #ifndef WITHOUT_BOOST
1255 : boost::cmatch what;
1256 : matched = boost::regex_match(projectPath.c_str(), what, PROJECTPATH4OR5);
1257 : #else
1258 41201 : std::cmatch what;
1259 41201 : matched = std::regex_match(projectPath.c_str(), what, PROJECTPATH4OR5);
1260 : #endif
1261 :
1262 41201 : if (!matched)
1263 0 : throw SDMDataObjectException("'" + projectPath + "' is an invalid string for a 'projectPath' attribute.");
1264 :
1265 : // Let's retrieve the 4 first numbers.
1266 206005 : for (unsigned int i = 0; i < 4; i++)
1267 164804 : result.push_back(::atoi(what[i+1].first));
1268 :
1269 : // and the fifth if it exists...
1270 41201 : if (what[5].matched) {
1271 20077 : result.push_back(::atoi(what[5].first));
1272 : }
1273 :
1274 82402 : return result;
1275 41201 : }
1276 :
1277 2951 : const ByteOrder* SDMDataObjectParser::parseByteOrderAttr(xmlNode* a_node, const string& attrName) {
1278 2951 : string byteOrder = SDMDataObjectParser::parseStringAttr(a_node, attrName);
1279 :
1280 2951 : if (byteOrder.compare("Little_Endian")==0) return ByteOrder::Little_Endian;
1281 0 : if (byteOrder.compare("Big_Endian")==0) return ByteOrder::Big_Endian;
1282 :
1283 0 : throw SDMDataObjectParserException("'" + byteOrder + "' is an invalid string for a 'byteOrder' attribute.");
1284 2951 : }
1285 :
1286 933 : SDMDataObjectParser::SDMDataObjectParser() {;}
1287 933 : SDMDataObjectParser::~SDMDataObjectParser() {;}
1288 :
1289 0 : void SDMDataObjectParser::parseFileHeader(const string& filename, SDMDataObject& sdmDataObject) {
1290 0 : headerParser.parseFile(filename, sdmDataObject);
1291 0 : }
1292 :
1293 2951 : void SDMDataObjectParser::parseMemoryHeader(const string& buffer, SDMDataObject& sdmDataObject) {
1294 2951 : headerParser.parseMemory(buffer, sdmDataObject);
1295 2951 : }
1296 :
1297 0 : void SDMDataObjectParser::parseFileCorrSubsetHeader(const string& filename, SDMDataSubset& sdmCorrDataSubset) {
1298 0 : corrSubsetHeaderParser.parseFile(filename, sdmCorrDataSubset);
1299 0 : }
1300 :
1301 41201 : void SDMDataObjectParser::parseMemoryCorrSubsetHeader(const string& buffer, SDMDataSubset& sdmCorrDataSubset) {
1302 41201 : corrSubsetHeaderParser.parseMemory(buffer, sdmCorrDataSubset);
1303 41201 : }
1304 :
1305 0 : void SDMDataObjectParser::parseFileTPSubsetHeader(const string& filename, SDMDataSubset& sdmCorrDataSubset) {
1306 0 : tpSubsetHeaderParser.parseFile(filename, sdmCorrDataSubset);
1307 0 : }
1308 :
1309 883 : void SDMDataObjectParser::parseMemoryTPSubsetHeader(const string& buffer, SDMDataSubset& sdmCorrDataSubset) {
1310 883 : tpSubsetHeaderParser.parseMemory(buffer, sdmCorrDataSubset);
1311 883 : }
1312 :
1313 : }
1314 :
1315 : #if 0
1316 : using namespace asdmbinaries;
1317 : int main (int argC, char* argV[]) {
1318 :
1319 : if (argC != 3) return (1);
1320 :
1321 : SDMDataObjectParser parser;
1322 : SDMDataObject sdmDataObject;
1323 :
1324 : SDMDataSubset sdmDataSubset;
1325 :
1326 : cout << "Trying to parse an SDMDataHeader in " << argV[1] << " and an SDMDataSubsetHeader in " << argV[2] <<endl;
1327 : try {
1328 : parser.parseFileHeader(argV[1], sdmDataObject);
1329 : cout << "----- SDMDataObject ------" << endl;
1330 : cout << "SDMDataHeader: " << endl;
1331 : cout << endl;
1332 : cout << sdmDataObject.toString() << endl;
1333 :
1334 : // Now process the sdmDataSubsetHeader passed in argV[2]
1335 : switch (sdmDataObject.dimensionality()) {
1336 : case 0:
1337 : {
1338 : parser.parseFileTPSubsetHeader(argV[2], sdmDataSubset);
1339 : cout << endl;
1340 : cout << "SDMDataSubsetHeader: " << endl;
1341 : cout << endl;
1342 : cout << sdmDataSubset.toString(sdmDataObject.dimensionality()) << endl;
1343 : break;
1344 : }
1345 :
1346 : case 1:
1347 : {
1348 : parser.parseFileCorrSubsetHeader(argV[2], sdmDataSubset);
1349 : cout << endl;
1350 : cout << "SDMDataSubsetHeader: " << endl;
1351 : cout << endl;
1352 : cout << sdmDataSubset.toString(sdmDataObject.dimensionality());
1353 : break;
1354 : }
1355 :
1356 : default:
1357 : break;
1358 : }
1359 : }
1360 : catch (SDMDataObjectParserException e) {
1361 : cout << e.getMessage() << endl;
1362 : exit(1);
1363 : }
1364 :
1365 : cout << endl;
1366 : cout << "----------------------" << endl;
1367 : cout << "XML representation of the sdmDataHeader: " << endl;
1368 : cout << endl;
1369 : cout << sdmDataObject.toXML() << endl;
1370 :
1371 : cout << endl;
1372 : cout << "----------------------" << endl;
1373 : cout << "XML representation of the sdmDataSubsetHeader: " << endl;
1374 : cout << endl;
1375 : cout << sdmDataSubset.toXML(sdmDataObject.dimensionality()) << endl;
1376 : }
1377 : #endif
|