LCOV - code coverage report
Current view: top level - alma/ASDM - Parser.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 765 10157 7.5 %
Date: 2024-12-11 20:54:31 Functions: 75 423 17.7 %

          Line data    Source code
       1             : 
       2             :  /*
       3             :  * ALMA - Atacama Large Millimeter Array
       4             :  * (c) European Southern Observatory, 2002
       5             :  * (c) Associated Universities Inc., 2002
       6             :  * Copyright by ESO (in the framework of the ALMA collaboration),
       7             :  * Copyright by AUI (in the framework of the ALMA collaboration),
       8             :  * All rights reserved.
       9             :  * 
      10             :  * This library is free software; you can redistribute it and/or
      11             :  * modify it under the terms of the GNU Lesser General Public
      12             :  * License as published by the Free software Foundation; either
      13             :  * version 2.1 of the License, or (at your option) any later version.
      14             :  * 
      15             :  * This library is distributed in the hope that it will be useful,
      16             :  * but WITHOUT ANY WARRANTY, without even the implied warranty of
      17             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      18             :  * Lesser General Public License for more details.
      19             :  * 
      20             :  * You should have received a copy of the GNU Lesser General Public
      21             :  * License along with this library; if not, write to the Free Software
      22             :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      23             :  * MA 02111-1307  USA
      24             :  *
      25             :  * Warning!
      26             :  *  -------------------------------------------------------------------- 
      27             :  * | This is generated code!  Do not modify this file.                  |
      28             :  * | If you do, all changes will be lost when the file is re-generated. |
      29             :  *  --------------------------------------------------------------------
      30             :  *
      31             :  * File Parser.cpp
      32             :  */
      33             : #include <iostream>
      34             : #include <sstream>
      35             : #include <alma/ASDM/Base64.h>
      36             : 
      37             : #include <alma/ASDM/Parser.h>
      38             : #ifndef WITHOUT_BOOST
      39             : #include <boost/property_tree/detail/xml_parser_utils.hpp>
      40             : #endif
      41             : #include <alma/ASDM/OutOfBoundsException.h>
      42             : #include <alma/ASDM/NumberFormatException.h>
      43             : #include <alma/ASDM/BooleanWrapper.h>
      44             : #include <alma/ASDM/ByteWrapper.h>
      45             : #include <alma/ASDM/CharacterWrapper.h>
      46             : #include <alma/ASDM/DoubleWrapper.h>
      47             : #include <alma/ASDM/FloatWrapper.h>
      48             : #include <alma/ASDM/IntegerWrapper.h>
      49             : #include <alma/ASDM/LongWrapper.h>
      50             : #include <alma/ASDM/ShortWrapper.h>
      51             : using asdm::OutOfBoundsException;
      52             : using asdm::NumberFormatException;
      53             : using asdm::Boolean;
      54             : using asdm::Byte;
      55             : using asdm::Character;
      56             : using asdm::Double;
      57             : using asdm::Float;
      58             : using asdm::Integer;
      59             : using asdm::Long;
      60             : using asdm::Short;
      61             : 
      62             : using namespace std;
      63             : 
      64             : namespace asdm { 
      65             :  
      66     3754488 :         string Parser::substring(const string &s, int a, int b) {
      67     3754488 :                 return s.substr(a,(b - a));
      68             :         }
      69             :         
      70     1781957 :         string Parser::trim(const string &s) {
      71     1781957 :                 unsigned int i = 0;
      72             :                 //while (s.at(i) == ' ' && i < s.length())
      73     1828980 :                 while (i < s.length() && s.at(i) == ' ')
      74       47023 :                         ++i;
      75     1781957 :                 if (i == s.length())
      76           2 :                         return "";
      77     1781955 :                 unsigned int j = s.length() - 1;
      78             :                 //while (s.at(j) == ' ' && j > i)
      79     2246307 :                 while (j > i && s.at(j) == ' ')
      80      464352 :                         --j;
      81     1781955 :                 return substring(s,i,j + 1);            
      82             :         }
      83             : 
      84        6161 :         string Parser::encode(const string &s) {
      85             : #ifndef WITHOUT_BOOST
      86             :             return boost::property_tree::xml_parser::encode_char_entities(s);
      87             : #else
      88        6161 :             string result;                  
      89       58170 :             for (string::const_iterator it=s.begin(); it!=s.end();++it) {
      90       52009 :                 switch(*it) {
      91           0 :                 case '&':  result += "&amp;";   break;
      92           0 :                 case '<':  result += "&gt;";    break;
      93           0 :                 case '>':  result += "&lt;";    break;
      94           0 :                 case '\"': result += "&quot;";  break;
      95           0 :                 case '\'': result += "&apos;";  break;
      96       52009 :                 default:   result += *it;
      97             :                 }
      98             :             }
      99        6161 :             return result;
     100             : #endif
     101           0 :         }
     102             : 
     103             : #ifndef WITHOUT_BOOST
     104             :         string Parser::decode(const string &s, const string &/* tableName */) {
     105             :             return boost::property_tree::xml_parser::decode_char_entities(s);
     106             :         }
     107             : #else
     108       36411 :         string Parser::decode(const string &s, const string &tableName) {
     109       36411 :             string result;
     110      304134 :             for (string::const_iterator it=s.begin(); it!=s.end();++it) {
     111             :                 // is this the start of a special set of characters to be decoded
     112      267723 :                 if (*it == '&') {
     113             :                     // is it correctly terminated
     114           8 :                     string::const_iterator term = find(it+1,s.end(),';');
     115           8 :                     if (term == s.end())
     116           0 :                         throw ConversionException("Error: Missing semi-colon after start of special characters in \"" + 
     117           0 :                                  s + "\" : Invalid XML syntax", tableName);
     118             : 
     119           8 :                     string thing(it+1,term);
     120           8 :                     if (thing == "amp") result += '&';
     121           8 :                     else if (thing == "gt") result += '>';
     122           0 :                     else if (thing == "lt") result += '<';
     123           0 :                     else if (thing == "quot") result += '\"';
     124           0 :                     else if (thing == "apos") result += '\'';
     125             :                     else 
     126           0 :                         throw ConversionException("Error: Unrecognized special characters in \"" + 
     127           0 :                                  s + "\" : Invalid XML syntax", tableName);
     128             : 
     129           8 :                     it = term;
     130           8 :                 } else {
     131      267715 :                     result += *it;
     132             :                 }
     133             :             }
     134       36411 :             return result;
     135           0 :         }
     136             : #endif
     137             : 
     138             :  
     139             :         /**
     140             :          * Get the portion of the string bounded by s1 and s2, inclusive.
     141             :          * @param s1
     142             :          * @param s2
     143             :          * @return
     144             :          */
     145      192483 :         string Parser::getElement(const string &s1, const string &s2) {
     146      192483 :                 beg = str.find(s1,pos);
     147      192483 :                 if (beg == string::npos)
     148        1907 :                         return "";
     149      190576 :                 end = str.find(s2,beg + s1.length());
     150      190576 :                 if (end == string::npos)
     151           0 :                         return "";
     152      190576 :                 pos = end + s2.length();
     153      190576 :                 return substring(str,beg,end + s2.length());
     154             :         }
     155             : 
     156             :         /**
     157             :          * Get the portion of the string bounded by s1 and s2, exclusive.
     158             :          * @param s1
     159             :          * @param s2
     160             :          * @return
     161             :          */
     162      188916 :         string Parser::getElementContent(const string &s1, const string &s2) {
     163      188916 :                 string s = getElement(s1,s2);
     164      188916 :                 if (s.length() == 0)
     165        1739 :                         return "";
     166      187177 :                 s = substring(str,beg + s1.length(),end);
     167      187177 :                 return trim(s);
     168      188916 :         }
     169             : 
     170           0 :         string Parser::getField(const string &field) {
     171           0 :                 beg = str.find("<" + field + ">");
     172           0 :                 if (beg == string::npos)
     173           0 :                         return "";
     174           0 :                 beg += field.length() + 2;
     175           0 :                 end = str.find("</" + field + ">",beg);
     176           0 :                 if (end == string::npos)
     177           0 :                         return "";
     178           0 :                 string s = substring(str,beg,end);
     179           0 :                 return trim(s);
     180           0 :         }
     181             : 
     182     1594793 :         string Parser::getField(const string &xml, const string &field) {
     183     1594793 :                 string::size_type b = xml.find("<" + field + ">");
     184     1594793 :                 if (b == string::npos)
     185          13 :                         return "";
     186     1594780 :                 b += field.length() + 2;
     187     1594780 :                 string::size_type e = xml.find("</" + field + ">",b);
     188     1594780 :                 if (e == string::npos)
     189           0 :                         return "";
     190     1594780 :                 string s = substring(xml,b,e);
     191     1594780 :                 return trim(s);
     192     1594780 :         }
     193             : 
     194             :         //////////////////////////////////////////////////////
     195             :         // The follwing is a special case.
     196             :         //////////////////////////////////////////////////////
     197             : 
     198       36151 :         string Parser::getString(const string &name, const string &tableName, const string &xmlDoc) 
     199             :         {
     200       36151 :                 string xmlField = Parser::getField(xmlDoc,name);
     201             :                 /*
     202             :                 if (xmlField == "")
     203             :                         throw  ConversionException("Error: Missing field \"" + 
     204             :                                         name + "\" or invalid syntax",tableName);
     205             :                 */
     206       72302 :                 return Parser::decode(xmlField,tableName);
     207       36151 :         }
     208             : 
     209        3256 :         vector<string> Parser::get1DString(const string &name, const string &tableName, const string &xmlDoc)
     210             :         {
     211        3256 :                 vector<string> x(2);
     212        3256 :                 string xmlField = Parser::getField(xmlDoc,name);
     213        3256 :                 if (xmlField == "") {
     214           0 :                         throw  ConversionException("Error: Field \"" + 
     215           0 :                                         name + "\": Invalid XML syntax", tableName);
     216             :                 }
     217        6512 :                 StringTokenizer t(xmlField," ");
     218             :                 try {
     219        3256 :                         int ndim = Integer::parseInt(t.nextToken());
     220        3256 :                         if (ndim != 1) {
     221           0 :                                 throw ConversionException("Error: Field \"" + 
     222           0 :                                                 name + "\": Invalid array format", tableName);
     223             :                         }
     224        3256 :                         int dim0 = Integer::parseInt(t.nextToken());
     225        3256 :                         vector<string> value(dim0);
     226        3256 :                         if (dim0 == 0)
     227         137 :                                 return value;
     228        3119 :                         t.nextToken("\""); // the space
     229        3119 :                         value[0] = t.nextToken();
     230        3379 :                         for (int i = 1; i < dim0; ++i) {
     231         260 :                                 t.nextToken(); // the space
     232         260 :                                 string thisToken = t.nextToken();               
     233         260 :                                 value[i] = Parser::decode(thisToken,tableName);
     234         260 :                         }
     235        3119 :                         if (t.hasMoreTokens()) {
     236           0 :                                 throw ConversionException("Error: Field \"" + 
     237           0 :                                                 name + "\": Syntax error.", tableName);
     238             :                         }
     239        3119 :                         return value;
     240        3256 :                 } catch (const NumberFormatException &e) {
     241           0 :                         throw ConversionException("Error: Field \"" + 
     242           0 :                                         name + "\": " + e.getMessage(), tableName);
     243           0 :                 } catch (const OutOfBoundsException &e) {
     244           0 :                         throw ConversionException("Error: Field \"" + 
     245           0 :                                         name + "\": Unexpected end of string", tableName);
     246           0 :                 }
     247        3256 :         }
     248             :  
     249           0 :         vector <vector<string> > Parser::get2DString(const string &name, const string &tableName, const string &xmlDoc)
     250             :         {
     251           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     252           0 :                 if (xmlField == "") {
     253           0 :                         throw ConversionException("Error: Field \"" + 
     254           0 :                                         name + "\": Invalid XML syntax", tableName);
     255             :                 }
     256           0 :                 StringTokenizer t(xmlField," ");
     257             :                 try {
     258           0 :                         int ndim = Integer::parseInt(t.nextToken());
     259           0 :                         if (ndim != 2) {
     260           0 :                                 throw ConversionException("Error: Field \"" + 
     261           0 :                                                 name + "\": Invalid array format", tableName);
     262             :                         }
     263           0 :                         int dim0 = Integer::parseInt(t.nextToken());
     264           0 :                         int dim1 = Integer::parseInt(t.nextToken());
     265           0 :                         vector <vector<string> > value;
     266             : 
     267           0 :                         if (dim0 == 0 || dim1 == 0)
     268           0 :                                 return value;
     269           0 :                         t.nextToken("\""); // the space
     270             :                         
     271           0 :                         vector<string>v_aux;
     272           0 :                         for (int i = 0; i < dim0; ++i) {
     273           0 :                                 v_aux.clear();
     274           0 :                                 for (int j = 0; j < dim1; ++j) {
     275           0 :                                         v_aux.push_back(Parser::decode(t.nextToken(),tableName));
     276           0 :                                         if (i != dim0 - 1 || j != dim1 - 1)
     277           0 :                                                 t.nextToken(); // the space
     278             :                                 }
     279           0 :                                 value.push_back(v_aux);
     280             :                         }
     281           0 :                         if (t.hasMoreTokens()) {
     282           0 :                                 throw ConversionException("Error: Field \"" + 
     283           0 :                                                 name + "\": Syntax error.", tableName);
     284             :                         }
     285           0 :                         return value;
     286           0 :                 } catch (const NumberFormatException &e) {
     287           0 :                         throw ConversionException("Error: Field \"" + 
     288           0 :                                         name + "\": " + e.getMessage(), tableName);
     289           0 :                 } catch (const OutOfBoundsException &e) {
     290           0 :                         throw ConversionException("Error: Field \"" + 
     291           0 :                                         name + "\": Unexpected end of string", tableName);
     292           0 :                 }
     293           0 :         }
     294             :  
     295           0 :         vector <vector <vector<string> > > Parser::get3DString(const string &name, const string &tableName, const string &xmlDoc)
     296             :         {
     297           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     298           0 :                 if (xmlField == "") {
     299           0 :                         throw ConversionException("Error: Field \"" + 
     300           0 :                                         name + "\": Invalid XML syntax", tableName);
     301             :                 }
     302           0 :                 StringTokenizer t(xmlField," ");
     303             :                 try {
     304           0 :                         int ndim = Integer::parseInt(t.nextToken());
     305           0 :                         if (ndim != 3) {
     306           0 :                                 throw ConversionException("Error: Field \"" + 
     307           0 :                                                 name + "\": Invalid array format", tableName);
     308             :                         }
     309           0 :                         int dim0 = Integer::parseInt(t.nextToken());
     310           0 :                         int dim1 = Integer::parseInt(t.nextToken());
     311           0 :                         int dim2 = Integer::parseInt(t.nextToken());
     312           0 :                         vector <vector <vector<string> > > value;
     313           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
     314           0 :                                 return value;
     315           0 :                         t.nextToken("\""); // the space
     316             :                         
     317           0 :                         vector<string> v_aux;
     318           0 :                         vector<vector <string> > vv_aux;
     319           0 :                         for (int i = 0; i < dim0; ++i) {
     320           0 :                                 vv_aux.clear();
     321           0 :                                 for (int j = 0; j < dim1; ++j) {
     322           0 :                                         v_aux.clear();
     323           0 :                                         for (int k = 0; k < dim2; ++k) {
     324           0 :                                                 v_aux.push_back( Parser::decode(t.nextToken(),tableName));
     325           0 :                                                 if (i != dim0 - 1 || j != dim1 - 1 || k != dim2 - 1)
     326           0 :                                                         t.nextToken(); // the space
     327             :                                         }
     328           0 :                                         vv_aux.push_back(v_aux);
     329             :                                 }
     330           0 :                                 value.push_back(vv_aux);
     331             :                         }
     332           0 :                         if (t.hasMoreTokens()) {
     333           0 :                                 throw ConversionException("Error: Field \"" + 
     334           0 :                                                 name + "\": Syntax error.", tableName);
     335             :                         }
     336           0 :                         return value;
     337           0 :                 } catch (const NumberFormatException &e) {
     338           0 :                         throw ConversionException("Error: Field \"" + 
     339           0 :                                         name + "\": " + e.getMessage(), tableName);
     340           0 :                 } catch (const OutOfBoundsException &e) {
     341           0 :                         throw ConversionException("Error: Field \"" + 
     342           0 :                                         name + "\": Unexpected end of string", tableName);
     343           0 :                 }
     344           0 :         }
     345             : 
     346             :         // Generated methods for conversion to and from XML
     347             :         // data representations for all types, both primitive
     348             :         // and extended.  Also included are 1, 2, and 3 
     349             :         // dimensional arrays of these types.
     350             : 
     351             :         
     352             :         // Field type: int
     353             : 
     354       12408 :         void Parser::toXML(int data, const string &name, string &buf) {
     355       12408 :                 buf.append("<" + name + "> ");
     356             :         
     357       12408 :                 buf.append(Integer::toString(data));
     358             :                 
     359       12408 :                 buf.append(" </" + name + "> ");
     360       12408 :         }
     361             : 
     362             :         
     363             :         
     364           0 :          void Parser::toXML(set< int > data, const string &name, string &buf) {
     365           0 :                 buf.append("<" + name + "> ");
     366           0 :                 set < int >::iterator iter;
     367           0 :                 for (iter=data.begin(); iter!=data.end(); iter++) {
     368             :                         
     369           0 :                         buf.append(Integer::toString(*iter));
     370           0 :                         buf.append(" ");                      
     371             :                         
     372             :                 }       
     373           0 :         }
     374             :         
     375             :         
     376        1480 :         void Parser::toXML(vector<int> data, const string &name, string &buf) {
     377        1480 :                 buf.append("<" + name + "> ");
     378        1480 :                 buf.append("1 ");
     379        1480 :                 buf.append(Integer::toString(data.size()));
     380        1480 :                 buf.append(" ");
     381        8275 :                 for (unsigned int i = 0; i < data.size(); ++i) {
     382             :         
     383        6795 :                         buf.append(Integer::toString(data[i]));
     384             :                 
     385        6795 :                         buf.append(" ");
     386             :                 }
     387        1480 :                 buf.append(" </" + name + "> ");
     388        1480 :         }
     389             : 
     390           0 :         void Parser::toXML(vector< vector<int> > data, const string &name, string &buf) {
     391           0 :                 buf.append("<" + name + "> ");
     392           0 :                 buf.append("2 ");
     393           0 :                 buf.append(Integer::toString(data.size()));
     394           0 :                 buf.append(" ");
     395           0 :                 buf.append(Integer::toString(data[0].size()));
     396           0 :                 buf.append(" ");
     397           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
     398           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
     399             :         
     400           0 :                                 buf.append(Integer::toString(data[i][j]));
     401             :                 
     402           0 :                                 buf.append(" ");
     403             :                         }
     404             :                 }
     405           0 :                 buf.append(" </" + name + "> ");
     406           0 :         }
     407             :         
     408           0 :         void Parser::toXML(vector< vector< vector<int> > > data, const string &name, string &buf) {
     409           0 :                 buf.append("<" + name + "> ");
     410           0 :                 buf.append("3 ");
     411           0 :                 buf.append(Integer::toString(data.size()));
     412           0 :                 buf.append(" ");
     413           0 :                 buf.append(Integer::toString(data[0].size()));
     414           0 :                 buf.append(" ");
     415           0 :                 buf.append(Integer::toString(data[0][0].size()));
     416           0 :                 buf.append(" ");
     417           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
     418           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
     419           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
     420             :         
     421           0 :                                         buf.append(Integer::toString(data[i][j][k]));
     422             :                 
     423           0 :                                         buf.append(" ");
     424             :                                 }
     425             :                         }
     426             :                 }
     427           0 :                 buf.append(" </" + name + "> ");
     428           0 :         }
     429             :         
     430           0 :         void Parser::toXML(vector<vector< vector< vector<int> > > >data, const string &name, string &buf) {
     431           0 :                 buf.append("<" + name + "> ");
     432           0 :                 buf.append("4 ");
     433           0 :                 buf.append(Integer::toString(data.size()));
     434           0 :                 buf.append(" ");
     435           0 :                 buf.append(Integer::toString(data[0].size()));
     436           0 :                 buf.append(" ");
     437           0 :                 buf.append(Integer::toString(data[0][0].size()));
     438           0 :                 buf.append(" ");
     439           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
     440           0 :                 buf.append(" ");
     441           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
     442           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
     443           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
     444           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
     445             :         
     446           0 :                                                 buf.append(Integer::toString(data[i][j][k][l]));
     447             :                 
     448           0 :                                                 buf.append(" ");
     449             :                                         }
     450             :                                 }
     451             :                         }
     452             :                 }
     453           0 :                 buf.append(" </" + name + "> ");
     454           0 :         }       
     455             :         
     456             :                 
     457             : 
     458             :         
     459             :         
     460           0 :         set< int >  Parser::getIntSet(const string &name, const string &tableName, const string &xmlDoc) {
     461           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     462           0 :                 if (xmlField.length() == 0)
     463           0 :                         throw ConversionException("Error: Missing field \"" + 
     464           0 :                                 name + "\" or invalid syntax",tableName);
     465           0 :                 StringTokenizer t(xmlField," ");
     466           0 :                 set < int > result;
     467             :                 
     468           0 :                 while (t.hasMoreTokens()) {
     469             :                 
     470             :                         
     471             :                         try {
     472           0 :                                 int data = Integer::parseInt(xmlField);
     473           0 :                                 result.insert(data);
     474           0 :                         } catch (const NumberFormatException &e) {
     475           0 :                                 throw ConversionException("Error: Field \"" + 
     476           0 :                                 name + "\": " + e.getMessage(), tableName);
     477           0 :                         }
     478             :                 
     479             :                 }
     480           0 :                 return result;                                                  
     481           0 :         }
     482             :                 
     483             :         
     484      388084 :         int Parser::getInteger(const string &name, const string &tableName, const string &xmlDoc) 
     485             :         {
     486      388084 :                 string xmlField = Parser::getField(xmlDoc,name);
     487      388084 :                 if (xmlField.length() == 0)
     488           0 :                         throw ConversionException("Error: Missing field \"" + 
     489           0 :                                 name + "\" or invalid syntax",tableName);
     490             :         
     491             :                 try {
     492      388084 :                         int data = Integer::parseInt(xmlField);
     493      388084 :                         return data;
     494           0 :                 } catch (const NumberFormatException &e) {
     495           0 :                         throw ConversionException("Error: Field \"" + 
     496           0 :                                 name + "\": " + e.getMessage(), tableName);
     497           0 :                 }
     498             :                 
     499      388084 :         }
     500             : 
     501       75504 :         vector<int> Parser::get1DInteger(const string &name, const string &tableName, const string &xmlDoc)
     502             :         {
     503       75504 :                 string xmlField = Parser::getField(xmlDoc,name);
     504       75504 :                 if (xmlField.length() == 0) {
     505           0 :                         throw ConversionException("Error: Field \"" + 
     506           0 :                                         name + "\": Invalid XML syntax", tableName);
     507             :                 }
     508      151008 :                 StringTokenizer t(xmlField," ");
     509             :                 try {
     510       75504 :                         int ndim = Integer::parseInt(t.nextToken());
     511       75504 :                         if (ndim != 1) {
     512           0 :                                 throw ConversionException("Error: Field \"" + 
     513           0 :                                         name + "\": Invalid array format", tableName);
     514             :                         }
     515       75504 :                         int dim0 = Integer::parseInt(t.nextToken());
     516       75504 :                         vector<int> value (dim0);
     517       75504 :                         if (dim0 == 0)
     518           0 :                                 return value;
     519      669774 :                         for (int i = 0; i < dim0; ++i) {
     520             :         
     521      594270 :                                 value[i] = Integer::parseInt(t.nextToken());
     522             :         
     523             :                         }
     524       75504 :                         if (t.hasMoreTokens()) {
     525           0 :                                 throw ConversionException("Error: Field \"" + 
     526           0 :                                         name + "\": Syntax error.", tableName);
     527             :                         }
     528       75504 :                         return value;
     529       75504 :                 } catch (const NumberFormatException &e) {
     530           0 :                         throw ConversionException("Error: Field \"" + 
     531           0 :                                 name + "\": " + e.getMessage(), tableName);
     532           0 :                 } catch (const OutOfBoundsException &e) {
     533           0 :                         throw  ConversionException("Error: Field \"" + 
     534           0 :                                 name + "\": Unexpected end of string", tableName);
     535           0 :                 } catch (const TagFormatException &e) {
     536           0 :                         throw ConversionException("Error: Field \"" + 
     537           0 :                                 name + "\": " + e.getMessage(), tableName);                              
     538           0 :                 }               
     539       75504 :         }
     540             :                 
     541           0 :         vector< vector<int> > Parser::get2DInteger(const string &name, const string &tableName, const string &xmlDoc)
     542             :         {
     543           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     544           0 :                 if (xmlField.length() == 0) {
     545           0 :                         throw ConversionException("Error: Field \"" + 
     546           0 :                                         name + "\": Invalid XML syntax", tableName);
     547             :                 }
     548           0 :                 StringTokenizer t(xmlField," ");
     549             :                 try {
     550           0 :                         int ndim = Integer::parseInt(t.nextToken());
     551           0 :                         if (ndim != 2) {
     552           0 :                                 throw ConversionException("Error: Field \"" + 
     553           0 :                                         name + "\": Invalid array format", tableName);
     554             :                         }
     555           0 :                         int dim0 = Integer::parseInt(t.nextToken());
     556           0 :                         int dim1 = Integer::parseInt(t.nextToken());
     557           0 :                         vector< vector<int> > value;
     558             : 
     559           0 :                         if (dim0 == 0 || dim1 == 0)
     560           0 :                                 return value;
     561             : 
     562           0 :                         vector<int> v_aux;
     563           0 :                         for (int i = 0; i < dim0; ++i) {
     564           0 :                                 v_aux.clear();
     565           0 :                                 for (int j = 0; j < dim1; ++j) {
     566             :         
     567           0 :                                         v_aux.push_back(Integer::parseInt(t.nextToken()));
     568             :         
     569             :                                 }
     570           0 :                                 value.push_back(v_aux);
     571             :                         }
     572           0 :                         if (t.hasMoreTokens()) {
     573           0 :                                 throw ConversionException("Error: Field \"" + 
     574           0 :                                         name + "\": Syntax error.", tableName);
     575             :                         }
     576           0 :                         return value;
     577           0 :                 } catch (const NumberFormatException &e) {
     578           0 :                         throw ConversionException("Error: Field \"" + 
     579           0 :                                 name + "\": " + e.getMessage(), tableName);
     580           0 :                 } catch (const OutOfBoundsException &e) {
     581           0 :                         throw  ConversionException("Error: Field \"" + 
     582           0 :                                 name + "\": Unexpected end of string", tableName);
     583           0 :                 } catch (const TagFormatException &e) {
     584           0 :                         throw ConversionException("Error: Field \"" + 
     585           0 :                                 name + "\": " + e.getMessage(), tableName);                              
     586           0 :                 }               
     587           0 :         }       
     588             :         
     589           0 :         vector< vector< vector<int> > > Parser::get3DInteger(const string &name, const string &tableName, const string &xmlDoc)
     590             :         {
     591           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     592           0 :                 if (xmlField.length() == 0) {
     593           0 :                         throw ConversionException("Error: Field \"" + 
     594           0 :                                         name + "\": Invalid XML syntax", tableName);
     595             :                 }
     596           0 :                 StringTokenizer t(xmlField," ");
     597             :                 try {
     598           0 :                         int ndim = Integer::parseInt(t.nextToken());
     599           0 :                         if (ndim != 3) {
     600           0 :                                 throw ConversionException("Error: Field \"" + 
     601           0 :                                         name + "\": Invalid array format", tableName);
     602             :                         }
     603           0 :                         int dim0 = Integer::parseInt(t.nextToken());
     604           0 :                         int dim1 = Integer::parseInt(t.nextToken());
     605           0 :                         int dim2 = Integer::parseInt(t.nextToken());
     606           0 :                         vector< vector< vector<int> > > value ;
     607           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
     608           0 :                                 return value;
     609             :                         
     610           0 :                         vector<vector<int> > vv_aux;
     611           0 :                         vector<int> v_aux;
     612           0 :                         for (int i = 0; i < dim0; ++i) {
     613           0 :                                 vv_aux.clear();
     614           0 :                                 for (int j = 0; j < dim1; ++j) {
     615           0 :                                         v_aux.clear();
     616           0 :                                         for (int k = 0; k < dim2; ++k) {
     617             :         
     618           0 :                                                 v_aux.push_back(Integer::parseInt(t.nextToken()));
     619             :         
     620             :                                         }
     621           0 :                                         vv_aux.push_back(v_aux);
     622             :                                 }
     623           0 :                                 value.push_back(vv_aux);
     624             :                         }
     625           0 :                         if (t.hasMoreTokens()) {
     626           0 :                                 throw ConversionException("Error: Field \"" + 
     627           0 :                                         name + "\": Syntax error.", tableName);
     628             :                         }
     629           0 :                         return value;
     630           0 :                 } catch (const NumberFormatException &e) {
     631           0 :                         throw ConversionException("Error: Field \"" + 
     632           0 :                                 name + "\": " + e.getMessage(), tableName);
     633           0 :                 } catch (const OutOfBoundsException &e) {
     634           0 :                         throw  ConversionException("Error: Field \"" + 
     635           0 :                                 name + "\": Unexpected end of string", tableName);
     636           0 :                 } catch (const TagFormatException &e) {
     637           0 :                         throw ConversionException("Error: Field \"" + 
     638           0 :                                 name + "\": " + e.getMessage(), tableName);                              
     639           0 :                 }               
     640           0 :         }
     641             :         
     642           0 :         vector< vector< vector< vector<int> > > >Parser::get4DInteger(const string &name, const string &tableName, const string &xmlDoc)
     643             :         {
     644           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     645           0 :                 if (xmlField.length() == 0) {
     646           0 :                         throw ConversionException("Error: Field \"" + 
     647           0 :                                         name + "\": Invalid XML syntax", tableName);
     648             :                 }
     649           0 :                 StringTokenizer t(xmlField," ");
     650             :                 try {
     651           0 :                         int ndim = Integer::parseInt(t.nextToken());
     652           0 :                         if (ndim != 4) {
     653           0 :                                 throw ConversionException("Error: Field \"" + 
     654           0 :                                         name + "\": Invalid array format", tableName);
     655             :                         }
     656           0 :                         int dim0 = Integer::parseInt(t.nextToken());
     657           0 :                         int dim1 = Integer::parseInt(t.nextToken());
     658           0 :                         int dim2 = Integer::parseInt(t.nextToken());
     659           0 :                         int dim3 = Integer::parseInt(t.nextToken());
     660           0 :                         vector<vector< vector< vector<int> > > >value;
     661           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
     662           0 :                                 return value;
     663             :                         
     664           0 :                         vector<vector<vector<int> > >vvv_aux;
     665           0 :                         vector<vector< int> > vv_aux;
     666           0 :                         vector<int> v_aux;
     667           0 :                         for (int i = 0; i < dim0; ++i) {
     668           0 :                                 vvv_aux.clear();
     669           0 :                                 for (int j = 0; j < dim1; ++j) {
     670           0 :                                         vv_aux.clear();
     671           0 :                                         for (int k = 0; k < dim2; ++k) {
     672           0 :                                                 v_aux.clear();
     673           0 :                                                 for (int l = 0; l < dim3; l++) {
     674             :         
     675           0 :                                                         v_aux.push_back(Integer::parseInt(t.nextToken()));
     676             :         
     677             :                                                 }
     678           0 :                                                 vv_aux.push_back(v_aux);
     679             :                                         }
     680           0 :                                         vvv_aux.push_back(vv_aux);
     681             :                                 }
     682           0 :                                 value.push_back(vvv_aux);
     683             :                         }
     684           0 :                         if (t.hasMoreTokens()) {
     685           0 :                                 throw ConversionException("Error: Field \"" + 
     686           0 :                                         name + "\": Syntax error.", tableName);
     687             :                         }
     688           0 :                         return value;
     689           0 :                 } catch (const NumberFormatException &e) {
     690           0 :                         throw ConversionException("Error: Field \"" + 
     691           0 :                                 name + "\": " + e.getMessage(), tableName);
     692           0 :                 } catch (const OutOfBoundsException &e) {
     693           0 :                         throw  ConversionException("Error: Field \"" + 
     694           0 :                                 name + "\": Unexpected end of string", tableName);
     695           0 :                 } catch (const TagFormatException &e) {
     696           0 :                         throw ConversionException("Error: Field \"" + 
     697           0 :                                 name + "\": " + e.getMessage(), tableName);                              
     698           0 :                 }               
     699           0 :         }       
     700             :         
     701             : 
     702             :                 
     703             : 
     704             : 
     705             :         // Field type: short
     706             : 
     707           0 :         void Parser::toXML(short data, const string &name, string &buf) {
     708           0 :                 buf.append("<" + name + "> ");
     709             :         
     710           0 :                 buf.append(Short::toString(data));
     711             :                 
     712           0 :                 buf.append(" </" + name + "> ");
     713           0 :         }
     714             : 
     715             :         
     716             :         
     717             :         
     718           0 :         void Parser::toXML(vector<short> data, const string &name, string &buf) {
     719           0 :                 buf.append("<" + name + "> ");
     720           0 :                 buf.append("1 ");
     721           0 :                 buf.append(Integer::toString(data.size()));
     722           0 :                 buf.append(" ");
     723           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
     724             :         
     725           0 :                         buf.append(Short::toString(data[i]));
     726             :                 
     727           0 :                         buf.append(" ");
     728             :                 }
     729           0 :                 buf.append(" </" + name + "> ");
     730           0 :         }
     731             : 
     732           0 :         void Parser::toXML(vector< vector<short> > data, const string &name, string &buf) {
     733           0 :                 buf.append("<" + name + "> ");
     734           0 :                 buf.append("2 ");
     735           0 :                 buf.append(Integer::toString(data.size()));
     736           0 :                 buf.append(" ");
     737           0 :                 buf.append(Integer::toString(data[0].size()));
     738           0 :                 buf.append(" ");
     739           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
     740           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
     741             :         
     742           0 :                                 buf.append(Short::toString(data[i][j]));
     743             :                 
     744           0 :                                 buf.append(" ");
     745             :                         }
     746             :                 }
     747           0 :                 buf.append(" </" + name + "> ");
     748           0 :         }
     749             :         
     750           0 :         void Parser::toXML(vector< vector< vector<short> > > data, const string &name, string &buf) {
     751           0 :                 buf.append("<" + name + "> ");
     752           0 :                 buf.append("3 ");
     753           0 :                 buf.append(Integer::toString(data.size()));
     754           0 :                 buf.append(" ");
     755           0 :                 buf.append(Integer::toString(data[0].size()));
     756           0 :                 buf.append(" ");
     757           0 :                 buf.append(Integer::toString(data[0][0].size()));
     758           0 :                 buf.append(" ");
     759           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
     760           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
     761           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
     762             :         
     763           0 :                                         buf.append(Short::toString(data[i][j][k]));
     764             :                 
     765           0 :                                         buf.append(" ");
     766             :                                 }
     767             :                         }
     768             :                 }
     769           0 :                 buf.append(" </" + name + "> ");
     770           0 :         }
     771             :         
     772           0 :         void Parser::toXML(vector<vector< vector< vector<short> > > >data, const string &name, string &buf) {
     773           0 :                 buf.append("<" + name + "> ");
     774           0 :                 buf.append("4 ");
     775           0 :                 buf.append(Integer::toString(data.size()));
     776           0 :                 buf.append(" ");
     777           0 :                 buf.append(Integer::toString(data[0].size()));
     778           0 :                 buf.append(" ");
     779           0 :                 buf.append(Integer::toString(data[0][0].size()));
     780           0 :                 buf.append(" ");
     781           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
     782           0 :                 buf.append(" ");
     783           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
     784           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
     785           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
     786           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
     787             :         
     788           0 :                                                 buf.append(Short::toString(data[i][j][k][l]));
     789             :                 
     790           0 :                                                 buf.append(" ");
     791             :                                         }
     792             :                                 }
     793             :                         }
     794             :                 }
     795           0 :                 buf.append(" </" + name + "> ");
     796           0 :         }       
     797             :         
     798             :                 
     799             : 
     800             :         
     801             :                 
     802             :         
     803           0 :         short Parser::getShort(const string &name, const string &tableName, const string &xmlDoc) 
     804             :         {
     805           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     806           0 :                 if (xmlField.length() == 0)
     807           0 :                         throw ConversionException("Error: Missing field \"" + 
     808           0 :                                 name + "\" or invalid syntax",tableName);
     809             :         
     810             :                 try {
     811           0 :                         short data = Short::parseShort(xmlField);
     812           0 :                         return data;
     813           0 :                 } catch (const NumberFormatException &e) {
     814           0 :                         throw ConversionException("Error: Field \"" + 
     815           0 :                                 name + "\": " + e.getMessage(), tableName);
     816           0 :                 }
     817             :                 
     818           0 :         }
     819             : 
     820           0 :         vector<short> Parser::get1DShort(const string &name, const string &tableName, const string &xmlDoc)
     821             :         {
     822           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     823           0 :                 if (xmlField.length() == 0) {
     824           0 :                         throw ConversionException("Error: Field \"" + 
     825           0 :                                         name + "\": Invalid XML syntax", tableName);
     826             :                 }
     827           0 :                 StringTokenizer t(xmlField," ");
     828             :                 try {
     829           0 :                         int ndim = Integer::parseInt(t.nextToken());
     830           0 :                         if (ndim != 1) {
     831           0 :                                 throw ConversionException("Error: Field \"" + 
     832           0 :                                         name + "\": Invalid array format", tableName);
     833             :                         }
     834           0 :                         int dim0 = Integer::parseInt(t.nextToken());
     835           0 :                         vector<short> value (dim0);
     836           0 :                         if (dim0 == 0)
     837           0 :                                 return value;
     838           0 :                         for (int i = 0; i < dim0; ++i) {
     839             :         
     840           0 :                                 value[i] = Short::parseShort(t.nextToken());
     841             :         
     842             :                         }
     843           0 :                         if (t.hasMoreTokens()) {
     844           0 :                                 throw ConversionException("Error: Field \"" + 
     845           0 :                                         name + "\": Syntax error.", tableName);
     846             :                         }
     847           0 :                         return value;
     848           0 :                 } catch (const NumberFormatException &e) {
     849           0 :                         throw ConversionException("Error: Field \"" + 
     850           0 :                                 name + "\": " + e.getMessage(), tableName);
     851           0 :                 } catch (const OutOfBoundsException &e) {
     852           0 :                         throw  ConversionException("Error: Field \"" + 
     853           0 :                                 name + "\": Unexpected end of string", tableName);
     854           0 :                 } catch (const TagFormatException &e) {
     855           0 :                         throw ConversionException("Error: Field \"" + 
     856           0 :                                 name + "\": " + e.getMessage(), tableName);                              
     857           0 :                 }               
     858           0 :         }
     859             :                 
     860           0 :         vector< vector<short> > Parser::get2DShort(const string &name, const string &tableName, const string &xmlDoc)
     861             :         {
     862           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     863           0 :                 if (xmlField.length() == 0) {
     864           0 :                         throw ConversionException("Error: Field \"" + 
     865           0 :                                         name + "\": Invalid XML syntax", tableName);
     866             :                 }
     867           0 :                 StringTokenizer t(xmlField," ");
     868             :                 try {
     869           0 :                         int ndim = Integer::parseInt(t.nextToken());
     870           0 :                         if (ndim != 2) {
     871           0 :                                 throw ConversionException("Error: Field \"" + 
     872           0 :                                         name + "\": Invalid array format", tableName);
     873             :                         }
     874           0 :                         int dim0 = Integer::parseInt(t.nextToken());
     875           0 :                         int dim1 = Integer::parseInt(t.nextToken());
     876           0 :                         vector< vector<short> > value;
     877             : 
     878           0 :                         if (dim0 == 0 || dim1 == 0)
     879           0 :                                 return value;
     880             : 
     881           0 :                         vector<short> v_aux;
     882           0 :                         for (int i = 0; i < dim0; ++i) {
     883           0 :                                 v_aux.clear();
     884           0 :                                 for (int j = 0; j < dim1; ++j) {
     885             :         
     886           0 :                                         v_aux.push_back(Short::parseShort(t.nextToken()));
     887             :         
     888             :                                 }
     889           0 :                                 value.push_back(v_aux);
     890             :                         }
     891           0 :                         if (t.hasMoreTokens()) {
     892           0 :                                 throw ConversionException("Error: Field \"" + 
     893           0 :                                         name + "\": Syntax error.", tableName);
     894             :                         }
     895           0 :                         return value;
     896           0 :                 } catch (const NumberFormatException &e) {
     897           0 :                         throw ConversionException("Error: Field \"" + 
     898           0 :                                 name + "\": " + e.getMessage(), tableName);
     899           0 :                 } catch (const OutOfBoundsException &e) {
     900           0 :                         throw  ConversionException("Error: Field \"" + 
     901           0 :                                 name + "\": Unexpected end of string", tableName);
     902           0 :                 } catch (const TagFormatException &e) {
     903           0 :                         throw ConversionException("Error: Field \"" + 
     904           0 :                                 name + "\": " + e.getMessage(), tableName);                              
     905           0 :                 }               
     906           0 :         }       
     907             :         
     908           0 :         vector< vector< vector<short> > > Parser::get3DShort(const string &name, const string &tableName, const string &xmlDoc)
     909             :         {
     910           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     911           0 :                 if (xmlField.length() == 0) {
     912           0 :                         throw ConversionException("Error: Field \"" + 
     913           0 :                                         name + "\": Invalid XML syntax", tableName);
     914             :                 }
     915           0 :                 StringTokenizer t(xmlField," ");
     916             :                 try {
     917           0 :                         int ndim = Integer::parseInt(t.nextToken());
     918           0 :                         if (ndim != 3) {
     919           0 :                                 throw ConversionException("Error: Field \"" + 
     920           0 :                                         name + "\": Invalid array format", tableName);
     921             :                         }
     922           0 :                         int dim0 = Integer::parseInt(t.nextToken());
     923           0 :                         int dim1 = Integer::parseInt(t.nextToken());
     924           0 :                         int dim2 = Integer::parseInt(t.nextToken());
     925           0 :                         vector< vector< vector<short> > > value ;
     926           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
     927           0 :                                 return value;
     928             :                         
     929           0 :                         vector<vector<short> > vv_aux;
     930           0 :                         vector<short> v_aux;
     931           0 :                         for (int i = 0; i < dim0; ++i) {
     932           0 :                                 vv_aux.clear();
     933           0 :                                 for (int j = 0; j < dim1; ++j) {
     934           0 :                                         v_aux.clear();
     935           0 :                                         for (int k = 0; k < dim2; ++k) {
     936             :         
     937           0 :                                                 v_aux.push_back(Short::parseShort(t.nextToken()));
     938             :         
     939             :                                         }
     940           0 :                                         vv_aux.push_back(v_aux);
     941             :                                 }
     942           0 :                                 value.push_back(vv_aux);
     943             :                         }
     944           0 :                         if (t.hasMoreTokens()) {
     945           0 :                                 throw ConversionException("Error: Field \"" + 
     946           0 :                                         name + "\": Syntax error.", tableName);
     947             :                         }
     948           0 :                         return value;
     949           0 :                 } catch (const NumberFormatException &e) {
     950           0 :                         throw ConversionException("Error: Field \"" + 
     951           0 :                                 name + "\": " + e.getMessage(), tableName);
     952           0 :                 } catch (const OutOfBoundsException &e) {
     953           0 :                         throw  ConversionException("Error: Field \"" + 
     954           0 :                                 name + "\": Unexpected end of string", tableName);
     955           0 :                 } catch (const TagFormatException &e) {
     956           0 :                         throw ConversionException("Error: Field \"" + 
     957           0 :                                 name + "\": " + e.getMessage(), tableName);                              
     958           0 :                 }               
     959           0 :         }
     960             :         
     961           0 :         vector< vector< vector< vector<short> > > >Parser::get4DShort(const string &name, const string &tableName, const string &xmlDoc)
     962             :         {
     963           0 :                 string xmlField = Parser::getField(xmlDoc,name);
     964           0 :                 if (xmlField.length() == 0) {
     965           0 :                         throw ConversionException("Error: Field \"" + 
     966           0 :                                         name + "\": Invalid XML syntax", tableName);
     967             :                 }
     968           0 :                 StringTokenizer t(xmlField," ");
     969             :                 try {
     970           0 :                         int ndim = Integer::parseInt(t.nextToken());
     971           0 :                         if (ndim != 4) {
     972           0 :                                 throw ConversionException("Error: Field \"" + 
     973           0 :                                         name + "\": Invalid array format", tableName);
     974             :                         }
     975           0 :                         int dim0 = Integer::parseInt(t.nextToken());
     976           0 :                         int dim1 = Integer::parseInt(t.nextToken());
     977           0 :                         int dim2 = Integer::parseInt(t.nextToken());
     978           0 :                         int dim3 = Integer::parseInt(t.nextToken());
     979           0 :                         vector<vector< vector< vector<short> > > >value;
     980           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
     981           0 :                                 return value;
     982             :                         
     983           0 :                         vector<vector<vector<short> > >vvv_aux;
     984           0 :                         vector<vector< short> > vv_aux;
     985           0 :                         vector<short> v_aux;
     986           0 :                         for (int i = 0; i < dim0; ++i) {
     987           0 :                                 vvv_aux.clear();
     988           0 :                                 for (int j = 0; j < dim1; ++j) {
     989           0 :                                         vv_aux.clear();
     990           0 :                                         for (int k = 0; k < dim2; ++k) {
     991           0 :                                                 v_aux.clear();
     992           0 :                                                 for (int l = 0; l < dim3; l++) {
     993             :         
     994           0 :                                                         v_aux.push_back(Short::parseShort(t.nextToken()));
     995             :         
     996             :                                                 }
     997           0 :                                                 vv_aux.push_back(v_aux);
     998             :                                         }
     999           0 :                                         vvv_aux.push_back(vv_aux);
    1000             :                                 }
    1001           0 :                                 value.push_back(vvv_aux);
    1002             :                         }
    1003           0 :                         if (t.hasMoreTokens()) {
    1004           0 :                                 throw ConversionException("Error: Field \"" + 
    1005           0 :                                         name + "\": Syntax error.", tableName);
    1006             :                         }
    1007           0 :                         return value;
    1008           0 :                 } catch (const NumberFormatException &e) {
    1009           0 :                         throw ConversionException("Error: Field \"" + 
    1010           0 :                                 name + "\": " + e.getMessage(), tableName);
    1011           0 :                 } catch (const OutOfBoundsException &e) {
    1012           0 :                         throw  ConversionException("Error: Field \"" + 
    1013           0 :                                 name + "\": Unexpected end of string", tableName);
    1014           0 :                 } catch (const TagFormatException &e) {
    1015           0 :                         throw ConversionException("Error: Field \"" + 
    1016           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1017           0 :                 }               
    1018           0 :         }       
    1019             :         
    1020             : 
    1021             :                 
    1022             : 
    1023             : 
    1024             :         // Field type: int64_t
    1025             : 
    1026         536 :         void Parser::toXML(int64_t data, const string &name, string &buf) {
    1027         536 :                 buf.append("<" + name + "> ");
    1028             :         
    1029         536 :                 buf.append(Long::toString(data));
    1030             :                 
    1031         536 :                 buf.append(" </" + name + "> ");
    1032         536 :         }
    1033             : 
    1034             :         
    1035             :         
    1036             :         
    1037           0 :         void Parser::toXML(vector<int64_t> data, const string &name, string &buf) {
    1038           0 :                 buf.append("<" + name + "> ");
    1039           0 :                 buf.append("1 ");
    1040           0 :                 buf.append(Integer::toString(data.size()));
    1041           0 :                 buf.append(" ");
    1042           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1043             :         
    1044           0 :                         buf.append(Long::toString(data[i]));
    1045             :                 
    1046           0 :                         buf.append(" ");
    1047             :                 }
    1048           0 :                 buf.append(" </" + name + "> ");
    1049           0 :         }
    1050             : 
    1051           0 :         void Parser::toXML(vector< vector<int64_t> > data, const string &name, string &buf) {
    1052           0 :                 buf.append("<" + name + "> ");
    1053           0 :                 buf.append("2 ");
    1054           0 :                 buf.append(Integer::toString(data.size()));
    1055           0 :                 buf.append(" ");
    1056           0 :                 buf.append(Integer::toString(data[0].size()));
    1057           0 :                 buf.append(" ");
    1058           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1059           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    1060             :         
    1061           0 :                                 buf.append(Long::toString(data[i][j]));
    1062             :                 
    1063           0 :                                 buf.append(" ");
    1064             :                         }
    1065             :                 }
    1066           0 :                 buf.append(" </" + name + "> ");
    1067           0 :         }
    1068             :         
    1069           0 :         void Parser::toXML(vector< vector< vector<int64_t> > > data, const string &name, string &buf) {
    1070           0 :                 buf.append("<" + name + "> ");
    1071           0 :                 buf.append("3 ");
    1072           0 :                 buf.append(Integer::toString(data.size()));
    1073           0 :                 buf.append(" ");
    1074           0 :                 buf.append(Integer::toString(data[0].size()));
    1075           0 :                 buf.append(" ");
    1076           0 :                 buf.append(Integer::toString(data[0][0].size()));
    1077           0 :                 buf.append(" ");
    1078           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1079           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    1080           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    1081             :         
    1082           0 :                                         buf.append(Long::toString(data[i][j][k]));
    1083             :                 
    1084           0 :                                         buf.append(" ");
    1085             :                                 }
    1086             :                         }
    1087             :                 }
    1088           0 :                 buf.append(" </" + name + "> ");
    1089           0 :         }
    1090             :         
    1091           0 :         void Parser::toXML(vector<vector< vector< vector<int64_t> > > >data, const string &name, string &buf) {
    1092           0 :                 buf.append("<" + name + "> ");
    1093           0 :                 buf.append("4 ");
    1094           0 :                 buf.append(Integer::toString(data.size()));
    1095           0 :                 buf.append(" ");
    1096           0 :                 buf.append(Integer::toString(data[0].size()));
    1097           0 :                 buf.append(" ");
    1098           0 :                 buf.append(Integer::toString(data[0][0].size()));
    1099           0 :                 buf.append(" ");
    1100           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    1101           0 :                 buf.append(" ");
    1102           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1103           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    1104           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    1105           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    1106             :         
    1107           0 :                                                 buf.append(Long::toString(data[i][j][k][l]));
    1108             :                 
    1109           0 :                                                 buf.append(" ");
    1110             :                                         }
    1111             :                                 }
    1112             :                         }
    1113             :                 }
    1114           0 :                 buf.append(" </" + name + "> ");
    1115           0 :         }       
    1116             :         
    1117             :                 
    1118             : 
    1119             :         
    1120             :                 
    1121             :         
    1122        7737 :         int64_t Parser::getLong(const string &name, const string &tableName, const string &xmlDoc) 
    1123             :         {
    1124        7737 :                 string xmlField = Parser::getField(xmlDoc,name);
    1125        7737 :                 if (xmlField.length() == 0)
    1126           0 :                         throw ConversionException("Error: Missing field \"" + 
    1127           0 :                                 name + "\" or invalid syntax",tableName);
    1128             :         
    1129             :                 try {
    1130        7737 :                         int64_t data = Long::parseLong(xmlField);
    1131        7737 :                         return data;
    1132           0 :                 } catch (const NumberFormatException &e) {
    1133           0 :                         throw ConversionException("Error: Field \"" + 
    1134           0 :                                 name + "\": " + e.getMessage(), tableName);
    1135           0 :                 }
    1136             :                 
    1137        7737 :         }
    1138             : 
    1139           0 :         vector<int64_t> Parser::get1DLong(const string &name, const string &tableName, const string &xmlDoc)
    1140             :         {
    1141           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1142           0 :                 if (xmlField.length() == 0) {
    1143           0 :                         throw ConversionException("Error: Field \"" + 
    1144           0 :                                         name + "\": Invalid XML syntax", tableName);
    1145             :                 }
    1146           0 :                 StringTokenizer t(xmlField," ");
    1147             :                 try {
    1148           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1149           0 :                         if (ndim != 1) {
    1150           0 :                                 throw ConversionException("Error: Field \"" + 
    1151           0 :                                         name + "\": Invalid array format", tableName);
    1152             :                         }
    1153           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1154           0 :                         vector<int64_t> value (dim0);
    1155           0 :                         if (dim0 == 0)
    1156           0 :                                 return value;
    1157           0 :                         for (int i = 0; i < dim0; ++i) {
    1158             :         
    1159           0 :                                 value[i] = Long::parseLong(t.nextToken());
    1160             :         
    1161             :                         }
    1162           0 :                         if (t.hasMoreTokens()) {
    1163           0 :                                 throw ConversionException("Error: Field \"" + 
    1164           0 :                                         name + "\": Syntax error.", tableName);
    1165             :                         }
    1166           0 :                         return value;
    1167           0 :                 } catch (const NumberFormatException &e) {
    1168           0 :                         throw ConversionException("Error: Field \"" + 
    1169           0 :                                 name + "\": " + e.getMessage(), tableName);
    1170           0 :                 } catch (const OutOfBoundsException &e) {
    1171           0 :                         throw  ConversionException("Error: Field \"" + 
    1172           0 :                                 name + "\": Unexpected end of string", tableName);
    1173           0 :                 } catch (const TagFormatException &e) {
    1174           0 :                         throw ConversionException("Error: Field \"" + 
    1175           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1176           0 :                 }               
    1177           0 :         }
    1178             :                 
    1179           0 :         vector< vector<int64_t> > Parser::get2DLong(const string &name, const string &tableName, const string &xmlDoc)
    1180             :         {
    1181           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1182           0 :                 if (xmlField.length() == 0) {
    1183           0 :                         throw ConversionException("Error: Field \"" + 
    1184           0 :                                         name + "\": Invalid XML syntax", tableName);
    1185             :                 }
    1186           0 :                 StringTokenizer t(xmlField," ");
    1187             :                 try {
    1188           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1189           0 :                         if (ndim != 2) {
    1190           0 :                                 throw ConversionException("Error: Field \"" + 
    1191           0 :                                         name + "\": Invalid array format", tableName);
    1192             :                         }
    1193           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1194           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    1195           0 :                         vector< vector<int64_t> > value;
    1196             : 
    1197           0 :                         if (dim0 == 0 || dim1 == 0)
    1198           0 :                                 return value;
    1199             : 
    1200           0 :                         vector<int64_t> v_aux;
    1201           0 :                         for (int i = 0; i < dim0; ++i) {
    1202           0 :                                 v_aux.clear();
    1203           0 :                                 for (int j = 0; j < dim1; ++j) {
    1204             :         
    1205           0 :                                         v_aux.push_back(Long::parseLong(t.nextToken()));
    1206             :         
    1207             :                                 }
    1208           0 :                                 value.push_back(v_aux);
    1209             :                         }
    1210           0 :                         if (t.hasMoreTokens()) {
    1211           0 :                                 throw ConversionException("Error: Field \"" + 
    1212           0 :                                         name + "\": Syntax error.", tableName);
    1213             :                         }
    1214           0 :                         return value;
    1215           0 :                 } catch (const NumberFormatException &e) {
    1216           0 :                         throw ConversionException("Error: Field \"" + 
    1217           0 :                                 name + "\": " + e.getMessage(), tableName);
    1218           0 :                 } catch (const OutOfBoundsException &e) {
    1219           0 :                         throw  ConversionException("Error: Field \"" + 
    1220           0 :                                 name + "\": Unexpected end of string", tableName);
    1221           0 :                 } catch (const TagFormatException &e) {
    1222           0 :                         throw ConversionException("Error: Field \"" + 
    1223           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1224           0 :                 }               
    1225           0 :         }       
    1226             :         
    1227           0 :         vector< vector< vector<int64_t> > > Parser::get3DLong(const string &name, const string &tableName, const string &xmlDoc)
    1228             :         {
    1229           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1230           0 :                 if (xmlField.length() == 0) {
    1231           0 :                         throw ConversionException("Error: Field \"" + 
    1232           0 :                                         name + "\": Invalid XML syntax", tableName);
    1233             :                 }
    1234           0 :                 StringTokenizer t(xmlField," ");
    1235             :                 try {
    1236           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1237           0 :                         if (ndim != 3) {
    1238           0 :                                 throw ConversionException("Error: Field \"" + 
    1239           0 :                                         name + "\": Invalid array format", tableName);
    1240             :                         }
    1241           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1242           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    1243           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    1244           0 :                         vector< vector< vector<int64_t> > > value ;
    1245           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    1246           0 :                                 return value;
    1247             :                         
    1248           0 :                         vector<vector<int64_t> > vv_aux;
    1249           0 :                         vector<int64_t> v_aux;
    1250           0 :                         for (int i = 0; i < dim0; ++i) {
    1251           0 :                                 vv_aux.clear();
    1252           0 :                                 for (int j = 0; j < dim1; ++j) {
    1253           0 :                                         v_aux.clear();
    1254           0 :                                         for (int k = 0; k < dim2; ++k) {
    1255             :         
    1256           0 :                                                 v_aux.push_back(Long::parseLong(t.nextToken()));
    1257             :         
    1258             :                                         }
    1259           0 :                                         vv_aux.push_back(v_aux);
    1260             :                                 }
    1261           0 :                                 value.push_back(vv_aux);
    1262             :                         }
    1263           0 :                         if (t.hasMoreTokens()) {
    1264           0 :                                 throw ConversionException("Error: Field \"" + 
    1265           0 :                                         name + "\": Syntax error.", tableName);
    1266             :                         }
    1267           0 :                         return value;
    1268           0 :                 } catch (const NumberFormatException &e) {
    1269           0 :                         throw ConversionException("Error: Field \"" + 
    1270           0 :                                 name + "\": " + e.getMessage(), tableName);
    1271           0 :                 } catch (const OutOfBoundsException &e) {
    1272           0 :                         throw  ConversionException("Error: Field \"" + 
    1273           0 :                                 name + "\": Unexpected end of string", tableName);
    1274           0 :                 } catch (const TagFormatException &e) {
    1275           0 :                         throw ConversionException("Error: Field \"" + 
    1276           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1277           0 :                 }               
    1278           0 :         }
    1279             :         
    1280           0 :         vector< vector< vector< vector<int64_t> > > >Parser::get4DLong(const string &name, const string &tableName, const string &xmlDoc)
    1281             :         {
    1282           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1283           0 :                 if (xmlField.length() == 0) {
    1284           0 :                         throw ConversionException("Error: Field \"" + 
    1285           0 :                                         name + "\": Invalid XML syntax", tableName);
    1286             :                 }
    1287           0 :                 StringTokenizer t(xmlField," ");
    1288             :                 try {
    1289           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1290           0 :                         if (ndim != 4) {
    1291           0 :                                 throw ConversionException("Error: Field \"" + 
    1292           0 :                                         name + "\": Invalid array format", tableName);
    1293             :                         }
    1294           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1295           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    1296           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    1297           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    1298           0 :                         vector<vector< vector< vector<int64_t> > > >value;
    1299           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    1300           0 :                                 return value;
    1301             :                         
    1302           0 :                         vector<vector<vector<int64_t> > >vvv_aux;
    1303           0 :                         vector<vector< int64_t> > vv_aux;
    1304           0 :                         vector<int64_t> v_aux;
    1305           0 :                         for (int i = 0; i < dim0; ++i) {
    1306           0 :                                 vvv_aux.clear();
    1307           0 :                                 for (int j = 0; j < dim1; ++j) {
    1308           0 :                                         vv_aux.clear();
    1309           0 :                                         for (int k = 0; k < dim2; ++k) {
    1310           0 :                                                 v_aux.clear();
    1311           0 :                                                 for (int l = 0; l < dim3; l++) {
    1312             :         
    1313           0 :                                                         v_aux.push_back(Long::parseLong(t.nextToken()));
    1314             :         
    1315             :                                                 }
    1316           0 :                                                 vv_aux.push_back(v_aux);
    1317             :                                         }
    1318           0 :                                         vvv_aux.push_back(vv_aux);
    1319             :                                 }
    1320           0 :                                 value.push_back(vvv_aux);
    1321             :                         }
    1322           0 :                         if (t.hasMoreTokens()) {
    1323           0 :                                 throw ConversionException("Error: Field \"" + 
    1324           0 :                                         name + "\": Syntax error.", tableName);
    1325             :                         }
    1326           0 :                         return value;
    1327           0 :                 } catch (const NumberFormatException &e) {
    1328           0 :                         throw ConversionException("Error: Field \"" + 
    1329           0 :                                 name + "\": " + e.getMessage(), tableName);
    1330           0 :                 } catch (const OutOfBoundsException &e) {
    1331           0 :                         throw  ConversionException("Error: Field \"" + 
    1332           0 :                                 name + "\": Unexpected end of string", tableName);
    1333           0 :                 } catch (const TagFormatException &e) {
    1334           0 :                         throw ConversionException("Error: Field \"" + 
    1335           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1336           0 :                 }               
    1337           0 :         }       
    1338             :         
    1339             : 
    1340             :                 
    1341             : 
    1342             : 
    1343             :         // Field type: char
    1344             : 
    1345           0 :         void Parser::toXML(char data, const string &name, string &buf) {
    1346           0 :                 buf.append("<" + name + "> ");
    1347             :         
    1348           0 :                 buf.append(Byte::toString(data));
    1349             :                 
    1350           0 :                 buf.append(" </" + name + "> ");
    1351           0 :         }
    1352             : 
    1353             :         
    1354             :         
    1355             :         
    1356           0 :         void Parser::toXML(vector<char> data, const string &name, string &buf) {
    1357           0 :                 buf.append("<" + name + "> ");
    1358           0 :                 buf.append("1 ");
    1359           0 :                 buf.append(Integer::toString(data.size()));
    1360           0 :                 buf.append(" ");
    1361           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1362             :         
    1363           0 :                         buf.append(Byte::toString(data[i]));
    1364             :                 
    1365           0 :                         buf.append(" ");
    1366             :                 }
    1367           0 :                 buf.append(" </" + name + "> ");
    1368           0 :         }
    1369             : 
    1370           0 :         void Parser::toXML(vector< vector<char> > data, const string &name, string &buf) {
    1371           0 :                 buf.append("<" + name + "> ");
    1372           0 :                 buf.append("2 ");
    1373           0 :                 buf.append(Integer::toString(data.size()));
    1374           0 :                 buf.append(" ");
    1375           0 :                 buf.append(Integer::toString(data[0].size()));
    1376           0 :                 buf.append(" ");
    1377           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1378           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    1379             :         
    1380           0 :                                 buf.append(Byte::toString(data[i][j]));
    1381             :                 
    1382           0 :                                 buf.append(" ");
    1383             :                         }
    1384             :                 }
    1385           0 :                 buf.append(" </" + name + "> ");
    1386           0 :         }
    1387             :         
    1388           0 :         void Parser::toXML(vector< vector< vector<char> > > data, const string &name, string &buf) {
    1389           0 :                 buf.append("<" + name + "> ");
    1390           0 :                 buf.append("3 ");
    1391           0 :                 buf.append(Integer::toString(data.size()));
    1392           0 :                 buf.append(" ");
    1393           0 :                 buf.append(Integer::toString(data[0].size()));
    1394           0 :                 buf.append(" ");
    1395           0 :                 buf.append(Integer::toString(data[0][0].size()));
    1396           0 :                 buf.append(" ");
    1397           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1398           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    1399           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    1400             :         
    1401           0 :                                         buf.append(Byte::toString(data[i][j][k]));
    1402             :                 
    1403           0 :                                         buf.append(" ");
    1404             :                                 }
    1405             :                         }
    1406             :                 }
    1407           0 :                 buf.append(" </" + name + "> ");
    1408           0 :         }
    1409             :         
    1410           0 :         void Parser::toXML(vector<vector< vector< vector<char> > > >data, const string &name, string &buf) {
    1411           0 :                 buf.append("<" + name + "> ");
    1412           0 :                 buf.append("4 ");
    1413           0 :                 buf.append(Integer::toString(data.size()));
    1414           0 :                 buf.append(" ");
    1415           0 :                 buf.append(Integer::toString(data[0].size()));
    1416           0 :                 buf.append(" ");
    1417           0 :                 buf.append(Integer::toString(data[0][0].size()));
    1418           0 :                 buf.append(" ");
    1419           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    1420           0 :                 buf.append(" ");
    1421           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1422           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    1423           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    1424           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    1425             :         
    1426           0 :                                                 buf.append(Byte::toString(data[i][j][k][l]));
    1427             :                 
    1428           0 :                                                 buf.append(" ");
    1429             :                                         }
    1430             :                                 }
    1431             :                         }
    1432             :                 }
    1433           0 :                 buf.append(" </" + name + "> ");
    1434           0 :         }       
    1435             :         
    1436             :                 
    1437             : 
    1438             :         
    1439             :                 
    1440             :         
    1441           0 :         char Parser::getByte(const string &name, const string &tableName, const string &xmlDoc) 
    1442             :         {
    1443           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1444           0 :                 if (xmlField.length() == 0)
    1445           0 :                         throw ConversionException("Error: Missing field \"" + 
    1446           0 :                                 name + "\" or invalid syntax",tableName);
    1447             :         
    1448             :                 try {
    1449           0 :                         char data = Byte::parseByte(xmlField);
    1450           0 :                         return data;
    1451           0 :                 } catch (const NumberFormatException &e) {
    1452           0 :                         throw ConversionException("Error: Field \"" + 
    1453           0 :                                 name + "\": " + e.getMessage(), tableName);
    1454           0 :                 }
    1455             :                 
    1456           0 :         }
    1457             : 
    1458           0 :         vector<char> Parser::get1DByte(const string &name, const string &tableName, const string &xmlDoc)
    1459             :         {
    1460           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1461           0 :                 if (xmlField.length() == 0) {
    1462           0 :                         throw ConversionException("Error: Field \"" + 
    1463           0 :                                         name + "\": Invalid XML syntax", tableName);
    1464             :                 }
    1465           0 :                 StringTokenizer t(xmlField," ");
    1466             :                 try {
    1467           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1468           0 :                         if (ndim != 1) {
    1469           0 :                                 throw ConversionException("Error: Field \"" + 
    1470           0 :                                         name + "\": Invalid array format", tableName);
    1471             :                         }
    1472           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1473           0 :                         vector<char> value (dim0);
    1474           0 :                         if (dim0 == 0)
    1475           0 :                                 return value;
    1476           0 :                         for (int i = 0; i < dim0; ++i) {
    1477             :         
    1478           0 :                                 value[i] = Byte::parseByte(t.nextToken());
    1479             :         
    1480             :                         }
    1481           0 :                         if (t.hasMoreTokens()) {
    1482           0 :                                 throw ConversionException("Error: Field \"" + 
    1483           0 :                                         name + "\": Syntax error.", tableName);
    1484             :                         }
    1485           0 :                         return value;
    1486           0 :                 } catch (const NumberFormatException &e) {
    1487           0 :                         throw ConversionException("Error: Field \"" + 
    1488           0 :                                 name + "\": " + e.getMessage(), tableName);
    1489           0 :                 } catch (const OutOfBoundsException &e) {
    1490           0 :                         throw  ConversionException("Error: Field \"" + 
    1491           0 :                                 name + "\": Unexpected end of string", tableName);
    1492           0 :                 } catch (const TagFormatException &e) {
    1493           0 :                         throw ConversionException("Error: Field \"" + 
    1494           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1495           0 :                 }               
    1496           0 :         }
    1497             :                 
    1498           0 :         vector< vector<char> > Parser::get2DByte(const string &name, const string &tableName, const string &xmlDoc)
    1499             :         {
    1500           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1501           0 :                 if (xmlField.length() == 0) {
    1502           0 :                         throw ConversionException("Error: Field \"" + 
    1503           0 :                                         name + "\": Invalid XML syntax", tableName);
    1504             :                 }
    1505           0 :                 StringTokenizer t(xmlField," ");
    1506             :                 try {
    1507           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1508           0 :                         if (ndim != 2) {
    1509           0 :                                 throw ConversionException("Error: Field \"" + 
    1510           0 :                                         name + "\": Invalid array format", tableName);
    1511             :                         }
    1512           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1513           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    1514           0 :                         vector< vector<char> > value;
    1515             : 
    1516           0 :                         if (dim0 == 0 || dim1 == 0)
    1517           0 :                                 return value;
    1518             : 
    1519           0 :                         vector<char> v_aux;
    1520           0 :                         for (int i = 0; i < dim0; ++i) {
    1521           0 :                                 v_aux.clear();
    1522           0 :                                 for (int j = 0; j < dim1; ++j) {
    1523             :         
    1524           0 :                                         v_aux.push_back(Byte::parseByte(t.nextToken()));
    1525             :         
    1526             :                                 }
    1527           0 :                                 value.push_back(v_aux);
    1528             :                         }
    1529           0 :                         if (t.hasMoreTokens()) {
    1530           0 :                                 throw ConversionException("Error: Field \"" + 
    1531           0 :                                         name + "\": Syntax error.", tableName);
    1532             :                         }
    1533           0 :                         return value;
    1534           0 :                 } catch (const NumberFormatException &e) {
    1535           0 :                         throw ConversionException("Error: Field \"" + 
    1536           0 :                                 name + "\": " + e.getMessage(), tableName);
    1537           0 :                 } catch (const OutOfBoundsException &e) {
    1538           0 :                         throw  ConversionException("Error: Field \"" + 
    1539           0 :                                 name + "\": Unexpected end of string", tableName);
    1540           0 :                 } catch (const TagFormatException &e) {
    1541           0 :                         throw ConversionException("Error: Field \"" + 
    1542           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1543           0 :                 }               
    1544           0 :         }       
    1545             :         
    1546           0 :         vector< vector< vector<char> > > Parser::get3DByte(const string &name, const string &tableName, const string &xmlDoc)
    1547             :         {
    1548           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1549           0 :                 if (xmlField.length() == 0) {
    1550           0 :                         throw ConversionException("Error: Field \"" + 
    1551           0 :                                         name + "\": Invalid XML syntax", tableName);
    1552             :                 }
    1553           0 :                 StringTokenizer t(xmlField," ");
    1554             :                 try {
    1555           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1556           0 :                         if (ndim != 3) {
    1557           0 :                                 throw ConversionException("Error: Field \"" + 
    1558           0 :                                         name + "\": Invalid array format", tableName);
    1559             :                         }
    1560           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1561           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    1562           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    1563           0 :                         vector< vector< vector<char> > > value ;
    1564           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    1565           0 :                                 return value;
    1566             :                         
    1567           0 :                         vector<vector<char> > vv_aux;
    1568           0 :                         vector<char> v_aux;
    1569           0 :                         for (int i = 0; i < dim0; ++i) {
    1570           0 :                                 vv_aux.clear();
    1571           0 :                                 for (int j = 0; j < dim1; ++j) {
    1572           0 :                                         v_aux.clear();
    1573           0 :                                         for (int k = 0; k < dim2; ++k) {
    1574             :         
    1575           0 :                                                 v_aux.push_back(Byte::parseByte(t.nextToken()));
    1576             :         
    1577             :                                         }
    1578           0 :                                         vv_aux.push_back(v_aux);
    1579             :                                 }
    1580           0 :                                 value.push_back(vv_aux);
    1581             :                         }
    1582           0 :                         if (t.hasMoreTokens()) {
    1583           0 :                                 throw ConversionException("Error: Field \"" + 
    1584           0 :                                         name + "\": Syntax error.", tableName);
    1585             :                         }
    1586           0 :                         return value;
    1587           0 :                 } catch (const NumberFormatException &e) {
    1588           0 :                         throw ConversionException("Error: Field \"" + 
    1589           0 :                                 name + "\": " + e.getMessage(), tableName);
    1590           0 :                 } catch (const OutOfBoundsException &e) {
    1591           0 :                         throw  ConversionException("Error: Field \"" + 
    1592           0 :                                 name + "\": Unexpected end of string", tableName);
    1593           0 :                 } catch (const TagFormatException &e) {
    1594           0 :                         throw ConversionException("Error: Field \"" + 
    1595           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1596           0 :                 }               
    1597           0 :         }
    1598             :         
    1599           0 :         vector< vector< vector< vector<char> > > >Parser::get4DByte(const string &name, const string &tableName, const string &xmlDoc)
    1600             :         {
    1601           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1602           0 :                 if (xmlField.length() == 0) {
    1603           0 :                         throw ConversionException("Error: Field \"" + 
    1604           0 :                                         name + "\": Invalid XML syntax", tableName);
    1605             :                 }
    1606           0 :                 StringTokenizer t(xmlField," ");
    1607             :                 try {
    1608           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1609           0 :                         if (ndim != 4) {
    1610           0 :                                 throw ConversionException("Error: Field \"" + 
    1611           0 :                                         name + "\": Invalid array format", tableName);
    1612             :                         }
    1613           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1614           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    1615           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    1616           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    1617           0 :                         vector<vector< vector< vector<char> > > >value;
    1618           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    1619           0 :                                 return value;
    1620             :                         
    1621           0 :                         vector<vector<vector<char> > >vvv_aux;
    1622           0 :                         vector<vector< char> > vv_aux;
    1623           0 :                         vector<char> v_aux;
    1624           0 :                         for (int i = 0; i < dim0; ++i) {
    1625           0 :                                 vvv_aux.clear();
    1626           0 :                                 for (int j = 0; j < dim1; ++j) {
    1627           0 :                                         vv_aux.clear();
    1628           0 :                                         for (int k = 0; k < dim2; ++k) {
    1629           0 :                                                 v_aux.clear();
    1630           0 :                                                 for (int l = 0; l < dim3; l++) {
    1631             :         
    1632           0 :                                                         v_aux.push_back(Byte::parseByte(t.nextToken()));
    1633             :         
    1634             :                                                 }
    1635           0 :                                                 vv_aux.push_back(v_aux);
    1636             :                                         }
    1637           0 :                                         vvv_aux.push_back(vv_aux);
    1638             :                                 }
    1639           0 :                                 value.push_back(vvv_aux);
    1640             :                         }
    1641           0 :                         if (t.hasMoreTokens()) {
    1642           0 :                                 throw ConversionException("Error: Field \"" + 
    1643           0 :                                         name + "\": Syntax error.", tableName);
    1644             :                         }
    1645           0 :                         return value;
    1646           0 :                 } catch (const NumberFormatException &e) {
    1647           0 :                         throw ConversionException("Error: Field \"" + 
    1648           0 :                                 name + "\": " + e.getMessage(), tableName);
    1649           0 :                 } catch (const OutOfBoundsException &e) {
    1650           0 :                         throw  ConversionException("Error: Field \"" + 
    1651           0 :                                 name + "\": Unexpected end of string", tableName);
    1652           0 :                 } catch (const TagFormatException &e) {
    1653           0 :                         throw ConversionException("Error: Field \"" + 
    1654           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1655           0 :                 }               
    1656           0 :         }       
    1657             :         
    1658             : 
    1659             :                 
    1660             : 
    1661             : 
    1662             :         // Field type: float
    1663             : 
    1664          16 :         void Parser::toXML(float data, const string &name, string &buf) {
    1665          16 :                 buf.append("<" + name + "> ");
    1666             :         
    1667          16 :                 buf.append(Float::toString(data));
    1668             :                 
    1669          16 :                 buf.append(" </" + name + "> ");
    1670          16 :         }
    1671             : 
    1672             :         
    1673             :         
    1674             :         
    1675         515 :         void Parser::toXML(vector<float> data, const string &name, string &buf) {
    1676         515 :                 buf.append("<" + name + "> ");
    1677         515 :                 buf.append("1 ");
    1678         515 :                 buf.append(Integer::toString(data.size()));
    1679         515 :                 buf.append(" ");
    1680        1532 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1681             :         
    1682        1017 :                         buf.append(Float::toString(data[i]));
    1683             :                 
    1684        1017 :                         buf.append(" ");
    1685             :                 }
    1686         515 :                 buf.append(" </" + name + "> ");
    1687         515 :         }
    1688             : 
    1689           0 :         void Parser::toXML(vector< vector<float> > data, const string &name, string &buf) {
    1690           0 :                 buf.append("<" + name + "> ");
    1691           0 :                 buf.append("2 ");
    1692           0 :                 buf.append(Integer::toString(data.size()));
    1693           0 :                 buf.append(" ");
    1694           0 :                 buf.append(Integer::toString(data[0].size()));
    1695           0 :                 buf.append(" ");
    1696           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1697           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    1698             :         
    1699           0 :                                 buf.append(Float::toString(data[i][j]));
    1700             :                 
    1701           0 :                                 buf.append(" ");
    1702             :                         }
    1703             :                 }
    1704           0 :                 buf.append(" </" + name + "> ");
    1705           0 :         }
    1706             :         
    1707           0 :         void Parser::toXML(vector< vector< vector<float> > > data, const string &name, string &buf) {
    1708           0 :                 buf.append("<" + name + "> ");
    1709           0 :                 buf.append("3 ");
    1710           0 :                 buf.append(Integer::toString(data.size()));
    1711           0 :                 buf.append(" ");
    1712           0 :                 buf.append(Integer::toString(data[0].size()));
    1713           0 :                 buf.append(" ");
    1714           0 :                 buf.append(Integer::toString(data[0][0].size()));
    1715           0 :                 buf.append(" ");
    1716           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1717           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    1718           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    1719             :         
    1720           0 :                                         buf.append(Float::toString(data[i][j][k]));
    1721             :                 
    1722           0 :                                         buf.append(" ");
    1723             :                                 }
    1724             :                         }
    1725             :                 }
    1726           0 :                 buf.append(" </" + name + "> ");
    1727           0 :         }
    1728             :         
    1729           0 :         void Parser::toXML(vector<vector< vector< vector<float> > > >data, const string &name, string &buf) {
    1730           0 :                 buf.append("<" + name + "> ");
    1731           0 :                 buf.append("4 ");
    1732           0 :                 buf.append(Integer::toString(data.size()));
    1733           0 :                 buf.append(" ");
    1734           0 :                 buf.append(Integer::toString(data[0].size()));
    1735           0 :                 buf.append(" ");
    1736           0 :                 buf.append(Integer::toString(data[0][0].size()));
    1737           0 :                 buf.append(" ");
    1738           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    1739           0 :                 buf.append(" ");
    1740           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    1741           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    1742           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    1743           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    1744             :         
    1745           0 :                                                 buf.append(Float::toString(data[i][j][k][l]));
    1746             :                 
    1747           0 :                                                 buf.append(" ");
    1748             :                                         }
    1749             :                                 }
    1750             :                         }
    1751             :                 }
    1752           0 :                 buf.append(" </" + name + "> ");
    1753           0 :         }       
    1754             :         
    1755             :                 
    1756             : 
    1757             :         
    1758             :                 
    1759             :         
    1760         123 :         float Parser::getFloat(const string &name, const string &tableName, const string &xmlDoc) 
    1761             :         {
    1762         123 :                 string xmlField = Parser::getField(xmlDoc,name);
    1763         123 :                 if (xmlField.length() == 0)
    1764           0 :                         throw ConversionException("Error: Missing field \"" + 
    1765           0 :                                 name + "\" or invalid syntax",tableName);
    1766             :         
    1767             :                 try {
    1768         123 :                         float data = Float::parseFloat(xmlField);
    1769         123 :                         return data;
    1770           0 :                 } catch (const NumberFormatException &e) {
    1771           0 :                         throw ConversionException("Error: Field \"" + 
    1772           0 :                                 name + "\": " + e.getMessage(), tableName);
    1773           0 :                 }
    1774             :                 
    1775         123 :         }
    1776             : 
    1777       12846 :         vector<float> Parser::get1DFloat(const string &name, const string &tableName, const string &xmlDoc)
    1778             :         {
    1779       12846 :                 string xmlField = Parser::getField(xmlDoc,name);
    1780       12846 :                 if (xmlField.length() == 0) {
    1781           0 :                         throw ConversionException("Error: Field \"" + 
    1782           0 :                                         name + "\": Invalid XML syntax", tableName);
    1783             :                 }
    1784       25692 :                 StringTokenizer t(xmlField," ");
    1785             :                 try {
    1786       12846 :                         int ndim = Integer::parseInt(t.nextToken());
    1787       12846 :                         if (ndim != 1) {
    1788           0 :                                 throw ConversionException("Error: Field \"" + 
    1789           0 :                                         name + "\": Invalid array format", tableName);
    1790             :                         }
    1791       12846 :                         int dim0 = Integer::parseInt(t.nextToken());
    1792       12846 :                         vector<float> value (dim0);
    1793       12846 :                         if (dim0 == 0)
    1794           0 :                                 return value;
    1795       63996 :                         for (int i = 0; i < dim0; ++i) {
    1796             :         
    1797       51150 :                                 value[i] = Float::parseFloat(t.nextToken());
    1798             :         
    1799             :                         }
    1800       12846 :                         if (t.hasMoreTokens()) {
    1801           0 :                                 throw ConversionException("Error: Field \"" + 
    1802           0 :                                         name + "\": Syntax error.", tableName);
    1803             :                         }
    1804       12846 :                         return value;
    1805       12846 :                 } catch (const NumberFormatException &e) {
    1806           0 :                         throw ConversionException("Error: Field \"" + 
    1807           0 :                                 name + "\": " + e.getMessage(), tableName);
    1808           0 :                 } catch (const OutOfBoundsException &e) {
    1809           0 :                         throw  ConversionException("Error: Field \"" + 
    1810           0 :                                 name + "\": Unexpected end of string", tableName);
    1811           0 :                 } catch (const TagFormatException &e) {
    1812           0 :                         throw ConversionException("Error: Field \"" + 
    1813           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1814           0 :                 }               
    1815       12846 :         }
    1816             :                 
    1817        4320 :         vector< vector<float> > Parser::get2DFloat(const string &name, const string &tableName, const string &xmlDoc)
    1818             :         {
    1819        4320 :                 string xmlField = Parser::getField(xmlDoc,name);
    1820        4320 :                 if (xmlField.length() == 0) {
    1821           0 :                         throw ConversionException("Error: Field \"" + 
    1822           0 :                                         name + "\": Invalid XML syntax", tableName);
    1823             :                 }
    1824        8640 :                 StringTokenizer t(xmlField," ");
    1825             :                 try {
    1826        4320 :                         int ndim = Integer::parseInt(t.nextToken());
    1827        4320 :                         if (ndim != 2) {
    1828           0 :                                 throw ConversionException("Error: Field \"" + 
    1829           0 :                                         name + "\": Invalid array format", tableName);
    1830             :                         }
    1831        4320 :                         int dim0 = Integer::parseInt(t.nextToken());
    1832        4320 :                         int dim1 = Integer::parseInt(t.nextToken());
    1833        4320 :                         vector< vector<float> > value;
    1834             : 
    1835        4320 :                         if (dim0 == 0 || dim1 == 0)
    1836           0 :                                 return value;
    1837             : 
    1838        4320 :                         vector<float> v_aux;
    1839       12960 :                         for (int i = 0; i < dim0; ++i) {
    1840        8640 :                                 v_aux.clear();
    1841       17280 :                                 for (int j = 0; j < dim1; ++j) {
    1842             :         
    1843        8640 :                                         v_aux.push_back(Float::parseFloat(t.nextToken()));
    1844             :         
    1845             :                                 }
    1846        8640 :                                 value.push_back(v_aux);
    1847             :                         }
    1848        4320 :                         if (t.hasMoreTokens()) {
    1849           0 :                                 throw ConversionException("Error: Field \"" + 
    1850           0 :                                         name + "\": Syntax error.", tableName);
    1851             :                         }
    1852        4320 :                         return value;
    1853        4320 :                 } catch (const NumberFormatException &e) {
    1854           0 :                         throw ConversionException("Error: Field \"" + 
    1855           0 :                                 name + "\": " + e.getMessage(), tableName);
    1856           0 :                 } catch (const OutOfBoundsException &e) {
    1857           0 :                         throw  ConversionException("Error: Field \"" + 
    1858           0 :                                 name + "\": Unexpected end of string", tableName);
    1859           0 :                 } catch (const TagFormatException &e) {
    1860           0 :                         throw ConversionException("Error: Field \"" + 
    1861           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1862           0 :                 }               
    1863        4320 :         }       
    1864             :         
    1865           0 :         vector< vector< vector<float> > > Parser::get3DFloat(const string &name, const string &tableName, const string &xmlDoc)
    1866             :         {
    1867           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1868           0 :                 if (xmlField.length() == 0) {
    1869           0 :                         throw ConversionException("Error: Field \"" + 
    1870           0 :                                         name + "\": Invalid XML syntax", tableName);
    1871             :                 }
    1872           0 :                 StringTokenizer t(xmlField," ");
    1873             :                 try {
    1874           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1875           0 :                         if (ndim != 3) {
    1876           0 :                                 throw ConversionException("Error: Field \"" + 
    1877           0 :                                         name + "\": Invalid array format", tableName);
    1878             :                         }
    1879           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1880           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    1881           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    1882           0 :                         vector< vector< vector<float> > > value ;
    1883           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    1884           0 :                                 return value;
    1885             :                         
    1886           0 :                         vector<vector<float> > vv_aux;
    1887           0 :                         vector<float> v_aux;
    1888           0 :                         for (int i = 0; i < dim0; ++i) {
    1889           0 :                                 vv_aux.clear();
    1890           0 :                                 for (int j = 0; j < dim1; ++j) {
    1891           0 :                                         v_aux.clear();
    1892           0 :                                         for (int k = 0; k < dim2; ++k) {
    1893             :         
    1894           0 :                                                 v_aux.push_back(Float::parseFloat(t.nextToken()));
    1895             :         
    1896             :                                         }
    1897           0 :                                         vv_aux.push_back(v_aux);
    1898             :                                 }
    1899           0 :                                 value.push_back(vv_aux);
    1900             :                         }
    1901           0 :                         if (t.hasMoreTokens()) {
    1902           0 :                                 throw ConversionException("Error: Field \"" + 
    1903           0 :                                         name + "\": Syntax error.", tableName);
    1904             :                         }
    1905           0 :                         return value;
    1906           0 :                 } catch (const NumberFormatException &e) {
    1907           0 :                         throw ConversionException("Error: Field \"" + 
    1908           0 :                                 name + "\": " + e.getMessage(), tableName);
    1909           0 :                 } catch (const OutOfBoundsException &e) {
    1910           0 :                         throw  ConversionException("Error: Field \"" + 
    1911           0 :                                 name + "\": Unexpected end of string", tableName);
    1912           0 :                 } catch (const TagFormatException &e) {
    1913           0 :                         throw ConversionException("Error: Field \"" + 
    1914           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1915           0 :                 }               
    1916           0 :         }
    1917             :         
    1918           0 :         vector< vector< vector< vector<float> > > >Parser::get4DFloat(const string &name, const string &tableName, const string &xmlDoc)
    1919             :         {
    1920           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    1921           0 :                 if (xmlField.length() == 0) {
    1922           0 :                         throw ConversionException("Error: Field \"" + 
    1923           0 :                                         name + "\": Invalid XML syntax", tableName);
    1924             :                 }
    1925           0 :                 StringTokenizer t(xmlField," ");
    1926             :                 try {
    1927           0 :                         int ndim = Integer::parseInt(t.nextToken());
    1928           0 :                         if (ndim != 4) {
    1929           0 :                                 throw ConversionException("Error: Field \"" + 
    1930           0 :                                         name + "\": Invalid array format", tableName);
    1931             :                         }
    1932           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    1933           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    1934           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    1935           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    1936           0 :                         vector<vector< vector< vector<float> > > >value;
    1937           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    1938           0 :                                 return value;
    1939             :                         
    1940           0 :                         vector<vector<vector<float> > >vvv_aux;
    1941           0 :                         vector<vector< float> > vv_aux;
    1942           0 :                         vector<float> v_aux;
    1943           0 :                         for (int i = 0; i < dim0; ++i) {
    1944           0 :                                 vvv_aux.clear();
    1945           0 :                                 for (int j = 0; j < dim1; ++j) {
    1946           0 :                                         vv_aux.clear();
    1947           0 :                                         for (int k = 0; k < dim2; ++k) {
    1948           0 :                                                 v_aux.clear();
    1949           0 :                                                 for (int l = 0; l < dim3; l++) {
    1950             :         
    1951           0 :                                                         v_aux.push_back(Float::parseFloat(t.nextToken()));
    1952             :         
    1953             :                                                 }
    1954           0 :                                                 vv_aux.push_back(v_aux);
    1955             :                                         }
    1956           0 :                                         vvv_aux.push_back(vv_aux);
    1957             :                                 }
    1958           0 :                                 value.push_back(vvv_aux);
    1959             :                         }
    1960           0 :                         if (t.hasMoreTokens()) {
    1961           0 :                                 throw ConversionException("Error: Field \"" + 
    1962           0 :                                         name + "\": Syntax error.", tableName);
    1963             :                         }
    1964           0 :                         return value;
    1965           0 :                 } catch (const NumberFormatException &e) {
    1966           0 :                         throw ConversionException("Error: Field \"" + 
    1967           0 :                                 name + "\": " + e.getMessage(), tableName);
    1968           0 :                 } catch (const OutOfBoundsException &e) {
    1969           0 :                         throw  ConversionException("Error: Field \"" + 
    1970           0 :                                 name + "\": Unexpected end of string", tableName);
    1971           0 :                 } catch (const TagFormatException &e) {
    1972           0 :                         throw ConversionException("Error: Field \"" + 
    1973           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    1974           0 :                 }               
    1975           0 :         }       
    1976             :         
    1977             : 
    1978             :                 
    1979             : 
    1980             : 
    1981             :         // Field type: double
    1982             : 
    1983         231 :         void Parser::toXML(double data, const string &name, string &buf) {
    1984         231 :                 buf.append("<" + name + "> ");
    1985             :         
    1986         231 :                 buf.append(Double::toString(data));
    1987             :                 
    1988         231 :                 buf.append(" </" + name + "> ");
    1989         231 :         }
    1990             : 
    1991             :         
    1992             :         
    1993             :         
    1994           0 :         void Parser::toXML(vector<double> data, const string &name, string &buf) {
    1995           0 :                 buf.append("<" + name + "> ");
    1996           0 :                 buf.append("1 ");
    1997           0 :                 buf.append(Integer::toString(data.size()));
    1998           0 :                 buf.append(" ");
    1999           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2000             :         
    2001           0 :                         buf.append(Double::toString(data[i]));
    2002             :                 
    2003           0 :                         buf.append(" ");
    2004             :                 }
    2005           0 :                 buf.append(" </" + name + "> ");
    2006           0 :         }
    2007             : 
    2008         896 :         void Parser::toXML(vector< vector<double> > data, const string &name, string &buf) {
    2009         896 :                 buf.append("<" + name + "> ");
    2010         896 :                 buf.append("2 ");
    2011         896 :                 buf.append(Integer::toString(data.size()));
    2012         896 :                 buf.append(" ");
    2013         896 :                 buf.append(Integer::toString(data[0].size()));
    2014         896 :                 buf.append(" ");
    2015        2688 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2016        5376 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2017             :         
    2018        3584 :                                 buf.append(Double::toString(data[i][j]));
    2019             :                 
    2020        3584 :                                 buf.append(" ");
    2021             :                         }
    2022             :                 }
    2023         896 :                 buf.append(" </" + name + "> ");
    2024         896 :         }
    2025             :         
    2026           0 :         void Parser::toXML(vector< vector< vector<double> > > data, const string &name, string &buf) {
    2027           0 :                 buf.append("<" + name + "> ");
    2028           0 :                 buf.append("3 ");
    2029           0 :                 buf.append(Integer::toString(data.size()));
    2030           0 :                 buf.append(" ");
    2031           0 :                 buf.append(Integer::toString(data[0].size()));
    2032           0 :                 buf.append(" ");
    2033           0 :                 buf.append(Integer::toString(data[0][0].size()));
    2034           0 :                 buf.append(" ");
    2035           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2036           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2037           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    2038             :         
    2039           0 :                                         buf.append(Double::toString(data[i][j][k]));
    2040             :                 
    2041           0 :                                         buf.append(" ");
    2042             :                                 }
    2043             :                         }
    2044             :                 }
    2045           0 :                 buf.append(" </" + name + "> ");
    2046           0 :         }
    2047             :         
    2048           0 :         void Parser::toXML(vector<vector< vector< vector<double> > > >data, const string &name, string &buf) {
    2049           0 :                 buf.append("<" + name + "> ");
    2050           0 :                 buf.append("4 ");
    2051           0 :                 buf.append(Integer::toString(data.size()));
    2052           0 :                 buf.append(" ");
    2053           0 :                 buf.append(Integer::toString(data[0].size()));
    2054           0 :                 buf.append(" ");
    2055           0 :                 buf.append(Integer::toString(data[0][0].size()));
    2056           0 :                 buf.append(" ");
    2057           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    2058           0 :                 buf.append(" ");
    2059           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2060           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2061           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    2062           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    2063             :         
    2064           0 :                                                 buf.append(Double::toString(data[i][j][k][l]));
    2065             :                 
    2066           0 :                                                 buf.append(" ");
    2067             :                                         }
    2068             :                                 }
    2069             :                         }
    2070             :                 }
    2071           0 :                 buf.append(" </" + name + "> ");
    2072           0 :         }       
    2073             :         
    2074             :                 
    2075             : 
    2076             :         
    2077             :                 
    2078             :         
    2079        1444 :         double Parser::getDouble(const string &name, const string &tableName, const string &xmlDoc) 
    2080             :         {
    2081        1444 :                 string xmlField = Parser::getField(xmlDoc,name);
    2082        1444 :                 if (xmlField.length() == 0)
    2083           0 :                         throw ConversionException("Error: Missing field \"" + 
    2084           0 :                                 name + "\" or invalid syntax",tableName);
    2085             :         
    2086             :                 try {
    2087        1444 :                         double data = Double::parseDouble(xmlField);
    2088        1444 :                         return data;
    2089           0 :                 } catch (const NumberFormatException &e) {
    2090           0 :                         throw ConversionException("Error: Field \"" + 
    2091           0 :                                 name + "\": " + e.getMessage(), tableName);
    2092           0 :                 }
    2093             :                 
    2094        1444 :         }
    2095             : 
    2096        5682 :         vector<double> Parser::get1DDouble(const string &name, const string &tableName, const string &xmlDoc)
    2097             :         {
    2098        5682 :                 string xmlField = Parser::getField(xmlDoc,name);
    2099        5682 :                 if (xmlField.length() == 0) {
    2100           0 :                         throw ConversionException("Error: Field \"" + 
    2101           0 :                                         name + "\": Invalid XML syntax", tableName);
    2102             :                 }
    2103       11364 :                 StringTokenizer t(xmlField," ");
    2104             :                 try {
    2105        5682 :                         int ndim = Integer::parseInt(t.nextToken());
    2106        5682 :                         if (ndim != 1) {
    2107           0 :                                 throw ConversionException("Error: Field \"" + 
    2108           0 :                                         name + "\": Invalid array format", tableName);
    2109             :                         }
    2110        5682 :                         int dim0 = Integer::parseInt(t.nextToken());
    2111        5682 :                         vector<double> value (dim0);
    2112        5682 :                         if (dim0 == 0)
    2113           0 :                                 return value;
    2114       12312 :                         for (int i = 0; i < dim0; ++i) {
    2115             :         
    2116        6630 :                                 value[i] = Double::parseDouble(t.nextToken());
    2117             :         
    2118             :                         }
    2119        5682 :                         if (t.hasMoreTokens()) {
    2120           0 :                                 throw ConversionException("Error: Field \"" + 
    2121           0 :                                         name + "\": Syntax error.", tableName);
    2122             :                         }
    2123        5682 :                         return value;
    2124        5682 :                 } catch (const NumberFormatException &e) {
    2125           0 :                         throw ConversionException("Error: Field \"" + 
    2126           0 :                                 name + "\": " + e.getMessage(), tableName);
    2127           0 :                 } catch (const OutOfBoundsException &e) {
    2128           0 :                         throw  ConversionException("Error: Field \"" + 
    2129           0 :                                 name + "\": Unexpected end of string", tableName);
    2130           0 :                 } catch (const TagFormatException &e) {
    2131           0 :                         throw ConversionException("Error: Field \"" + 
    2132           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2133           0 :                 }               
    2134        5682 :         }
    2135             :                 
    2136       67745 :         vector< vector<double> > Parser::get2DDouble(const string &name, const string &tableName, const string &xmlDoc)
    2137             :         {
    2138       67745 :                 string xmlField = Parser::getField(xmlDoc,name);
    2139       67745 :                 if (xmlField.length() == 0) {
    2140           0 :                         throw ConversionException("Error: Field \"" + 
    2141           0 :                                         name + "\": Invalid XML syntax", tableName);
    2142             :                 }
    2143      135490 :                 StringTokenizer t(xmlField," ");
    2144             :                 try {
    2145       67745 :                         int ndim = Integer::parseInt(t.nextToken());
    2146       67745 :                         if (ndim != 2) {
    2147           0 :                                 throw ConversionException("Error: Field \"" + 
    2148           0 :                                         name + "\": Invalid array format", tableName);
    2149             :                         }
    2150       67745 :                         int dim0 = Integer::parseInt(t.nextToken());
    2151       67745 :                         int dim1 = Integer::parseInt(t.nextToken());
    2152       67745 :                         vector< vector<double> > value;
    2153             : 
    2154       67745 :                         if (dim0 == 0 || dim1 == 0)
    2155           0 :                                 return value;
    2156             : 
    2157       67745 :                         vector<double> v_aux;
    2158      202802 :                         for (int i = 0; i < dim0; ++i) {
    2159      135057 :                                 v_aux.clear();
    2160      405179 :                                 for (int j = 0; j < dim1; ++j) {
    2161             :         
    2162      270122 :                                         v_aux.push_back(Double::parseDouble(t.nextToken()));
    2163             :         
    2164             :                                 }
    2165      135057 :                                 value.push_back(v_aux);
    2166             :                         }
    2167       67745 :                         if (t.hasMoreTokens()) {
    2168           0 :                                 throw ConversionException("Error: Field \"" + 
    2169           0 :                                         name + "\": Syntax error.", tableName);
    2170             :                         }
    2171       67745 :                         return value;
    2172       67745 :                 } catch (const NumberFormatException &e) {
    2173           0 :                         throw ConversionException("Error: Field \"" + 
    2174           0 :                                 name + "\": " + e.getMessage(), tableName);
    2175           0 :                 } catch (const OutOfBoundsException &e) {
    2176           0 :                         throw  ConversionException("Error: Field \"" + 
    2177           0 :                                 name + "\": Unexpected end of string", tableName);
    2178           0 :                 } catch (const TagFormatException &e) {
    2179           0 :                         throw ConversionException("Error: Field \"" + 
    2180           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2181           0 :                 }               
    2182       67745 :         }       
    2183             :         
    2184           0 :         vector< vector< vector<double> > > Parser::get3DDouble(const string &name, const string &tableName, const string &xmlDoc)
    2185             :         {
    2186           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    2187           0 :                 if (xmlField.length() == 0) {
    2188           0 :                         throw ConversionException("Error: Field \"" + 
    2189           0 :                                         name + "\": Invalid XML syntax", tableName);
    2190             :                 }
    2191           0 :                 StringTokenizer t(xmlField," ");
    2192             :                 try {
    2193           0 :                         int ndim = Integer::parseInt(t.nextToken());
    2194           0 :                         if (ndim != 3) {
    2195           0 :                                 throw ConversionException("Error: Field \"" + 
    2196           0 :                                         name + "\": Invalid array format", tableName);
    2197             :                         }
    2198           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    2199           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    2200           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    2201           0 :                         vector< vector< vector<double> > > value ;
    2202           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    2203           0 :                                 return value;
    2204             :                         
    2205           0 :                         vector<vector<double> > vv_aux;
    2206           0 :                         vector<double> v_aux;
    2207           0 :                         for (int i = 0; i < dim0; ++i) {
    2208           0 :                                 vv_aux.clear();
    2209           0 :                                 for (int j = 0; j < dim1; ++j) {
    2210           0 :                                         v_aux.clear();
    2211           0 :                                         for (int k = 0; k < dim2; ++k) {
    2212             :         
    2213           0 :                                                 v_aux.push_back(Double::parseDouble(t.nextToken()));
    2214             :         
    2215             :                                         }
    2216           0 :                                         vv_aux.push_back(v_aux);
    2217             :                                 }
    2218           0 :                                 value.push_back(vv_aux);
    2219             :                         }
    2220           0 :                         if (t.hasMoreTokens()) {
    2221           0 :                                 throw ConversionException("Error: Field \"" + 
    2222           0 :                                         name + "\": Syntax error.", tableName);
    2223             :                         }
    2224           0 :                         return value;
    2225           0 :                 } catch (const NumberFormatException &e) {
    2226           0 :                         throw ConversionException("Error: Field \"" + 
    2227           0 :                                 name + "\": " + e.getMessage(), tableName);
    2228           0 :                 } catch (const OutOfBoundsException &e) {
    2229           0 :                         throw  ConversionException("Error: Field \"" + 
    2230           0 :                                 name + "\": Unexpected end of string", tableName);
    2231           0 :                 } catch (const TagFormatException &e) {
    2232           0 :                         throw ConversionException("Error: Field \"" + 
    2233           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2234           0 :                 }               
    2235           0 :         }
    2236             :         
    2237           0 :         vector< vector< vector< vector<double> > > >Parser::get4DDouble(const string &name, const string &tableName, const string &xmlDoc)
    2238             :         {
    2239           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    2240           0 :                 if (xmlField.length() == 0) {
    2241           0 :                         throw ConversionException("Error: Field \"" + 
    2242           0 :                                         name + "\": Invalid XML syntax", tableName);
    2243             :                 }
    2244           0 :                 StringTokenizer t(xmlField," ");
    2245             :                 try {
    2246           0 :                         int ndim = Integer::parseInt(t.nextToken());
    2247           0 :                         if (ndim != 4) {
    2248           0 :                                 throw ConversionException("Error: Field \"" + 
    2249           0 :                                         name + "\": Invalid array format", tableName);
    2250             :                         }
    2251           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    2252           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    2253           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    2254           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    2255           0 :                         vector<vector< vector< vector<double> > > >value;
    2256           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    2257           0 :                                 return value;
    2258             :                         
    2259           0 :                         vector<vector<vector<double> > >vvv_aux;
    2260           0 :                         vector<vector< double> > vv_aux;
    2261           0 :                         vector<double> v_aux;
    2262           0 :                         for (int i = 0; i < dim0; ++i) {
    2263           0 :                                 vvv_aux.clear();
    2264           0 :                                 for (int j = 0; j < dim1; ++j) {
    2265           0 :                                         vv_aux.clear();
    2266           0 :                                         for (int k = 0; k < dim2; ++k) {
    2267           0 :                                                 v_aux.clear();
    2268           0 :                                                 for (int l = 0; l < dim3; l++) {
    2269             :         
    2270           0 :                                                         v_aux.push_back(Double::parseDouble(t.nextToken()));
    2271             :         
    2272             :                                                 }
    2273           0 :                                                 vv_aux.push_back(v_aux);
    2274             :                                         }
    2275           0 :                                         vvv_aux.push_back(vv_aux);
    2276             :                                 }
    2277           0 :                                 value.push_back(vvv_aux);
    2278             :                         }
    2279           0 :                         if (t.hasMoreTokens()) {
    2280           0 :                                 throw ConversionException("Error: Field \"" + 
    2281           0 :                                         name + "\": Syntax error.", tableName);
    2282             :                         }
    2283           0 :                         return value;
    2284           0 :                 } catch (const NumberFormatException &e) {
    2285           0 :                         throw ConversionException("Error: Field \"" + 
    2286           0 :                                 name + "\": " + e.getMessage(), tableName);
    2287           0 :                 } catch (const OutOfBoundsException &e) {
    2288           0 :                         throw  ConversionException("Error: Field \"" + 
    2289           0 :                                 name + "\": Unexpected end of string", tableName);
    2290           0 :                 } catch (const TagFormatException &e) {
    2291           0 :                         throw ConversionException("Error: Field \"" + 
    2292           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2293           0 :                 }               
    2294           0 :         }       
    2295             :         
    2296             : 
    2297             :                 
    2298             : 
    2299             : 
    2300             :         // Field type: unsigned char
    2301             : 
    2302           0 :         void Parser::toXML(unsigned char data, const string &name, string &buf) {
    2303           0 :                 buf.append("<" + name + "> ");
    2304             :         
    2305           0 :                 buf.append(Character::toString(data));
    2306             :                 
    2307           0 :                 buf.append(" </" + name + "> ");
    2308           0 :         }
    2309             : 
    2310             :         
    2311             :         
    2312             :         
    2313           0 :         void Parser::toXML(vector<unsigned char> data, const string &name, string &buf) {
    2314           0 :                 buf.append("<" + name + "> ");
    2315           0 :                 buf.append("1 ");
    2316           0 :                 buf.append(Integer::toString(data.size()));
    2317           0 :                 buf.append(" ");
    2318           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2319             :         
    2320           0 :                         buf.append(Character::toString(data[i]));
    2321             :                 
    2322           0 :                         buf.append(" ");
    2323             :                 }
    2324           0 :                 buf.append(" </" + name + "> ");
    2325           0 :         }
    2326             : 
    2327           0 :         void Parser::toXML(vector< vector<unsigned char> > data, const string &name, string &buf) {
    2328           0 :                 buf.append("<" + name + "> ");
    2329           0 :                 buf.append("2 ");
    2330           0 :                 buf.append(Integer::toString(data.size()));
    2331           0 :                 buf.append(" ");
    2332           0 :                 buf.append(Integer::toString(data[0].size()));
    2333           0 :                 buf.append(" ");
    2334           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2335           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2336             :         
    2337           0 :                                 buf.append(Character::toString(data[i][j]));
    2338             :                 
    2339           0 :                                 buf.append(" ");
    2340             :                         }
    2341             :                 }
    2342           0 :                 buf.append(" </" + name + "> ");
    2343           0 :         }
    2344             :         
    2345           0 :         void Parser::toXML(vector< vector< vector<unsigned char> > > data, const string &name, string &buf) {
    2346           0 :                 buf.append("<" + name + "> ");
    2347           0 :                 buf.append("3 ");
    2348           0 :                 buf.append(Integer::toString(data.size()));
    2349           0 :                 buf.append(" ");
    2350           0 :                 buf.append(Integer::toString(data[0].size()));
    2351           0 :                 buf.append(" ");
    2352           0 :                 buf.append(Integer::toString(data[0][0].size()));
    2353           0 :                 buf.append(" ");
    2354           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2355           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2356           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    2357             :         
    2358           0 :                                         buf.append(Character::toString(data[i][j][k]));
    2359             :                 
    2360           0 :                                         buf.append(" ");
    2361             :                                 }
    2362             :                         }
    2363             :                 }
    2364           0 :                 buf.append(" </" + name + "> ");
    2365           0 :         }
    2366             :         
    2367           0 :         void Parser::toXML(vector<vector< vector< vector<unsigned char> > > >data, const string &name, string &buf) {
    2368           0 :                 buf.append("<" + name + "> ");
    2369           0 :                 buf.append("4 ");
    2370           0 :                 buf.append(Integer::toString(data.size()));
    2371           0 :                 buf.append(" ");
    2372           0 :                 buf.append(Integer::toString(data[0].size()));
    2373           0 :                 buf.append(" ");
    2374           0 :                 buf.append(Integer::toString(data[0][0].size()));
    2375           0 :                 buf.append(" ");
    2376           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    2377           0 :                 buf.append(" ");
    2378           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2379           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2380           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    2381           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    2382             :         
    2383           0 :                                                 buf.append(Character::toString(data[i][j][k][l]));
    2384             :                 
    2385           0 :                                                 buf.append(" ");
    2386             :                                         }
    2387             :                                 }
    2388             :                         }
    2389             :                 }
    2390           0 :                 buf.append(" </" + name + "> ");
    2391           0 :         }       
    2392             :         
    2393             :                 
    2394             : 
    2395             :         
    2396             :                 
    2397             :         
    2398           0 :         unsigned char Parser::getCharacter(const string &name, const string &tableName, const string &xmlDoc) 
    2399             :         {
    2400           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    2401           0 :                 if (xmlField.length() == 0)
    2402           0 :                         throw ConversionException("Error: Missing field \"" + 
    2403           0 :                                 name + "\" or invalid syntax",tableName);
    2404             :         
    2405           0 :                 return xmlField.at(0);
    2406             :                 
    2407           0 :         }
    2408             : 
    2409           0 :         vector<unsigned char> Parser::get1DCharacter(const string &name, const string &tableName, const string &xmlDoc)
    2410             :         {
    2411           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    2412           0 :                 if (xmlField.length() == 0) {
    2413           0 :                         throw ConversionException("Error: Field \"" + 
    2414           0 :                                         name + "\": Invalid XML syntax", tableName);
    2415             :                 }
    2416           0 :                 StringTokenizer t(xmlField," ");
    2417             :                 try {
    2418           0 :                         int ndim = Integer::parseInt(t.nextToken());
    2419           0 :                         if (ndim != 1) {
    2420           0 :                                 throw ConversionException("Error: Field \"" + 
    2421           0 :                                         name + "\": Invalid array format", tableName);
    2422             :                         }
    2423           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    2424           0 :                         vector<unsigned char> value (dim0);
    2425           0 :                         if (dim0 == 0)
    2426           0 :                                 return value;
    2427           0 :                         for (int i = 0; i < dim0; ++i) {
    2428             :         
    2429           0 :                                 value[i] = t.nextToken().at(0);
    2430             :         
    2431             :                         }
    2432           0 :                         if (t.hasMoreTokens()) {
    2433           0 :                                 throw ConversionException("Error: Field \"" + 
    2434           0 :                                         name + "\": Syntax error.", tableName);
    2435             :                         }
    2436           0 :                         return value;
    2437           0 :                 } catch (const NumberFormatException &e) {
    2438           0 :                         throw ConversionException("Error: Field \"" + 
    2439           0 :                                 name + "\": " + e.getMessage(), tableName);
    2440           0 :                 } catch (const OutOfBoundsException &e) {
    2441           0 :                         throw  ConversionException("Error: Field \"" + 
    2442           0 :                                 name + "\": Unexpected end of string", tableName);
    2443           0 :                 } catch (const TagFormatException &e) {
    2444           0 :                         throw ConversionException("Error: Field \"" + 
    2445           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2446           0 :                 }               
    2447           0 :         }
    2448             :                 
    2449           0 :         vector< vector<unsigned char> > Parser::get2DCharacter(const string &name, const string &tableName, const string &xmlDoc)
    2450             :         {
    2451           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    2452           0 :                 if (xmlField.length() == 0) {
    2453           0 :                         throw ConversionException("Error: Field \"" + 
    2454           0 :                                         name + "\": Invalid XML syntax", tableName);
    2455             :                 }
    2456           0 :                 StringTokenizer t(xmlField," ");
    2457             :                 try {
    2458           0 :                         int ndim = Integer::parseInt(t.nextToken());
    2459           0 :                         if (ndim != 2) {
    2460           0 :                                 throw ConversionException("Error: Field \"" + 
    2461           0 :                                         name + "\": Invalid array format", tableName);
    2462             :                         }
    2463           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    2464           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    2465           0 :                         vector< vector<unsigned char> > value;
    2466             : 
    2467           0 :                         if (dim0 == 0 || dim1 == 0)
    2468           0 :                                 return value;
    2469             : 
    2470           0 :                         vector<unsigned char> v_aux;
    2471           0 :                         for (int i = 0; i < dim0; ++i) {
    2472           0 :                                 v_aux.clear();
    2473           0 :                                 for (int j = 0; j < dim1; ++j) {
    2474             :         
    2475           0 :                                         v_aux.push_back(t.nextToken().at(0));
    2476             :         
    2477             :                                 }
    2478           0 :                                 value.push_back(v_aux);
    2479             :                         }
    2480           0 :                         if (t.hasMoreTokens()) {
    2481           0 :                                 throw ConversionException("Error: Field \"" + 
    2482           0 :                                         name + "\": Syntax error.", tableName);
    2483             :                         }
    2484           0 :                         return value;
    2485           0 :                 } catch (const NumberFormatException &e) {
    2486           0 :                         throw ConversionException("Error: Field \"" + 
    2487           0 :                                 name + "\": " + e.getMessage(), tableName);
    2488           0 :                 } catch (const OutOfBoundsException &e) {
    2489           0 :                         throw  ConversionException("Error: Field \"" + 
    2490           0 :                                 name + "\": Unexpected end of string", tableName);
    2491           0 :                 } catch (const TagFormatException &e) {
    2492           0 :                         throw ConversionException("Error: Field \"" + 
    2493           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2494           0 :                 }               
    2495           0 :         }       
    2496             :         
    2497           0 :         vector< vector< vector<unsigned char> > > Parser::get3DCharacter(const string &name, const string &tableName, const string &xmlDoc)
    2498             :         {
    2499           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    2500           0 :                 if (xmlField.length() == 0) {
    2501           0 :                         throw ConversionException("Error: Field \"" + 
    2502           0 :                                         name + "\": Invalid XML syntax", tableName);
    2503             :                 }
    2504           0 :                 StringTokenizer t(xmlField," ");
    2505             :                 try {
    2506           0 :                         int ndim = Integer::parseInt(t.nextToken());
    2507           0 :                         if (ndim != 3) {
    2508           0 :                                 throw ConversionException("Error: Field \"" + 
    2509           0 :                                         name + "\": Invalid array format", tableName);
    2510             :                         }
    2511           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    2512           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    2513           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    2514           0 :                         vector< vector< vector<unsigned char> > > value ;
    2515           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    2516           0 :                                 return value;
    2517             :                         
    2518           0 :                         vector<vector<unsigned char> > vv_aux;
    2519           0 :                         vector<unsigned char> v_aux;
    2520           0 :                         for (int i = 0; i < dim0; ++i) {
    2521           0 :                                 vv_aux.clear();
    2522           0 :                                 for (int j = 0; j < dim1; ++j) {
    2523           0 :                                         v_aux.clear();
    2524           0 :                                         for (int k = 0; k < dim2; ++k) {
    2525             :         
    2526           0 :                                                 v_aux.push_back( t.nextToken().at(0));
    2527             :         
    2528             :                                         }
    2529           0 :                                         vv_aux.push_back(v_aux);
    2530             :                                 }
    2531           0 :                                 value.push_back(vv_aux);
    2532             :                         }
    2533           0 :                         if (t.hasMoreTokens()) {
    2534           0 :                                 throw ConversionException("Error: Field \"" + 
    2535           0 :                                         name + "\": Syntax error.", tableName);
    2536             :                         }
    2537           0 :                         return value;
    2538           0 :                 } catch (const NumberFormatException &e) {
    2539           0 :                         throw ConversionException("Error: Field \"" + 
    2540           0 :                                 name + "\": " + e.getMessage(), tableName);
    2541           0 :                 } catch (const OutOfBoundsException &e) {
    2542           0 :                         throw  ConversionException("Error: Field \"" + 
    2543           0 :                                 name + "\": Unexpected end of string", tableName);
    2544           0 :                 } catch (const TagFormatException &e) {
    2545           0 :                         throw ConversionException("Error: Field \"" + 
    2546           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2547           0 :                 }               
    2548           0 :         }
    2549             :         
    2550           0 :         vector< vector< vector< vector<unsigned char> > > >Parser::get4DCharacter(const string &name, const string &tableName, const string &xmlDoc)
    2551             :         {
    2552           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    2553           0 :                 if (xmlField.length() == 0) {
    2554           0 :                         throw ConversionException("Error: Field \"" + 
    2555           0 :                                         name + "\": Invalid XML syntax", tableName);
    2556             :                 }
    2557           0 :                 StringTokenizer t(xmlField," ");
    2558             :                 try {
    2559           0 :                         int ndim = Integer::parseInt(t.nextToken());
    2560           0 :                         if (ndim != 4) {
    2561           0 :                                 throw ConversionException("Error: Field \"" + 
    2562           0 :                                         name + "\": Invalid array format", tableName);
    2563             :                         }
    2564           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    2565           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    2566           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    2567           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    2568           0 :                         vector<vector< vector< vector<unsigned char> > > >value;
    2569           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    2570           0 :                                 return value;
    2571             :                         
    2572           0 :                         vector<vector<vector<unsigned char> > >vvv_aux;
    2573           0 :                         vector<vector< unsigned char> > vv_aux;
    2574           0 :                         vector<unsigned char> v_aux;
    2575           0 :                         for (int i = 0; i < dim0; ++i) {
    2576           0 :                                 vvv_aux.clear();
    2577           0 :                                 for (int j = 0; j < dim1; ++j) {
    2578           0 :                                         vv_aux.clear();
    2579           0 :                                         for (int k = 0; k < dim2; ++k) {
    2580           0 :                                                 v_aux.clear();
    2581           0 :                                                 for (int l = 0; l < dim3; l++) {
    2582             :         
    2583           0 :                                                         v_aux.push_back( t.nextToken().at(0));
    2584             :         
    2585             :                                                 }
    2586           0 :                                                 vv_aux.push_back(v_aux);
    2587             :                                         }
    2588           0 :                                         vvv_aux.push_back(vv_aux);
    2589             :                                 }
    2590           0 :                                 value.push_back(vvv_aux);
    2591             :                         }
    2592           0 :                         if (t.hasMoreTokens()) {
    2593           0 :                                 throw ConversionException("Error: Field \"" + 
    2594           0 :                                         name + "\": Syntax error.", tableName);
    2595             :                         }
    2596           0 :                         return value;
    2597           0 :                 } catch (const NumberFormatException &e) {
    2598           0 :                         throw ConversionException("Error: Field \"" + 
    2599           0 :                                 name + "\": " + e.getMessage(), tableName);
    2600           0 :                 } catch (const OutOfBoundsException &e) {
    2601           0 :                         throw  ConversionException("Error: Field \"" + 
    2602           0 :                                 name + "\": Unexpected end of string", tableName);
    2603           0 :                 } catch (const TagFormatException &e) {
    2604           0 :                         throw ConversionException("Error: Field \"" + 
    2605           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2606           0 :                 }               
    2607           0 :         }       
    2608             :         
    2609             : 
    2610             :                 
    2611             : 
    2612             : 
    2613             :         // Field type: bool
    2614             : 
    2615         382 :         void Parser::toXML(bool data, const string &name, string &buf) {
    2616         382 :                 buf.append("<" + name + "> ");
    2617             :         
    2618         382 :                 buf.append(Boolean::toString(data));
    2619             :                 
    2620         382 :                 buf.append(" </" + name + "> ");
    2621         382 :         }
    2622             : 
    2623             :         
    2624             :         
    2625             :         
    2626         334 :         void Parser::toXML(vector<bool> data, const string &name, string &buf) {
    2627         334 :                 buf.append("<" + name + "> ");
    2628         334 :                 buf.append("1 ");
    2629         334 :                 buf.append(Integer::toString(data.size()));
    2630         334 :                 buf.append(" ");
    2631         668 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2632             :         
    2633         334 :                         buf.append(Boolean::toString(data[i]));
    2634             :                 
    2635         334 :                         buf.append(" ");
    2636             :                 }
    2637         334 :                 buf.append(" </" + name + "> ");
    2638         334 :         }
    2639             : 
    2640           0 :         void Parser::toXML(vector< vector<bool> > data, const string &name, string &buf) {
    2641           0 :                 buf.append("<" + name + "> ");
    2642           0 :                 buf.append("2 ");
    2643           0 :                 buf.append(Integer::toString(data.size()));
    2644           0 :                 buf.append(" ");
    2645           0 :                 buf.append(Integer::toString(data[0].size()));
    2646           0 :                 buf.append(" ");
    2647           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2648           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2649             :         
    2650           0 :                                 buf.append(Boolean::toString(data[i][j]));
    2651             :                 
    2652           0 :                                 buf.append(" ");
    2653             :                         }
    2654             :                 }
    2655           0 :                 buf.append(" </" + name + "> ");
    2656           0 :         }
    2657             :         
    2658           0 :         void Parser::toXML(vector< vector< vector<bool> > > data, const string &name, string &buf) {
    2659           0 :                 buf.append("<" + name + "> ");
    2660           0 :                 buf.append("3 ");
    2661           0 :                 buf.append(Integer::toString(data.size()));
    2662           0 :                 buf.append(" ");
    2663           0 :                 buf.append(Integer::toString(data[0].size()));
    2664           0 :                 buf.append(" ");
    2665           0 :                 buf.append(Integer::toString(data[0][0].size()));
    2666           0 :                 buf.append(" ");
    2667           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2668           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2669           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    2670             :         
    2671           0 :                                         buf.append(Boolean::toString(data[i][j][k]));
    2672             :                 
    2673           0 :                                         buf.append(" ");
    2674             :                                 }
    2675             :                         }
    2676             :                 }
    2677           0 :                 buf.append(" </" + name + "> ");
    2678           0 :         }
    2679             :         
    2680           0 :         void Parser::toXML(vector<vector< vector< vector<bool> > > >data, const string &name, string &buf) {
    2681           0 :                 buf.append("<" + name + "> ");
    2682           0 :                 buf.append("4 ");
    2683           0 :                 buf.append(Integer::toString(data.size()));
    2684           0 :                 buf.append(" ");
    2685           0 :                 buf.append(Integer::toString(data[0].size()));
    2686           0 :                 buf.append(" ");
    2687           0 :                 buf.append(Integer::toString(data[0][0].size()));
    2688           0 :                 buf.append(" ");
    2689           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    2690           0 :                 buf.append(" ");
    2691           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2692           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2693           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    2694           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    2695             :         
    2696           0 :                                                 buf.append(Boolean::toString(data[i][j][k][l]));
    2697             :                 
    2698           0 :                                                 buf.append(" ");
    2699             :                                         }
    2700             :                                 }
    2701             :                         }
    2702             :                 }
    2703           0 :                 buf.append(" </" + name + "> ");
    2704           0 :         }       
    2705             :         
    2706             :                 
    2707             : 
    2708             :         
    2709             :                 
    2710             :         
    2711       47447 :         bool Parser::getBoolean(const string &name, const string &tableName, const string &xmlDoc) 
    2712             :         {
    2713       47447 :                 string xmlField = Parser::getField(xmlDoc,name);
    2714       47447 :                 if (xmlField.length() == 0)
    2715           0 :                         throw ConversionException("Error: Missing field \"" + 
    2716           0 :                                 name + "\" or invalid syntax",tableName);
    2717             :         
    2718             :                 try {
    2719       47447 :                         bool data = Boolean::parseBoolean(xmlField);
    2720       47447 :                         return data;
    2721           0 :                 } catch (const NumberFormatException &e) {
    2722           0 :                         throw ConversionException("Error: Field \"" + 
    2723           0 :                                 name + "\": " + e.getMessage(), tableName);
    2724           0 :                 }
    2725             :                 
    2726       47447 :         }
    2727             : 
    2728        1781 :         vector<bool> Parser::get1DBoolean(const string &name, const string &tableName, const string &xmlDoc)
    2729             :         {
    2730        1781 :                 string xmlField = Parser::getField(xmlDoc,name);
    2731        1781 :                 if (xmlField.length() == 0) {
    2732           0 :                         throw ConversionException("Error: Field \"" + 
    2733           0 :                                         name + "\": Invalid XML syntax", tableName);
    2734             :                 }
    2735        3562 :                 StringTokenizer t(xmlField," ");
    2736             :                 try {
    2737        1781 :                         int ndim = Integer::parseInt(t.nextToken());
    2738        1781 :                         if (ndim != 1) {
    2739           0 :                                 throw ConversionException("Error: Field \"" + 
    2740           0 :                                         name + "\": Invalid array format", tableName);
    2741             :                         }
    2742        1781 :                         int dim0 = Integer::parseInt(t.nextToken());
    2743        1781 :                         vector<bool> value (dim0);
    2744        1781 :                         if (dim0 == 0)
    2745           0 :                                 return value;
    2746        4900 :                         for (int i = 0; i < dim0; ++i) {
    2747             :         
    2748        3119 :                                 value[i] = Boolean::parseBoolean(t.nextToken());
    2749             :         
    2750             :                         }
    2751        1781 :                         if (t.hasMoreTokens()) {
    2752           0 :                                 throw ConversionException("Error: Field \"" + 
    2753           0 :                                         name + "\": Syntax error.", tableName);
    2754             :                         }
    2755        1781 :                         return value;
    2756        1781 :                 } catch (const NumberFormatException &e) {
    2757           0 :                         throw ConversionException("Error: Field \"" + 
    2758           0 :                                 name + "\": " + e.getMessage(), tableName);
    2759           0 :                 } catch (const OutOfBoundsException &e) {
    2760           0 :                         throw  ConversionException("Error: Field \"" + 
    2761           0 :                                 name + "\": Unexpected end of string", tableName);
    2762           0 :                 } catch (const TagFormatException &e) {
    2763           0 :                         throw ConversionException("Error: Field \"" + 
    2764           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2765           0 :                 }               
    2766        1781 :         }
    2767             :                 
    2768          60 :         vector< vector<bool> > Parser::get2DBoolean(const string &name, const string &tableName, const string &xmlDoc)
    2769             :         {
    2770          60 :                 string xmlField = Parser::getField(xmlDoc,name);
    2771          60 :                 if (xmlField.length() == 0) {
    2772           0 :                         throw ConversionException("Error: Field \"" + 
    2773           0 :                                         name + "\": Invalid XML syntax", tableName);
    2774             :                 }
    2775         120 :                 StringTokenizer t(xmlField," ");
    2776             :                 try {
    2777          60 :                         int ndim = Integer::parseInt(t.nextToken());
    2778          60 :                         if (ndim != 2) {
    2779           0 :                                 throw ConversionException("Error: Field \"" + 
    2780           0 :                                         name + "\": Invalid array format", tableName);
    2781             :                         }
    2782          60 :                         int dim0 = Integer::parseInt(t.nextToken());
    2783          60 :                         int dim1 = Integer::parseInt(t.nextToken());
    2784          60 :                         vector< vector<bool> > value;
    2785             : 
    2786          60 :                         if (dim0 == 0 || dim1 == 0)
    2787           0 :                                 return value;
    2788             : 
    2789          60 :                         vector<bool> v_aux;
    2790         180 :                         for (int i = 0; i < dim0; ++i) {
    2791         120 :                                 v_aux.clear();
    2792         360 :                                 for (int j = 0; j < dim1; ++j) {
    2793             :         
    2794         240 :                                         v_aux.push_back(Boolean::parseBoolean(t.nextToken()));
    2795             :         
    2796             :                                 }
    2797         120 :                                 value.push_back(v_aux);
    2798             :                         }
    2799          60 :                         if (t.hasMoreTokens()) {
    2800           0 :                                 throw ConversionException("Error: Field \"" + 
    2801           0 :                                         name + "\": Syntax error.", tableName);
    2802             :                         }
    2803          60 :                         return value;
    2804          60 :                 } catch (const NumberFormatException &e) {
    2805           0 :                         throw ConversionException("Error: Field \"" + 
    2806           0 :                                 name + "\": " + e.getMessage(), tableName);
    2807           0 :                 } catch (const OutOfBoundsException &e) {
    2808           0 :                         throw  ConversionException("Error: Field \"" + 
    2809           0 :                                 name + "\": Unexpected end of string", tableName);
    2810           0 :                 } catch (const TagFormatException &e) {
    2811           0 :                         throw ConversionException("Error: Field \"" + 
    2812           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2813           0 :                 }               
    2814          60 :         }       
    2815             :         
    2816           0 :         vector< vector< vector<bool> > > Parser::get3DBoolean(const string &name, const string &tableName, const string &xmlDoc)
    2817             :         {
    2818           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    2819           0 :                 if (xmlField.length() == 0) {
    2820           0 :                         throw ConversionException("Error: Field \"" + 
    2821           0 :                                         name + "\": Invalid XML syntax", tableName);
    2822             :                 }
    2823           0 :                 StringTokenizer t(xmlField," ");
    2824             :                 try {
    2825           0 :                         int ndim = Integer::parseInt(t.nextToken());
    2826           0 :                         if (ndim != 3) {
    2827           0 :                                 throw ConversionException("Error: Field \"" + 
    2828           0 :                                         name + "\": Invalid array format", tableName);
    2829             :                         }
    2830           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    2831           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    2832           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    2833           0 :                         vector< vector< vector<bool> > > value ;
    2834           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    2835           0 :                                 return value;
    2836             :                         
    2837           0 :                         vector<vector<bool> > vv_aux;
    2838           0 :                         vector<bool> v_aux;
    2839           0 :                         for (int i = 0; i < dim0; ++i) {
    2840           0 :                                 vv_aux.clear();
    2841           0 :                                 for (int j = 0; j < dim1; ++j) {
    2842           0 :                                         v_aux.clear();
    2843           0 :                                         for (int k = 0; k < dim2; ++k) {
    2844             :         
    2845           0 :                                                 v_aux.push_back(Boolean::parseBoolean(t.nextToken()));
    2846             :         
    2847             :                                         }
    2848           0 :                                         vv_aux.push_back(v_aux);
    2849             :                                 }
    2850           0 :                                 value.push_back(vv_aux);
    2851             :                         }
    2852           0 :                         if (t.hasMoreTokens()) {
    2853           0 :                                 throw ConversionException("Error: Field \"" + 
    2854           0 :                                         name + "\": Syntax error.", tableName);
    2855             :                         }
    2856           0 :                         return value;
    2857           0 :                 } catch (const NumberFormatException &e) {
    2858           0 :                         throw ConversionException("Error: Field \"" + 
    2859           0 :                                 name + "\": " + e.getMessage(), tableName);
    2860           0 :                 } catch (const OutOfBoundsException &e) {
    2861           0 :                         throw  ConversionException("Error: Field \"" + 
    2862           0 :                                 name + "\": Unexpected end of string", tableName);
    2863           0 :                 } catch (const TagFormatException &e) {
    2864           0 :                         throw ConversionException("Error: Field \"" + 
    2865           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2866           0 :                 }               
    2867           0 :         }
    2868             :         
    2869           0 :         vector< vector< vector< vector<bool> > > >Parser::get4DBoolean(const string &name, const string &tableName, const string &xmlDoc)
    2870             :         {
    2871           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    2872           0 :                 if (xmlField.length() == 0) {
    2873           0 :                         throw ConversionException("Error: Field \"" + 
    2874           0 :                                         name + "\": Invalid XML syntax", tableName);
    2875             :                 }
    2876           0 :                 StringTokenizer t(xmlField," ");
    2877             :                 try {
    2878           0 :                         int ndim = Integer::parseInt(t.nextToken());
    2879           0 :                         if (ndim != 4) {
    2880           0 :                                 throw ConversionException("Error: Field \"" + 
    2881           0 :                                         name + "\": Invalid array format", tableName);
    2882             :                         }
    2883           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    2884           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    2885           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    2886           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    2887           0 :                         vector<vector< vector< vector<bool> > > >value;
    2888           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    2889           0 :                                 return value;
    2890             :                         
    2891           0 :                         vector<vector<vector<bool> > >vvv_aux;
    2892           0 :                         vector<vector< bool> > vv_aux;
    2893           0 :                         vector<bool> v_aux;
    2894           0 :                         for (int i = 0; i < dim0; ++i) {
    2895           0 :                                 vvv_aux.clear();
    2896           0 :                                 for (int j = 0; j < dim1; ++j) {
    2897           0 :                                         vv_aux.clear();
    2898           0 :                                         for (int k = 0; k < dim2; ++k) {
    2899           0 :                                                 v_aux.clear();
    2900           0 :                                                 for (int l = 0; l < dim3; l++) {
    2901             :         
    2902           0 :                                                         v_aux.push_back(Boolean::parseBoolean(t.nextToken()));
    2903             :         
    2904             :                                                 }
    2905           0 :                                                 vv_aux.push_back(v_aux);
    2906             :                                         }
    2907           0 :                                         vvv_aux.push_back(vv_aux);
    2908             :                                 }
    2909           0 :                                 value.push_back(vvv_aux);
    2910             :                         }
    2911           0 :                         if (t.hasMoreTokens()) {
    2912           0 :                                 throw ConversionException("Error: Field \"" + 
    2913           0 :                                         name + "\": Syntax error.", tableName);
    2914             :                         }
    2915           0 :                         return value;
    2916           0 :                 } catch (const NumberFormatException &e) {
    2917           0 :                         throw ConversionException("Error: Field \"" + 
    2918           0 :                                 name + "\": " + e.getMessage(), tableName);
    2919           0 :                 } catch (const OutOfBoundsException &e) {
    2920           0 :                         throw  ConversionException("Error: Field \"" + 
    2921           0 :                                 name + "\": Unexpected end of string", tableName);
    2922           0 :                 } catch (const TagFormatException &e) {
    2923           0 :                         throw ConversionException("Error: Field \"" + 
    2924           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    2925           0 :                 }               
    2926           0 :         }       
    2927             :         
    2928             : 
    2929             :                 
    2930             : 
    2931             : 
    2932             :         // Field type: std::string
    2933             : 
    2934        4204 :         void Parser::toXML(std::string data, const string &name, string &buf) {
    2935        4204 :                 buf.append("<" + name + "> ");
    2936             :         
    2937        4204 :                 if (data.size()>0)
    2938        4130 :                     buf.append(Parser::encode(data));
    2939             :                 
    2940        4204 :                 buf.append(" </" + name + "> ");
    2941        4204 :         }
    2942             : 
    2943             :         
    2944             :         
    2945             :         
    2946        1529 :         void Parser::toXML(vector<std::string> data, const string &name, string &buf) {
    2947        1529 :                 buf.append("<" + name + "> ");
    2948        1529 :                 buf.append("1 ");
    2949        1529 :                 buf.append(Integer::toString(data.size()));
    2950        1529 :                 buf.append(" ");
    2951        3560 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2952             :         
    2953        2031 :                         buf.append("\"");
    2954        2031 :                         if (data[i].size()>0)        
    2955        2031 :                             buf.append(Parser::encode(data[i]));
    2956        2031 :                         buf.append("\"");
    2957             :                 
    2958        2031 :                         buf.append(" ");
    2959             :                 }
    2960        1529 :                 buf.append(" </" + name + "> ");
    2961        1529 :         }
    2962             : 
    2963           0 :         void Parser::toXML(vector< vector<std::string> > data, const string &name, string &buf) {
    2964           0 :                 buf.append("<" + name + "> ");
    2965           0 :                 buf.append("2 ");
    2966           0 :                 buf.append(Integer::toString(data.size()));
    2967           0 :                 buf.append(" ");
    2968           0 :                 buf.append(Integer::toString(data[0].size()));
    2969           0 :                 buf.append(" ");
    2970           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2971           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2972             :         
    2973           0 :                                 buf.append("\"");
    2974           0 :                                 if(data[i][j].size()>0)      
    2975           0 :                                     buf.append(Parser::encode(data[i][j]));
    2976             : 
    2977           0 :                                 buf.append("\"");
    2978             :                 
    2979           0 :                                 buf.append(" ");
    2980             :                         }
    2981             :                 }
    2982           0 :                 buf.append(" </" + name + "> ");
    2983           0 :         }
    2984             :         
    2985           0 :         void Parser::toXML(vector< vector< vector<std::string> > > data, const string &name, string &buf) {
    2986           0 :                 buf.append("<" + name + "> ");
    2987           0 :                 buf.append("3 ");
    2988           0 :                 buf.append(Integer::toString(data.size()));
    2989           0 :                 buf.append(" ");
    2990           0 :                 buf.append(Integer::toString(data[0].size()));
    2991           0 :                 buf.append(" ");
    2992           0 :                 buf.append(Integer::toString(data[0][0].size()));
    2993           0 :                 buf.append(" ");
    2994           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    2995           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    2996           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    2997             :         
    2998           0 :                                         buf.append("\"");
    2999           0 :                                         if (data[i][j][k].size() > 0)        
    3000           0 :                                             buf.append(Parser::encode(data[i][j][k]));
    3001             : 
    3002           0 :                                         buf.append("\"");
    3003             :                 
    3004           0 :                                         buf.append(" ");
    3005             :                                 }
    3006             :                         }
    3007             :                 }
    3008           0 :                 buf.append(" </" + name + "> ");
    3009           0 :         }
    3010             :         
    3011           0 :         void Parser::toXML(vector<vector< vector< vector<std::string> > > >data, const string &name, string &buf) {
    3012           0 :                 buf.append("<" + name + "> ");
    3013           0 :                 buf.append("4 ");
    3014           0 :                 buf.append(Integer::toString(data.size()));
    3015           0 :                 buf.append(" ");
    3016           0 :                 buf.append(Integer::toString(data[0].size()));
    3017           0 :                 buf.append(" ");
    3018           0 :                 buf.append(Integer::toString(data[0][0].size()));
    3019           0 :                 buf.append(" ");
    3020           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    3021           0 :                 buf.append(" ");
    3022           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3023           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3024           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    3025           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    3026             :         
    3027           0 :                                                 buf.append("\"");
    3028           0 :                                                 if (data[i][j][k][l].size() > 0)
    3029           0 :                                                     Parser::encode(data[i][j][k][l]);
    3030           0 :                                                 buf.append("\"");
    3031             :                 
    3032           0 :                                                 buf.append(" ");
    3033             :                                         }
    3034             :                                 }
    3035             :                         }
    3036             :                 }
    3037           0 :                 buf.append(" </" + name + "> ");
    3038           0 :         }       
    3039             :         
    3040             :                 
    3041             : 
    3042             : 
    3043             :         // Field type: Angle
    3044             : 
    3045         334 :         void Parser::toXML(Angle data, const string &name, string &buf) {
    3046         334 :                 buf.append("<" + name + "> ");
    3047             :         
    3048         334 :                 buf.append(data.toString());
    3049             :                 
    3050         334 :                 buf.append(" </" + name + "> ");
    3051         334 :         }
    3052             : 
    3053             :         
    3054             :         
    3055             :         
    3056        1395 :         void Parser::toXML(vector<Angle> data, const string &name, string &buf) {
    3057        1395 :                 buf.append("<" + name + "> ");
    3058        1395 :                 buf.append("1 ");
    3059        1395 :                 buf.append(Integer::toString(data.size()));
    3060        1395 :                 buf.append(" ");
    3061        4185 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3062             :         
    3063        2790 :                         buf.append(data[i].toString());
    3064             :                 
    3065        2790 :                         buf.append(" ");
    3066             :                 }
    3067        1395 :                 buf.append(" </" + name + "> ");
    3068        1395 :         }
    3069             : 
    3070         760 :         void Parser::toXML(vector< vector<Angle> > data, const string &name, string &buf) {
    3071         760 :                 buf.append("<" + name + "> ");
    3072         760 :                 buf.append("2 ");
    3073         760 :                 buf.append(Integer::toString(data.size()));
    3074         760 :                 buf.append(" ");
    3075         760 :                 buf.append(Integer::toString(data[0].size()));
    3076         760 :                 buf.append(" ");
    3077        1520 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3078        2280 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3079             :         
    3080        1520 :                                 buf.append(data[i][j].toString());
    3081             :                 
    3082        1520 :                                 buf.append(" ");
    3083             :                         }
    3084             :                 }
    3085         760 :                 buf.append(" </" + name + "> ");
    3086         760 :         }
    3087             :         
    3088           0 :         void Parser::toXML(vector< vector< vector<Angle> > > data, const string &name, string &buf) {
    3089           0 :                 buf.append("<" + name + "> ");
    3090           0 :                 buf.append("3 ");
    3091           0 :                 buf.append(Integer::toString(data.size()));
    3092           0 :                 buf.append(" ");
    3093           0 :                 buf.append(Integer::toString(data[0].size()));
    3094           0 :                 buf.append(" ");
    3095           0 :                 buf.append(Integer::toString(data[0][0].size()));
    3096           0 :                 buf.append(" ");
    3097           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3098           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3099           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    3100             :         
    3101           0 :                                         buf.append(data[i][j][k].toString());
    3102             :                 
    3103           0 :                                         buf.append(" ");
    3104             :                                 }
    3105             :                         }
    3106             :                 }
    3107           0 :                 buf.append(" </" + name + "> ");
    3108           0 :         }
    3109             :         
    3110           0 :         void Parser::toXML(vector<vector< vector< vector<Angle> > > >data, const string &name, string &buf) {
    3111           0 :                 buf.append("<" + name + "> ");
    3112           0 :                 buf.append("4 ");
    3113           0 :                 buf.append(Integer::toString(data.size()));
    3114           0 :                 buf.append(" ");
    3115           0 :                 buf.append(Integer::toString(data[0].size()));
    3116           0 :                 buf.append(" ");
    3117           0 :                 buf.append(Integer::toString(data[0][0].size()));
    3118           0 :                 buf.append(" ");
    3119           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    3120           0 :                 buf.append(" ");
    3121           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3122           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3123           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    3124           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    3125             :         
    3126           0 :                                                 buf.append(data[i][j][k][l].toString());
    3127             :                 
    3128           0 :                                                 buf.append(" ");
    3129             :                                         }
    3130             :                                 }
    3131             :                         }
    3132             :                 }
    3133           0 :                 buf.append(" </" + name + "> ");
    3134           0 :         }       
    3135             :         
    3136             :                 
    3137             : 
    3138             :         
    3139             :                 
    3140             :         
    3141       15796 :         Angle Parser::getAngle(const string &name, const string &tableName, const string &xmlDoc) 
    3142             :         {
    3143       15796 :                 string xmlField = Parser::getField(xmlDoc,name);
    3144       15796 :                 if (xmlField.length() == 0)
    3145           0 :                         throw ConversionException("Error: Missing field \"" + 
    3146           0 :                                 name + "\" or invalid syntax",tableName);
    3147             :         
    3148             :         try {   
    3149       31592 :                         return Angle (xmlField);
    3150             :                 }
    3151           0 :                 catch (const InvalidArgumentException &e) {
    3152           0 :                         throw ConversionException("Error: message was '"+ 
    3153           0 :                                                    e.getMessage()+
    3154             :                                                    "'",
    3155           0 :                                                    tableName);
    3156           0 :                 }
    3157             :                 
    3158       15796 :         }
    3159             : 
    3160       77047 :         vector<Angle> Parser::get1DAngle(const string &name, const string &tableName, const string &xmlDoc)
    3161             :         {
    3162       77047 :                 string xmlField = Parser::getField(xmlDoc,name);
    3163       77047 :                 if (xmlField.length() == 0) {
    3164           0 :                         throw ConversionException("Error: Field \"" + 
    3165           0 :                                         name + "\": Invalid XML syntax", tableName);
    3166             :                 }
    3167      154094 :                 StringTokenizer t(xmlField," ");
    3168             :                 try {
    3169       77047 :                         int ndim = Integer::parseInt(t.nextToken());
    3170       77047 :                         if (ndim != 1) {
    3171           0 :                                 throw ConversionException("Error: Field \"" + 
    3172           0 :                                         name + "\": Invalid array format", tableName);
    3173             :                         }
    3174       77047 :                         int dim0 = Integer::parseInt(t.nextToken());
    3175       77047 :                         vector<Angle> value (dim0);
    3176       77047 :                         if (dim0 == 0)
    3177           0 :                                 return value;
    3178      231130 :                         for (int i = 0; i < dim0; ++i) {
    3179             :         
    3180      154083 :                                 value[i] = Angle::getAngle(t);
    3181             :         
    3182             :                         }
    3183       77047 :                         if (t.hasMoreTokens()) {
    3184           0 :                                 throw ConversionException("Error: Field \"" + 
    3185           0 :                                         name + "\": Syntax error.", tableName);
    3186             :                         }
    3187       77047 :                         return value;
    3188       77047 :                 } catch (const NumberFormatException &e) {
    3189           0 :                         throw ConversionException("Error: Field \"" + 
    3190           0 :                                 name + "\": " + e.getMessage(), tableName);
    3191           0 :                 } catch (const OutOfBoundsException &e) {
    3192           0 :                         throw  ConversionException("Error: Field \"" + 
    3193           0 :                                 name + "\": Unexpected end of string", tableName);
    3194           0 :                 } catch (const TagFormatException &e) {
    3195           0 :                         throw ConversionException("Error: Field \"" + 
    3196           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3197           0 :                 }               
    3198       77047 :         }
    3199             :                 
    3200        4376 :         vector< vector<Angle> > Parser::get2DAngle(const string &name, const string &tableName, const string &xmlDoc)
    3201             :         {
    3202        4376 :                 string xmlField = Parser::getField(xmlDoc,name);
    3203        4376 :                 if (xmlField.length() == 0) {
    3204           0 :                         throw ConversionException("Error: Field \"" + 
    3205           0 :                                         name + "\": Invalid XML syntax", tableName);
    3206             :                 }
    3207        8752 :                 StringTokenizer t(xmlField," ");
    3208             :                 try {
    3209        4376 :                         int ndim = Integer::parseInt(t.nextToken());
    3210        4376 :                         if (ndim != 2) {
    3211           0 :                                 throw ConversionException("Error: Field \"" + 
    3212           0 :                                         name + "\": Invalid array format", tableName);
    3213             :                         }
    3214        4376 :                         int dim0 = Integer::parseInt(t.nextToken());
    3215        4376 :                         int dim1 = Integer::parseInt(t.nextToken());
    3216        4376 :                         vector< vector<Angle> > value;
    3217             : 
    3218        4376 :                         if (dim0 == 0 || dim1 == 0)
    3219           0 :                                 return value;
    3220             : 
    3221        4376 :                         vector<Angle> v_aux;
    3222       11892 :                         for (int i = 0; i < dim0; ++i) {
    3223        7516 :                                 v_aux.clear();
    3224       22544 :                                 for (int j = 0; j < dim1; ++j) {
    3225             :         
    3226       15028 :                                         v_aux.push_back(Angle::getAngle(t));
    3227             :         
    3228             :                                 }
    3229        7516 :                                 value.push_back(v_aux);
    3230             :                         }
    3231        4376 :                         if (t.hasMoreTokens()) {
    3232           0 :                                 throw ConversionException("Error: Field \"" + 
    3233           0 :                                         name + "\": Syntax error.", tableName);
    3234             :                         }
    3235        4376 :                         return value;
    3236        4376 :                 } catch (const NumberFormatException &e) {
    3237           0 :                         throw ConversionException("Error: Field \"" + 
    3238           0 :                                 name + "\": " + e.getMessage(), tableName);
    3239           0 :                 } catch (const OutOfBoundsException &e) {
    3240           0 :                         throw  ConversionException("Error: Field \"" + 
    3241           0 :                                 name + "\": Unexpected end of string", tableName);
    3242           0 :                 } catch (const TagFormatException &e) {
    3243           0 :                         throw ConversionException("Error: Field \"" + 
    3244           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3245           0 :                 }               
    3246        4376 :         }       
    3247             :         
    3248           0 :         vector< vector< vector<Angle> > > Parser::get3DAngle(const string &name, const string &tableName, const string &xmlDoc)
    3249             :         {
    3250           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3251           0 :                 if (xmlField.length() == 0) {
    3252           0 :                         throw ConversionException("Error: Field \"" + 
    3253           0 :                                         name + "\": Invalid XML syntax", tableName);
    3254             :                 }
    3255           0 :                 StringTokenizer t(xmlField," ");
    3256             :                 try {
    3257           0 :                         int ndim = Integer::parseInt(t.nextToken());
    3258           0 :                         if (ndim != 3) {
    3259           0 :                                 throw ConversionException("Error: Field \"" + 
    3260           0 :                                         name + "\": Invalid array format", tableName);
    3261             :                         }
    3262           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    3263           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    3264           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    3265           0 :                         vector< vector< vector<Angle> > > value ;
    3266           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    3267           0 :                                 return value;
    3268             :                         
    3269           0 :                         vector<vector<Angle> > vv_aux;
    3270           0 :                         vector<Angle> v_aux;
    3271           0 :                         for (int i = 0; i < dim0; ++i) {
    3272           0 :                                 vv_aux.clear();
    3273           0 :                                 for (int j = 0; j < dim1; ++j) {
    3274           0 :                                         v_aux.clear();
    3275           0 :                                         for (int k = 0; k < dim2; ++k) {
    3276             :         
    3277           0 :                                                 v_aux.push_back(Angle::getAngle(t));
    3278             :         
    3279             :                                         }
    3280           0 :                                         vv_aux.push_back(v_aux);
    3281             :                                 }
    3282           0 :                                 value.push_back(vv_aux);
    3283             :                         }
    3284           0 :                         if (t.hasMoreTokens()) {
    3285           0 :                                 throw ConversionException("Error: Field \"" + 
    3286           0 :                                         name + "\": Syntax error.", tableName);
    3287             :                         }
    3288           0 :                         return value;
    3289           0 :                 } catch (const NumberFormatException &e) {
    3290           0 :                         throw ConversionException("Error: Field \"" + 
    3291           0 :                                 name + "\": " + e.getMessage(), tableName);
    3292           0 :                 } catch (const OutOfBoundsException &e) {
    3293           0 :                         throw  ConversionException("Error: Field \"" + 
    3294           0 :                                 name + "\": Unexpected end of string", tableName);
    3295           0 :                 } catch (const TagFormatException &e) {
    3296           0 :                         throw ConversionException("Error: Field \"" + 
    3297           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3298           0 :                 }               
    3299           0 :         }
    3300             :         
    3301           0 :         vector< vector< vector< vector<Angle> > > >Parser::get4DAngle(const string &name, const string &tableName, const string &xmlDoc)
    3302             :         {
    3303           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3304           0 :                 if (xmlField.length() == 0) {
    3305           0 :                         throw ConversionException("Error: Field \"" + 
    3306           0 :                                         name + "\": Invalid XML syntax", tableName);
    3307             :                 }
    3308           0 :                 StringTokenizer t(xmlField," ");
    3309             :                 try {
    3310           0 :                         int ndim = Integer::parseInt(t.nextToken());
    3311           0 :                         if (ndim != 4) {
    3312           0 :                                 throw ConversionException("Error: Field \"" + 
    3313           0 :                                         name + "\": Invalid array format", tableName);
    3314             :                         }
    3315           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    3316           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    3317           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    3318           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    3319           0 :                         vector<vector< vector< vector<Angle> > > >value;
    3320           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    3321           0 :                                 return value;
    3322             :                         
    3323           0 :                         vector<vector<vector<Angle> > >vvv_aux;
    3324           0 :                         vector<vector< Angle> > vv_aux;
    3325           0 :                         vector<Angle> v_aux;
    3326           0 :                         for (int i = 0; i < dim0; ++i) {
    3327           0 :                                 vvv_aux.clear();
    3328           0 :                                 for (int j = 0; j < dim1; ++j) {
    3329           0 :                                         vv_aux.clear();
    3330           0 :                                         for (int k = 0; k < dim2; ++k) {
    3331           0 :                                                 v_aux.clear();
    3332           0 :                                                 for (int l = 0; l < dim3; l++) {
    3333             :         
    3334           0 :                                                         v_aux.push_back(Angle::getAngle(t));
    3335             :         
    3336             :                                                 }
    3337           0 :                                                 vv_aux.push_back(v_aux);
    3338             :                                         }
    3339           0 :                                         vvv_aux.push_back(vv_aux);
    3340             :                                 }
    3341           0 :                                 value.push_back(vvv_aux);
    3342             :                         }
    3343           0 :                         if (t.hasMoreTokens()) {
    3344           0 :                                 throw ConversionException("Error: Field \"" + 
    3345           0 :                                         name + "\": Syntax error.", tableName);
    3346             :                         }
    3347           0 :                         return value;
    3348           0 :                 } catch (const NumberFormatException &e) {
    3349           0 :                         throw ConversionException("Error: Field \"" + 
    3350           0 :                                 name + "\": " + e.getMessage(), tableName);
    3351           0 :                 } catch (const OutOfBoundsException &e) {
    3352           0 :                         throw  ConversionException("Error: Field \"" + 
    3353           0 :                                 name + "\": Unexpected end of string", tableName);
    3354           0 :                 } catch (const TagFormatException &e) {
    3355           0 :                         throw ConversionException("Error: Field \"" + 
    3356           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3357           0 :                 }               
    3358           0 :         }       
    3359             :         
    3360             : 
    3361             :                 
    3362             : 
    3363             : 
    3364             :         // Field type: AngularRate
    3365             : 
    3366           0 :         void Parser::toXML(AngularRate data, const string &name, string &buf) {
    3367           0 :                 buf.append("<" + name + "> ");
    3368             :         
    3369           0 :                 buf.append(data.toString());
    3370             :                 
    3371           0 :                 buf.append(" </" + name + "> ");
    3372           0 :         }
    3373             : 
    3374             :         
    3375             :         
    3376             :         
    3377         499 :         void Parser::toXML(vector<AngularRate> data, const string &name, string &buf) {
    3378         499 :                 buf.append("<" + name + "> ");
    3379         499 :                 buf.append("1 ");
    3380         499 :                 buf.append(Integer::toString(data.size()));
    3381         499 :                 buf.append(" ");
    3382        1497 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3383             :         
    3384         998 :                         buf.append(data[i].toString());
    3385             :                 
    3386         998 :                         buf.append(" ");
    3387             :                 }
    3388         499 :                 buf.append(" </" + name + "> ");
    3389         499 :         }
    3390             : 
    3391           0 :         void Parser::toXML(vector< vector<AngularRate> > data, const string &name, string &buf) {
    3392           0 :                 buf.append("<" + name + "> ");
    3393           0 :                 buf.append("2 ");
    3394           0 :                 buf.append(Integer::toString(data.size()));
    3395           0 :                 buf.append(" ");
    3396           0 :                 buf.append(Integer::toString(data[0].size()));
    3397           0 :                 buf.append(" ");
    3398           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3399           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3400             :         
    3401           0 :                                 buf.append(data[i][j].toString());
    3402             :                 
    3403           0 :                                 buf.append(" ");
    3404             :                         }
    3405             :                 }
    3406           0 :                 buf.append(" </" + name + "> ");
    3407           0 :         }
    3408             :         
    3409           0 :         void Parser::toXML(vector< vector< vector<AngularRate> > > data, const string &name, string &buf) {
    3410           0 :                 buf.append("<" + name + "> ");
    3411           0 :                 buf.append("3 ");
    3412           0 :                 buf.append(Integer::toString(data.size()));
    3413           0 :                 buf.append(" ");
    3414           0 :                 buf.append(Integer::toString(data[0].size()));
    3415           0 :                 buf.append(" ");
    3416           0 :                 buf.append(Integer::toString(data[0][0].size()));
    3417           0 :                 buf.append(" ");
    3418           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3419           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3420           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    3421             :         
    3422           0 :                                         buf.append(data[i][j][k].toString());
    3423             :                 
    3424           0 :                                         buf.append(" ");
    3425             :                                 }
    3426             :                         }
    3427             :                 }
    3428           0 :                 buf.append(" </" + name + "> ");
    3429           0 :         }
    3430             :         
    3431           0 :         void Parser::toXML(vector<vector< vector< vector<AngularRate> > > >data, const string &name, string &buf) {
    3432           0 :                 buf.append("<" + name + "> ");
    3433           0 :                 buf.append("4 ");
    3434           0 :                 buf.append(Integer::toString(data.size()));
    3435           0 :                 buf.append(" ");
    3436           0 :                 buf.append(Integer::toString(data[0].size()));
    3437           0 :                 buf.append(" ");
    3438           0 :                 buf.append(Integer::toString(data[0][0].size()));
    3439           0 :                 buf.append(" ");
    3440           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    3441           0 :                 buf.append(" ");
    3442           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3443           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3444           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    3445           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    3446             :         
    3447           0 :                                                 buf.append(data[i][j][k][l].toString());
    3448             :                 
    3449           0 :                                                 buf.append(" ");
    3450             :                                         }
    3451             :                                 }
    3452             :                         }
    3453             :                 }
    3454           0 :                 buf.append(" </" + name + "> ");
    3455           0 :         }       
    3456             :         
    3457             :                 
    3458             : 
    3459             :         
    3460             :                 
    3461             :         
    3462           0 :         AngularRate Parser::getAngularRate(const string &name, const string &tableName, const string &xmlDoc) 
    3463             :         {
    3464           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3465           0 :                 if (xmlField.length() == 0)
    3466           0 :                         throw ConversionException("Error: Missing field \"" + 
    3467           0 :                                 name + "\" or invalid syntax",tableName);
    3468             :         
    3469             :         try {   
    3470           0 :                         return AngularRate (xmlField);
    3471             :                 }
    3472           0 :                 catch (const InvalidArgumentException &e) {
    3473           0 :                         throw ConversionException("Error: message was '"+ 
    3474           0 :                                                    e.getMessage()+
    3475             :                                                    "'",
    3476           0 :                                                    tableName);
    3477           0 :                 }
    3478             :                 
    3479           0 :         }
    3480             : 
    3481        9613 :         vector<AngularRate> Parser::get1DAngularRate(const string &name, const string &tableName, const string &xmlDoc)
    3482             :         {
    3483        9613 :                 string xmlField = Parser::getField(xmlDoc,name);
    3484        9613 :                 if (xmlField.length() == 0) {
    3485           0 :                         throw ConversionException("Error: Field \"" + 
    3486           0 :                                         name + "\": Invalid XML syntax", tableName);
    3487             :                 }
    3488       19226 :                 StringTokenizer t(xmlField," ");
    3489             :                 try {
    3490        9613 :                         int ndim = Integer::parseInt(t.nextToken());
    3491        9613 :                         if (ndim != 1) {
    3492           0 :                                 throw ConversionException("Error: Field \"" + 
    3493           0 :                                         name + "\": Invalid array format", tableName);
    3494             :                         }
    3495        9613 :                         int dim0 = Integer::parseInt(t.nextToken());
    3496        9613 :                         vector<AngularRate> value (dim0);
    3497        9613 :                         if (dim0 == 0)
    3498           0 :                                 return value;
    3499       28839 :                         for (int i = 0; i < dim0; ++i) {
    3500             :         
    3501       19226 :                                 value[i] = AngularRate::getAngularRate(t);
    3502             :         
    3503             :                         }
    3504        9613 :                         if (t.hasMoreTokens()) {
    3505           0 :                                 throw ConversionException("Error: Field \"" + 
    3506           0 :                                         name + "\": Syntax error.", tableName);
    3507             :                         }
    3508        9613 :                         return value;
    3509        9613 :                 } catch (const NumberFormatException &e) {
    3510           0 :                         throw ConversionException("Error: Field \"" + 
    3511           0 :                                 name + "\": " + e.getMessage(), tableName);
    3512           0 :                 } catch (const OutOfBoundsException &e) {
    3513           0 :                         throw  ConversionException("Error: Field \"" + 
    3514           0 :                                 name + "\": Unexpected end of string", tableName);
    3515           0 :                 } catch (const TagFormatException &e) {
    3516           0 :                         throw ConversionException("Error: Field \"" + 
    3517           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3518           0 :                 }               
    3519        9613 :         }
    3520             :                 
    3521           0 :         vector< vector<AngularRate> > Parser::get2DAngularRate(const string &name, const string &tableName, const string &xmlDoc)
    3522             :         {
    3523           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3524           0 :                 if (xmlField.length() == 0) {
    3525           0 :                         throw ConversionException("Error: Field \"" + 
    3526           0 :                                         name + "\": Invalid XML syntax", tableName);
    3527             :                 }
    3528           0 :                 StringTokenizer t(xmlField," ");
    3529             :                 try {
    3530           0 :                         int ndim = Integer::parseInt(t.nextToken());
    3531           0 :                         if (ndim != 2) {
    3532           0 :                                 throw ConversionException("Error: Field \"" + 
    3533           0 :                                         name + "\": Invalid array format", tableName);
    3534             :                         }
    3535           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    3536           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    3537           0 :                         vector< vector<AngularRate> > value;
    3538             : 
    3539           0 :                         if (dim0 == 0 || dim1 == 0)
    3540           0 :                                 return value;
    3541             : 
    3542           0 :                         vector<AngularRate> v_aux;
    3543           0 :                         for (int i = 0; i < dim0; ++i) {
    3544           0 :                                 v_aux.clear();
    3545           0 :                                 for (int j = 0; j < dim1; ++j) {
    3546             :         
    3547           0 :                                         v_aux.push_back(AngularRate::getAngularRate(t));
    3548             :         
    3549             :                                 }
    3550           0 :                                 value.push_back(v_aux);
    3551             :                         }
    3552           0 :                         if (t.hasMoreTokens()) {
    3553           0 :                                 throw ConversionException("Error: Field \"" + 
    3554           0 :                                         name + "\": Syntax error.", tableName);
    3555             :                         }
    3556           0 :                         return value;
    3557           0 :                 } catch (const NumberFormatException &e) {
    3558           0 :                         throw ConversionException("Error: Field \"" + 
    3559           0 :                                 name + "\": " + e.getMessage(), tableName);
    3560           0 :                 } catch (const OutOfBoundsException &e) {
    3561           0 :                         throw  ConversionException("Error: Field \"" + 
    3562           0 :                                 name + "\": Unexpected end of string", tableName);
    3563           0 :                 } catch (const TagFormatException &e) {
    3564           0 :                         throw ConversionException("Error: Field \"" + 
    3565           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3566           0 :                 }               
    3567           0 :         }       
    3568             :         
    3569           0 :         vector< vector< vector<AngularRate> > > Parser::get3DAngularRate(const string &name, const string &tableName, const string &xmlDoc)
    3570             :         {
    3571           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3572           0 :                 if (xmlField.length() == 0) {
    3573           0 :                         throw ConversionException("Error: Field \"" + 
    3574           0 :                                         name + "\": Invalid XML syntax", tableName);
    3575             :                 }
    3576           0 :                 StringTokenizer t(xmlField," ");
    3577             :                 try {
    3578           0 :                         int ndim = Integer::parseInt(t.nextToken());
    3579           0 :                         if (ndim != 3) {
    3580           0 :                                 throw ConversionException("Error: Field \"" + 
    3581           0 :                                         name + "\": Invalid array format", tableName);
    3582             :                         }
    3583           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    3584           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    3585           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    3586           0 :                         vector< vector< vector<AngularRate> > > value ;
    3587           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    3588           0 :                                 return value;
    3589             :                         
    3590           0 :                         vector<vector<AngularRate> > vv_aux;
    3591           0 :                         vector<AngularRate> v_aux;
    3592           0 :                         for (int i = 0; i < dim0; ++i) {
    3593           0 :                                 vv_aux.clear();
    3594           0 :                                 for (int j = 0; j < dim1; ++j) {
    3595           0 :                                         v_aux.clear();
    3596           0 :                                         for (int k = 0; k < dim2; ++k) {
    3597             :         
    3598           0 :                                                 v_aux.push_back(AngularRate::getAngularRate(t));
    3599             :         
    3600             :                                         }
    3601           0 :                                         vv_aux.push_back(v_aux);
    3602             :                                 }
    3603           0 :                                 value.push_back(vv_aux);
    3604             :                         }
    3605           0 :                         if (t.hasMoreTokens()) {
    3606           0 :                                 throw ConversionException("Error: Field \"" + 
    3607           0 :                                         name + "\": Syntax error.", tableName);
    3608             :                         }
    3609           0 :                         return value;
    3610           0 :                 } catch (const NumberFormatException &e) {
    3611           0 :                         throw ConversionException("Error: Field \"" + 
    3612           0 :                                 name + "\": " + e.getMessage(), tableName);
    3613           0 :                 } catch (const OutOfBoundsException &e) {
    3614           0 :                         throw  ConversionException("Error: Field \"" + 
    3615           0 :                                 name + "\": Unexpected end of string", tableName);
    3616           0 :                 } catch (const TagFormatException &e) {
    3617           0 :                         throw ConversionException("Error: Field \"" + 
    3618           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3619           0 :                 }               
    3620           0 :         }
    3621             :         
    3622           0 :         vector< vector< vector< vector<AngularRate> > > >Parser::get4DAngularRate(const string &name, const string &tableName, const string &xmlDoc)
    3623             :         {
    3624           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3625           0 :                 if (xmlField.length() == 0) {
    3626           0 :                         throw ConversionException("Error: Field \"" + 
    3627           0 :                                         name + "\": Invalid XML syntax", tableName);
    3628             :                 }
    3629           0 :                 StringTokenizer t(xmlField," ");
    3630             :                 try {
    3631           0 :                         int ndim = Integer::parseInt(t.nextToken());
    3632           0 :                         if (ndim != 4) {
    3633           0 :                                 throw ConversionException("Error: Field \"" + 
    3634           0 :                                         name + "\": Invalid array format", tableName);
    3635             :                         }
    3636           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    3637           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    3638           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    3639           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    3640           0 :                         vector<vector< vector< vector<AngularRate> > > >value;
    3641           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    3642           0 :                                 return value;
    3643             :                         
    3644           0 :                         vector<vector<vector<AngularRate> > >vvv_aux;
    3645           0 :                         vector<vector< AngularRate> > vv_aux;
    3646           0 :                         vector<AngularRate> v_aux;
    3647           0 :                         for (int i = 0; i < dim0; ++i) {
    3648           0 :                                 vvv_aux.clear();
    3649           0 :                                 for (int j = 0; j < dim1; ++j) {
    3650           0 :                                         vv_aux.clear();
    3651           0 :                                         for (int k = 0; k < dim2; ++k) {
    3652           0 :                                                 v_aux.clear();
    3653           0 :                                                 for (int l = 0; l < dim3; l++) {
    3654             :         
    3655           0 :                                                         v_aux.push_back(AngularRate::getAngularRate(t));
    3656             :         
    3657             :                                                 }
    3658           0 :                                                 vv_aux.push_back(v_aux);
    3659             :                                         }
    3660           0 :                                         vvv_aux.push_back(vv_aux);
    3661             :                                 }
    3662           0 :                                 value.push_back(vvv_aux);
    3663             :                         }
    3664           0 :                         if (t.hasMoreTokens()) {
    3665           0 :                                 throw ConversionException("Error: Field \"" + 
    3666           0 :                                         name + "\": Syntax error.", tableName);
    3667             :                         }
    3668           0 :                         return value;
    3669           0 :                 } catch (const NumberFormatException &e) {
    3670           0 :                         throw ConversionException("Error: Field \"" + 
    3671           0 :                                 name + "\": " + e.getMessage(), tableName);
    3672           0 :                 } catch (const OutOfBoundsException &e) {
    3673           0 :                         throw  ConversionException("Error: Field \"" + 
    3674           0 :                                 name + "\": Unexpected end of string", tableName);
    3675           0 :                 } catch (const TagFormatException &e) {
    3676           0 :                         throw ConversionException("Error: Field \"" + 
    3677           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3678           0 :                 }               
    3679           0 :         }       
    3680             :         
    3681             : 
    3682             :                 
    3683             : 
    3684             : 
    3685             :         // Field type: ArrayTime
    3686             : 
    3687        3444 :         void Parser::toXML(ArrayTime data, const string &name, string &buf) {
    3688        3444 :                 buf.append("<" + name + "> ");
    3689             :         
    3690        3444 :                 buf.append(data.toString());
    3691             :                 
    3692        3444 :                 buf.append(" </" + name + "> ");
    3693        3444 :         }
    3694             : 
    3695             :         
    3696             :         
    3697             :         
    3698           0 :         void Parser::toXML(vector<ArrayTime> data, const string &name, string &buf) {
    3699           0 :                 buf.append("<" + name + "> ");
    3700           0 :                 buf.append("1 ");
    3701           0 :                 buf.append(Integer::toString(data.size()));
    3702           0 :                 buf.append(" ");
    3703           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3704             :         
    3705           0 :                         buf.append(data[i].toString());
    3706             :                 
    3707           0 :                         buf.append(" ");
    3708             :                 }
    3709           0 :                 buf.append(" </" + name + "> ");
    3710           0 :         }
    3711             : 
    3712           0 :         void Parser::toXML(vector< vector<ArrayTime> > data, const string &name, string &buf) {
    3713           0 :                 buf.append("<" + name + "> ");
    3714           0 :                 buf.append("2 ");
    3715           0 :                 buf.append(Integer::toString(data.size()));
    3716           0 :                 buf.append(" ");
    3717           0 :                 buf.append(Integer::toString(data[0].size()));
    3718           0 :                 buf.append(" ");
    3719           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3720           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3721             :         
    3722           0 :                                 buf.append(data[i][j].toString());
    3723             :                 
    3724           0 :                                 buf.append(" ");
    3725             :                         }
    3726             :                 }
    3727           0 :                 buf.append(" </" + name + "> ");
    3728           0 :         }
    3729             :         
    3730           0 :         void Parser::toXML(vector< vector< vector<ArrayTime> > > data, const string &name, string &buf) {
    3731           0 :                 buf.append("<" + name + "> ");
    3732           0 :                 buf.append("3 ");
    3733           0 :                 buf.append(Integer::toString(data.size()));
    3734           0 :                 buf.append(" ");
    3735           0 :                 buf.append(Integer::toString(data[0].size()));
    3736           0 :                 buf.append(" ");
    3737           0 :                 buf.append(Integer::toString(data[0][0].size()));
    3738           0 :                 buf.append(" ");
    3739           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3740           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3741           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    3742             :         
    3743           0 :                                         buf.append(data[i][j][k].toString());
    3744             :                 
    3745           0 :                                         buf.append(" ");
    3746             :                                 }
    3747             :                         }
    3748             :                 }
    3749           0 :                 buf.append(" </" + name + "> ");
    3750           0 :         }
    3751             :         
    3752           0 :         void Parser::toXML(vector<vector< vector< vector<ArrayTime> > > >data, const string &name, string &buf) {
    3753           0 :                 buf.append("<" + name + "> ");
    3754           0 :                 buf.append("4 ");
    3755           0 :                 buf.append(Integer::toString(data.size()));
    3756           0 :                 buf.append(" ");
    3757           0 :                 buf.append(Integer::toString(data[0].size()));
    3758           0 :                 buf.append(" ");
    3759           0 :                 buf.append(Integer::toString(data[0][0].size()));
    3760           0 :                 buf.append(" ");
    3761           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    3762           0 :                 buf.append(" ");
    3763           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    3764           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    3765           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    3766           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    3767             :         
    3768           0 :                                                 buf.append(data[i][j][k][l].toString());
    3769             :                 
    3770           0 :                                                 buf.append(" ");
    3771             :                                         }
    3772             :                                 }
    3773             :                         }
    3774             :                 }
    3775           0 :                 buf.append(" </" + name + "> ");
    3776           0 :         }       
    3777             :         
    3778             :                 
    3779             : 
    3780             :         
    3781             :                 
    3782             :         
    3783       29591 :         ArrayTime Parser::getArrayTime(const string &name, const string &tableName, const string &xmlDoc) 
    3784             :         {
    3785       29591 :                 string xmlField = Parser::getField(xmlDoc,name);
    3786       29591 :                 if (xmlField.length() == 0)
    3787           0 :                         throw ConversionException("Error: Missing field \"" + 
    3788           0 :                                 name + "\" or invalid syntax",tableName);
    3789             :         
    3790             :         try {   
    3791       59182 :                         return ArrayTime (xmlField);
    3792             :                 }
    3793           0 :                 catch (const InvalidArgumentException &e) {
    3794           0 :                         throw ConversionException("Error: message was '"+ 
    3795           0 :                                                    e.getMessage()+
    3796             :                                                    "'",
    3797           0 :                                                    tableName);
    3798           0 :                 }
    3799             :                 
    3800       29591 :         }
    3801             : 
    3802           0 :         vector<ArrayTime> Parser::get1DArrayTime(const string &name, const string &tableName, const string &xmlDoc)
    3803             :         {
    3804           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3805           0 :                 if (xmlField.length() == 0) {
    3806           0 :                         throw ConversionException("Error: Field \"" + 
    3807           0 :                                         name + "\": Invalid XML syntax", tableName);
    3808             :                 }
    3809           0 :                 StringTokenizer t(xmlField," ");
    3810             :                 try {
    3811           0 :                         int ndim = Integer::parseInt(t.nextToken());
    3812           0 :                         if (ndim != 1) {
    3813           0 :                                 throw ConversionException("Error: Field \"" + 
    3814           0 :                                         name + "\": Invalid array format", tableName);
    3815             :                         }
    3816           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    3817           0 :                         vector<ArrayTime> value (dim0);
    3818           0 :                         if (dim0 == 0)
    3819           0 :                                 return value;
    3820           0 :                         for (int i = 0; i < dim0; ++i) {
    3821             :         
    3822           0 :                                 value[i] = ArrayTime::getArrayTime(t);
    3823             :         
    3824             :                         }
    3825           0 :                         if (t.hasMoreTokens()) {
    3826           0 :                                 throw ConversionException("Error: Field \"" + 
    3827           0 :                                         name + "\": Syntax error.", tableName);
    3828             :                         }
    3829           0 :                         return value;
    3830           0 :                 } catch (const NumberFormatException &e) {
    3831           0 :                         throw ConversionException("Error: Field \"" + 
    3832           0 :                                 name + "\": " + e.getMessage(), tableName);
    3833           0 :                 } catch (const OutOfBoundsException &e) {
    3834           0 :                         throw  ConversionException("Error: Field \"" + 
    3835           0 :                                 name + "\": Unexpected end of string", tableName);
    3836           0 :                 } catch (const TagFormatException &e) {
    3837           0 :                         throw ConversionException("Error: Field \"" + 
    3838           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3839           0 :                 }               
    3840           0 :         }
    3841             :                 
    3842           0 :         vector< vector<ArrayTime> > Parser::get2DArrayTime(const string &name, const string &tableName, const string &xmlDoc)
    3843             :         {
    3844           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3845           0 :                 if (xmlField.length() == 0) {
    3846           0 :                         throw ConversionException("Error: Field \"" + 
    3847           0 :                                         name + "\": Invalid XML syntax", tableName);
    3848             :                 }
    3849           0 :                 StringTokenizer t(xmlField," ");
    3850             :                 try {
    3851           0 :                         int ndim = Integer::parseInt(t.nextToken());
    3852           0 :                         if (ndim != 2) {
    3853           0 :                                 throw ConversionException("Error: Field \"" + 
    3854           0 :                                         name + "\": Invalid array format", tableName);
    3855             :                         }
    3856           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    3857           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    3858           0 :                         vector< vector<ArrayTime> > value;
    3859             : 
    3860           0 :                         if (dim0 == 0 || dim1 == 0)
    3861           0 :                                 return value;
    3862             : 
    3863           0 :                         vector<ArrayTime> v_aux;
    3864           0 :                         for (int i = 0; i < dim0; ++i) {
    3865           0 :                                 v_aux.clear();
    3866           0 :                                 for (int j = 0; j < dim1; ++j) {
    3867             :         
    3868           0 :                                         v_aux.push_back(ArrayTime::getArrayTime(t));
    3869             :         
    3870             :                                 }
    3871           0 :                                 value.push_back(v_aux);
    3872             :                         }
    3873           0 :                         if (t.hasMoreTokens()) {
    3874           0 :                                 throw ConversionException("Error: Field \"" + 
    3875           0 :                                         name + "\": Syntax error.", tableName);
    3876             :                         }
    3877           0 :                         return value;
    3878           0 :                 } catch (const NumberFormatException &e) {
    3879           0 :                         throw ConversionException("Error: Field \"" + 
    3880           0 :                                 name + "\": " + e.getMessage(), tableName);
    3881           0 :                 } catch (const OutOfBoundsException &e) {
    3882           0 :                         throw  ConversionException("Error: Field \"" + 
    3883           0 :                                 name + "\": Unexpected end of string", tableName);
    3884           0 :                 } catch (const TagFormatException &e) {
    3885           0 :                         throw ConversionException("Error: Field \"" + 
    3886           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3887           0 :                 }               
    3888           0 :         }       
    3889             :         
    3890           0 :         vector< vector< vector<ArrayTime> > > Parser::get3DArrayTime(const string &name, const string &tableName, const string &xmlDoc)
    3891             :         {
    3892           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3893           0 :                 if (xmlField.length() == 0) {
    3894           0 :                         throw ConversionException("Error: Field \"" + 
    3895           0 :                                         name + "\": Invalid XML syntax", tableName);
    3896             :                 }
    3897           0 :                 StringTokenizer t(xmlField," ");
    3898             :                 try {
    3899           0 :                         int ndim = Integer::parseInt(t.nextToken());
    3900           0 :                         if (ndim != 3) {
    3901           0 :                                 throw ConversionException("Error: Field \"" + 
    3902           0 :                                         name + "\": Invalid array format", tableName);
    3903             :                         }
    3904           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    3905           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    3906           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    3907           0 :                         vector< vector< vector<ArrayTime> > > value ;
    3908           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    3909           0 :                                 return value;
    3910             :                         
    3911           0 :                         vector<vector<ArrayTime> > vv_aux;
    3912           0 :                         vector<ArrayTime> v_aux;
    3913           0 :                         for (int i = 0; i < dim0; ++i) {
    3914           0 :                                 vv_aux.clear();
    3915           0 :                                 for (int j = 0; j < dim1; ++j) {
    3916           0 :                                         v_aux.clear();
    3917           0 :                                         for (int k = 0; k < dim2; ++k) {
    3918             :         
    3919           0 :                                                 v_aux.push_back(ArrayTime::getArrayTime(t));
    3920             :         
    3921             :                                         }
    3922           0 :                                         vv_aux.push_back(v_aux);
    3923             :                                 }
    3924           0 :                                 value.push_back(vv_aux);
    3925             :                         }
    3926           0 :                         if (t.hasMoreTokens()) {
    3927           0 :                                 throw ConversionException("Error: Field \"" + 
    3928           0 :                                         name + "\": Syntax error.", tableName);
    3929             :                         }
    3930           0 :                         return value;
    3931           0 :                 } catch (const NumberFormatException &e) {
    3932           0 :                         throw ConversionException("Error: Field \"" + 
    3933           0 :                                 name + "\": " + e.getMessage(), tableName);
    3934           0 :                 } catch (const OutOfBoundsException &e) {
    3935           0 :                         throw  ConversionException("Error: Field \"" + 
    3936           0 :                                 name + "\": Unexpected end of string", tableName);
    3937           0 :                 } catch (const TagFormatException &e) {
    3938           0 :                         throw ConversionException("Error: Field \"" + 
    3939           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3940           0 :                 }               
    3941           0 :         }
    3942             :         
    3943           0 :         vector< vector< vector< vector<ArrayTime> > > >Parser::get4DArrayTime(const string &name, const string &tableName, const string &xmlDoc)
    3944             :         {
    3945           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    3946           0 :                 if (xmlField.length() == 0) {
    3947           0 :                         throw ConversionException("Error: Field \"" + 
    3948           0 :                                         name + "\": Invalid XML syntax", tableName);
    3949             :                 }
    3950           0 :                 StringTokenizer t(xmlField," ");
    3951             :                 try {
    3952           0 :                         int ndim = Integer::parseInt(t.nextToken());
    3953           0 :                         if (ndim != 4) {
    3954           0 :                                 throw ConversionException("Error: Field \"" + 
    3955           0 :                                         name + "\": Invalid array format", tableName);
    3956             :                         }
    3957           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    3958           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    3959           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    3960           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    3961           0 :                         vector<vector< vector< vector<ArrayTime> > > >value;
    3962           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    3963           0 :                                 return value;
    3964             :                         
    3965           0 :                         vector<vector<vector<ArrayTime> > >vvv_aux;
    3966           0 :                         vector<vector< ArrayTime> > vv_aux;
    3967           0 :                         vector<ArrayTime> v_aux;
    3968           0 :                         for (int i = 0; i < dim0; ++i) {
    3969           0 :                                 vvv_aux.clear();
    3970           0 :                                 for (int j = 0; j < dim1; ++j) {
    3971           0 :                                         vv_aux.clear();
    3972           0 :                                         for (int k = 0; k < dim2; ++k) {
    3973           0 :                                                 v_aux.clear();
    3974           0 :                                                 for (int l = 0; l < dim3; l++) {
    3975             :         
    3976           0 :                                                         v_aux.push_back(ArrayTime::getArrayTime(t));
    3977             :         
    3978             :                                                 }
    3979           0 :                                                 vv_aux.push_back(v_aux);
    3980             :                                         }
    3981           0 :                                         vvv_aux.push_back(vv_aux);
    3982             :                                 }
    3983           0 :                                 value.push_back(vvv_aux);
    3984             :                         }
    3985           0 :                         if (t.hasMoreTokens()) {
    3986           0 :                                 throw ConversionException("Error: Field \"" + 
    3987           0 :                                         name + "\": Syntax error.", tableName);
    3988             :                         }
    3989           0 :                         return value;
    3990           0 :                 } catch (const NumberFormatException &e) {
    3991           0 :                         throw ConversionException("Error: Field \"" + 
    3992           0 :                                 name + "\": " + e.getMessage(), tableName);
    3993           0 :                 } catch (const OutOfBoundsException &e) {
    3994           0 :                         throw  ConversionException("Error: Field \"" + 
    3995           0 :                                 name + "\": Unexpected end of string", tableName);
    3996           0 :                 } catch (const TagFormatException &e) {
    3997           0 :                         throw ConversionException("Error: Field \"" + 
    3998           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    3999           0 :                 }               
    4000           0 :         }       
    4001             :         
    4002             : 
    4003             :                 
    4004             : 
    4005             : 
    4006             :         // Field type: ArrayTimeInterval
    4007             : 
    4008        1478 :         void Parser::toXML(ArrayTimeInterval data, const string &name, string &buf) {
    4009        1478 :                 buf.append("<" + name + "> ");
    4010             :         
    4011             :                 //buf.append(data.getStart().toString()+" "+data.getDuration().toString());   
    4012        1478 :                 buf.append(data.getMidPoint().toString()+" "+data.getDuration().toString());
    4013             :                 
    4014        1478 :                 buf.append(" </" + name + "> ");
    4015        1478 :         }
    4016             : 
    4017             :         
    4018             :         
    4019             :         
    4020           0 :         void Parser::toXML(vector<ArrayTimeInterval> data, const string &name, string &buf) {
    4021           0 :                 buf.append("<" + name + "> ");
    4022           0 :                 buf.append("1 ");
    4023           0 :                 buf.append(Integer::toString(data.size()));
    4024           0 :                 buf.append(" ");
    4025           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4026             :         
    4027             :                 //buf.append(data[i].getStart().toString()+" "+data[i].getDuration().toString()+" ");       
    4028           0 :                 buf.append(data[i].getMidPoint().toString()+" "+data[i].getDuration().toString()+" ");      
    4029             :                 
    4030           0 :                         buf.append(" ");
    4031             :                 }
    4032           0 :                 buf.append(" </" + name + "> ");
    4033           0 :         }
    4034             : 
    4035           0 :         void Parser::toXML(vector< vector<ArrayTimeInterval> > data, const string &name, string &buf) {
    4036           0 :                 buf.append("<" + name + "> ");
    4037           0 :                 buf.append("2 ");
    4038           0 :                 buf.append(Integer::toString(data.size()));
    4039           0 :                 buf.append(" ");
    4040           0 :                 buf.append(Integer::toString(data[0].size()));
    4041           0 :                 buf.append(" ");
    4042           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4043           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    4044             :         
    4045             :                                 //buf.append(data[i][j].getStart().toString()+" "+data[i][j].getDuration().toString()+" "); 
    4046           0 :                                 buf.append(data[i][j].getMidPoint().toString()+" "+data[i][j].getDuration().toString()+" ");                                
    4047             :                 
    4048           0 :                                 buf.append(" ");
    4049             :                         }
    4050             :                 }
    4051           0 :                 buf.append(" </" + name + "> ");
    4052           0 :         }
    4053             :         
    4054           0 :         void Parser::toXML(vector< vector< vector<ArrayTimeInterval> > > data, const string &name, string &buf) {
    4055           0 :                 buf.append("<" + name + "> ");
    4056           0 :                 buf.append("3 ");
    4057           0 :                 buf.append(Integer::toString(data.size()));
    4058           0 :                 buf.append(" ");
    4059           0 :                 buf.append(Integer::toString(data[0].size()));
    4060           0 :                 buf.append(" ");
    4061           0 :                 buf.append(Integer::toString(data[0][0].size()));
    4062           0 :                 buf.append(" ");
    4063           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4064           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    4065           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    4066             :         
    4067             :                                         //buf.append(data[i][j][k].getStart().toString()+" "+data[i][j][k].getDuration().toString()+" ");   
    4068           0 :                                         buf.append(data[i][j][k].getMidPoint().toString()+" "+data[i][j][k].getDuration().toString()+" ");  
    4069             :                 
    4070           0 :                                         buf.append(" ");
    4071             :                                 }
    4072             :                         }
    4073             :                 }
    4074           0 :                 buf.append(" </" + name + "> ");
    4075           0 :         }
    4076             :         
    4077           0 :         void Parser::toXML(vector<vector< vector< vector<ArrayTimeInterval> > > >data, const string &name, string &buf) {
    4078           0 :                 buf.append("<" + name + "> ");
    4079           0 :                 buf.append("4 ");
    4080           0 :                 buf.append(Integer::toString(data.size()));
    4081           0 :                 buf.append(" ");
    4082           0 :                 buf.append(Integer::toString(data[0].size()));
    4083           0 :                 buf.append(" ");
    4084           0 :                 buf.append(Integer::toString(data[0][0].size()));
    4085           0 :                 buf.append(" ");
    4086           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    4087           0 :                 buf.append(" ");
    4088           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4089           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    4090           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    4091           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    4092             :         
    4093             :                                                 //buf.append(data[i][j][k][l].getStart().toString()+" "+data[i][j][k][l].getDuration().toString()+" ");
    4094           0 :                                                 buf.append(data[i][j][k][l].getMidPoint().toString()+" "+data[i][j][k][l].getDuration().toString()+" ");            
    4095             :                 
    4096           0 :                                                 buf.append(" ");
    4097             :                                         }
    4098             :                                 }
    4099             :                         }
    4100             :                 }
    4101           0 :                 buf.append(" </" + name + "> ");
    4102           0 :         }       
    4103             :         
    4104             :                 
    4105             : 
    4106             :         
    4107             :                 
    4108             :         
    4109      143411 :         ArrayTimeInterval Parser::getArrayTimeInterval(const string &name, const string &tableName, const string &xmlDoc) 
    4110             :         {
    4111      143411 :                 string xmlField = Parser::getField(xmlDoc,name);
    4112      143411 :                 if (xmlField.length() == 0)
    4113           0 :                         throw ConversionException("Error: Missing field \"" + 
    4114           0 :                                 name + "\" or invalid syntax",tableName);
    4115             :         
    4116      286822 :                 StringTokenizer t(xmlField," ");
    4117             :                 //int64_t start = Long::parseLong(t.nextToken());
    4118      143411 :                 int64_t l1 = Long::parseLong(t.nextToken());
    4119      143411 :                 int64_t l2 = Long::parseLong(t.nextToken());
    4120      143411 :                 if ( ArrayTimeInterval::readStartTimeDurationInXML() ) 
    4121          24 :                         return ArrayTimeInterval (l1, l2);
    4122             :                 else 
    4123      143387 :                         return ArrayTimeInterval (l1 - l2 / 2, l2);
    4124             :                 
    4125      143411 :         }
    4126             : 
    4127           0 :         vector<ArrayTimeInterval> Parser::get1DArrayTimeInterval(const string &name, const string &tableName, const string &xmlDoc)
    4128             :         {
    4129           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4130           0 :                 if (xmlField.length() == 0) {
    4131           0 :                         throw ConversionException("Error: Field \"" + 
    4132           0 :                                         name + "\": Invalid XML syntax", tableName);
    4133             :                 }
    4134           0 :                 StringTokenizer t(xmlField," ");
    4135             :                 try {
    4136           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4137           0 :                         if (ndim != 1) {
    4138           0 :                                 throw ConversionException("Error: Field \"" + 
    4139           0 :                                         name + "\": Invalid array format", tableName);
    4140             :                         }
    4141           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4142           0 :                         vector<ArrayTimeInterval> value (dim0);
    4143           0 :                         if (dim0 == 0)
    4144           0 :                                 return value;
    4145           0 :                         for (int i = 0; i < dim0; ++i) {
    4146             :         
    4147           0 :                                 int64_t l1 = Long::parseLong(t.nextToken());
    4148           0 :                                 int64_t l2 = Long::parseLong(t.nextToken());
    4149           0 :                                 if ( ArrayTimeInterval::readStartTimeDurationInXML() ) 
    4150           0 :                                         value[i] = ArrayTimeInterval (l1, l2);
    4151             :                                 else 
    4152           0 :                                         value[i] = ArrayTimeInterval (l1 - l2 / 2, l2);
    4153             : 
    4154             :         
    4155             :                         }
    4156           0 :                         if (t.hasMoreTokens()) {
    4157           0 :                                 throw ConversionException("Error: Field \"" + 
    4158           0 :                                         name + "\": Syntax error.", tableName);
    4159             :                         }
    4160           0 :                         return value;
    4161           0 :                 } catch (const NumberFormatException &e) {
    4162           0 :                         throw ConversionException("Error: Field \"" + 
    4163           0 :                                 name + "\": " + e.getMessage(), tableName);
    4164           0 :                 } catch (const OutOfBoundsException &e) {
    4165           0 :                         throw  ConversionException("Error: Field \"" + 
    4166           0 :                                 name + "\": Unexpected end of string", tableName);
    4167           0 :                 } catch (const TagFormatException &e) {
    4168           0 :                         throw ConversionException("Error: Field \"" + 
    4169           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4170           0 :                 }               
    4171           0 :         }
    4172             :                 
    4173           0 :         vector< vector<ArrayTimeInterval> > Parser::get2DArrayTimeInterval(const string &name, const string &tableName, const string &xmlDoc)
    4174             :         {
    4175           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4176           0 :                 if (xmlField.length() == 0) {
    4177           0 :                         throw ConversionException("Error: Field \"" + 
    4178           0 :                                         name + "\": Invalid XML syntax", tableName);
    4179             :                 }
    4180           0 :                 StringTokenizer t(xmlField," ");
    4181             :                 try {
    4182           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4183           0 :                         if (ndim != 2) {
    4184           0 :                                 throw ConversionException("Error: Field \"" + 
    4185           0 :                                         name + "\": Invalid array format", tableName);
    4186             :                         }
    4187           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4188           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    4189           0 :                         vector< vector<ArrayTimeInterval> > value;
    4190             : 
    4191           0 :                         if (dim0 == 0 || dim1 == 0)
    4192           0 :                                 return value;
    4193             : 
    4194           0 :                         vector<ArrayTimeInterval> v_aux;
    4195           0 :                         for (int i = 0; i < dim0; ++i) {
    4196           0 :                                 v_aux.clear();
    4197           0 :                                 for (int j = 0; j < dim1; ++j) {
    4198             :         
    4199           0 :                                         int64_t l1 = Long::parseLong(t.nextToken());
    4200           0 :                                         int64_t l2 = Long::parseLong(t.nextToken());
    4201           0 :                                         if ( ArrayTimeInterval::readStartTimeDurationInXML() ) 
    4202           0 :                                                 v_aux.push_back(ArrayTimeInterval (l1, l2));
    4203             :                                         else 
    4204           0 :                                                 v_aux.push_back(ArrayTimeInterval (l1 - l2 / 2, l2));
    4205             :                                                                                         
    4206             :         
    4207             :                                 }
    4208           0 :                                 value.push_back(v_aux);
    4209             :                         }
    4210           0 :                         if (t.hasMoreTokens()) {
    4211           0 :                                 throw ConversionException("Error: Field \"" + 
    4212           0 :                                         name + "\": Syntax error.", tableName);
    4213             :                         }
    4214           0 :                         return value;
    4215           0 :                 } catch (const NumberFormatException &e) {
    4216           0 :                         throw ConversionException("Error: Field \"" + 
    4217           0 :                                 name + "\": " + e.getMessage(), tableName);
    4218           0 :                 } catch (const OutOfBoundsException &e) {
    4219           0 :                         throw  ConversionException("Error: Field \"" + 
    4220           0 :                                 name + "\": Unexpected end of string", tableName);
    4221           0 :                 } catch (const TagFormatException &e) {
    4222           0 :                         throw ConversionException("Error: Field \"" + 
    4223           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4224           0 :                 }               
    4225           0 :         }       
    4226             :         
    4227           0 :         vector< vector< vector<ArrayTimeInterval> > > Parser::get3DArrayTimeInterval(const string &name, const string &tableName, const string &xmlDoc)
    4228             :         {
    4229           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4230           0 :                 if (xmlField.length() == 0) {
    4231           0 :                         throw ConversionException("Error: Field \"" + 
    4232           0 :                                         name + "\": Invalid XML syntax", tableName);
    4233             :                 }
    4234           0 :                 StringTokenizer t(xmlField," ");
    4235             :                 try {
    4236           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4237           0 :                         if (ndim != 3) {
    4238           0 :                                 throw ConversionException("Error: Field \"" + 
    4239           0 :                                         name + "\": Invalid array format", tableName);
    4240             :                         }
    4241           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4242           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    4243           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    4244           0 :                         vector< vector< vector<ArrayTimeInterval> > > value ;
    4245           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    4246           0 :                                 return value;
    4247             :                         
    4248           0 :                         vector<vector<ArrayTimeInterval> > vv_aux;
    4249           0 :                         vector<ArrayTimeInterval> v_aux;
    4250           0 :                         for (int i = 0; i < dim0; ++i) {
    4251           0 :                                 vv_aux.clear();
    4252           0 :                                 for (int j = 0; j < dim1; ++j) {
    4253           0 :                                         v_aux.clear();
    4254           0 :                                         for (int k = 0; k < dim2; ++k) {
    4255             :         
    4256           0 :                                                 int64_t l1 = Long::parseLong(t.nextToken());
    4257           0 :                                                 int64_t l2 = Long::parseLong(t.nextToken());
    4258           0 :                                                 if ( ArrayTimeInterval::readStartTimeDurationInXML() ) 
    4259           0 :                                                         v_aux.push_back(ArrayTimeInterval (l1, l2));
    4260             :                                                 else 
    4261           0 :                                                         v_aux.push_back(ArrayTimeInterval (l1 - l2 / 2, l2));                                           
    4262             :         
    4263             :                                         }
    4264           0 :                                         vv_aux.push_back(v_aux);
    4265             :                                 }
    4266           0 :                                 value.push_back(vv_aux);
    4267             :                         }
    4268           0 :                         if (t.hasMoreTokens()) {
    4269           0 :                                 throw ConversionException("Error: Field \"" + 
    4270           0 :                                         name + "\": Syntax error.", tableName);
    4271             :                         }
    4272           0 :                         return value;
    4273           0 :                 } catch (const NumberFormatException &e) {
    4274           0 :                         throw ConversionException("Error: Field \"" + 
    4275           0 :                                 name + "\": " + e.getMessage(), tableName);
    4276           0 :                 } catch (const OutOfBoundsException &e) {
    4277           0 :                         throw  ConversionException("Error: Field \"" + 
    4278           0 :                                 name + "\": Unexpected end of string", tableName);
    4279           0 :                 } catch (const TagFormatException &e) {
    4280           0 :                         throw ConversionException("Error: Field \"" + 
    4281           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4282           0 :                 }               
    4283           0 :         }
    4284             :         
    4285           0 :         vector< vector< vector< vector<ArrayTimeInterval> > > >Parser::get4DArrayTimeInterval(const string &name, const string &tableName, const string &xmlDoc)
    4286             :         {
    4287           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4288           0 :                 if (xmlField.length() == 0) {
    4289           0 :                         throw ConversionException("Error: Field \"" + 
    4290           0 :                                         name + "\": Invalid XML syntax", tableName);
    4291             :                 }
    4292           0 :                 StringTokenizer t(xmlField," ");
    4293             :                 try {
    4294           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4295           0 :                         if (ndim != 4) {
    4296           0 :                                 throw ConversionException("Error: Field \"" + 
    4297           0 :                                         name + "\": Invalid array format", tableName);
    4298             :                         }
    4299           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4300           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    4301           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    4302           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    4303           0 :                         vector<vector< vector< vector<ArrayTimeInterval> > > >value;
    4304           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    4305           0 :                                 return value;
    4306             :                         
    4307           0 :                         vector<vector<vector<ArrayTimeInterval> > >vvv_aux;
    4308           0 :                         vector<vector< ArrayTimeInterval> > vv_aux;
    4309           0 :                         vector<ArrayTimeInterval> v_aux;
    4310           0 :                         for (int i = 0; i < dim0; ++i) {
    4311           0 :                                 vvv_aux.clear();
    4312           0 :                                 for (int j = 0; j < dim1; ++j) {
    4313           0 :                                         vv_aux.clear();
    4314           0 :                                         for (int k = 0; k < dim2; ++k) {
    4315           0 :                                                 v_aux.clear();
    4316           0 :                                                 for (int l = 0; l < dim3; l++) {
    4317             :         
    4318           0 :                                                         int64_t l1 = Long::parseLong(t.nextToken());
    4319           0 :                                                         int64_t l2 = Long::parseLong(t.nextToken());
    4320           0 :                                                         if ( ArrayTimeInterval::readStartTimeDurationInXML() ) 
    4321           0 :                                                                 v_aux.push_back(ArrayTimeInterval (l1, l2));
    4322             :                                                         else 
    4323           0 :                                                                 v_aux.push_back(ArrayTimeInterval (l1 - l2 / 2, l2));   
    4324             :         
    4325             :                                                 }
    4326           0 :                                                 vv_aux.push_back(v_aux);
    4327             :                                         }
    4328           0 :                                         vvv_aux.push_back(vv_aux);
    4329             :                                 }
    4330           0 :                                 value.push_back(vvv_aux);
    4331             :                         }
    4332           0 :                         if (t.hasMoreTokens()) {
    4333           0 :                                 throw ConversionException("Error: Field \"" + 
    4334           0 :                                         name + "\": Syntax error.", tableName);
    4335             :                         }
    4336           0 :                         return value;
    4337           0 :                 } catch (const NumberFormatException &e) {
    4338           0 :                         throw ConversionException("Error: Field \"" + 
    4339           0 :                                 name + "\": " + e.getMessage(), tableName);
    4340           0 :                 } catch (const OutOfBoundsException &e) {
    4341           0 :                         throw  ConversionException("Error: Field \"" + 
    4342           0 :                                 name + "\": Unexpected end of string", tableName);
    4343           0 :                 } catch (const TagFormatException &e) {
    4344           0 :                         throw ConversionException("Error: Field \"" + 
    4345           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4346           0 :                 }               
    4347           0 :         }       
    4348             :         
    4349             : 
    4350             :                 
    4351             : 
    4352             : 
    4353             :         // Field type: Complex
    4354             : 
    4355           0 :         void Parser::toXML(Complex data, const string &name, string &buf) {
    4356           0 :                 buf.append("<" + name + "> ");
    4357             :         
    4358           0 :                 buf.append(data.toString());
    4359             :                 
    4360           0 :                 buf.append(" </" + name + "> ");
    4361           0 :         }
    4362             : 
    4363             :         
    4364             :         
    4365             :         
    4366           0 :         void Parser::toXML(vector<Complex> data, const string &name, string &buf) {
    4367           0 :                 buf.append("<" + name + "> ");
    4368           0 :                 buf.append("1 ");
    4369           0 :                 buf.append(Integer::toString(data.size()));
    4370           0 :                 buf.append(" ");
    4371           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4372             :         
    4373           0 :                         buf.append(data[i].toString());
    4374             :                 
    4375           0 :                         buf.append(" ");
    4376             :                 }
    4377           0 :                 buf.append(" </" + name + "> ");
    4378           0 :         }
    4379             : 
    4380         896 :         void Parser::toXML(vector< vector<Complex> > data, const string &name, string &buf) {
    4381         896 :                 buf.append("<" + name + "> ");
    4382         896 :                 buf.append("2 ");
    4383         896 :                 buf.append(Integer::toString(data.size()));
    4384         896 :                 buf.append(" ");
    4385         896 :                 buf.append(Integer::toString(data[0].size()));
    4386         896 :                 buf.append(" ");
    4387        2688 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4388        5376 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    4389             :         
    4390        3584 :                                 buf.append(data[i][j].toString());
    4391             :                 
    4392        3584 :                                 buf.append(" ");
    4393             :                         }
    4394             :                 }
    4395         896 :                 buf.append(" </" + name + "> ");
    4396         896 :         }
    4397             :         
    4398           0 :         void Parser::toXML(vector< vector< vector<Complex> > > data, const string &name, string &buf) {
    4399           0 :                 buf.append("<" + name + "> ");
    4400           0 :                 buf.append("3 ");
    4401           0 :                 buf.append(Integer::toString(data.size()));
    4402           0 :                 buf.append(" ");
    4403           0 :                 buf.append(Integer::toString(data[0].size()));
    4404           0 :                 buf.append(" ");
    4405           0 :                 buf.append(Integer::toString(data[0][0].size()));
    4406           0 :                 buf.append(" ");
    4407           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4408           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    4409           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    4410             :         
    4411           0 :                                         buf.append(data[i][j][k].toString());
    4412             :                 
    4413           0 :                                         buf.append(" ");
    4414             :                                 }
    4415             :                         }
    4416             :                 }
    4417           0 :                 buf.append(" </" + name + "> ");
    4418           0 :         }
    4419             :         
    4420           0 :         void Parser::toXML(vector<vector< vector< vector<Complex> > > >data, const string &name, string &buf) {
    4421           0 :                 buf.append("<" + name + "> ");
    4422           0 :                 buf.append("4 ");
    4423           0 :                 buf.append(Integer::toString(data.size()));
    4424           0 :                 buf.append(" ");
    4425           0 :                 buf.append(Integer::toString(data[0].size()));
    4426           0 :                 buf.append(" ");
    4427           0 :                 buf.append(Integer::toString(data[0][0].size()));
    4428           0 :                 buf.append(" ");
    4429           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    4430           0 :                 buf.append(" ");
    4431           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4432           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    4433           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    4434           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    4435             :         
    4436           0 :                                                 buf.append(data[i][j][k][l].toString());
    4437             :                 
    4438           0 :                                                 buf.append(" ");
    4439             :                                         }
    4440             :                                 }
    4441             :                         }
    4442             :                 }
    4443           0 :                 buf.append(" </" + name + "> ");
    4444           0 :         }       
    4445             :         
    4446             :                 
    4447             : 
    4448             :         
    4449             :                 
    4450             :         
    4451           0 :         Complex Parser::getComplex(const string &name, const string &tableName, const string &xmlDoc) 
    4452             :         {
    4453           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4454           0 :                 if (xmlField.length() == 0)
    4455           0 :                         throw ConversionException("Error: Missing field \"" + 
    4456           0 :                                 name + "\" or invalid syntax",tableName);
    4457             :         
    4458             :         try {   
    4459           0 :                         return Complex (xmlField);
    4460             :                 }
    4461           0 :                 catch (const InvalidArgumentException &e) {
    4462           0 :                         throw ConversionException("Error: message was '"+ 
    4463           0 :                                                    e.getMessage()+
    4464             :                                                    "'",
    4465           0 :                                                    tableName);
    4466           0 :                 }
    4467             :                 
    4468           0 :         }
    4469             : 
    4470           0 :         vector<Complex> Parser::get1DComplex(const string &name, const string &tableName, const string &xmlDoc)
    4471             :         {
    4472           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4473           0 :                 if (xmlField.length() == 0) {
    4474           0 :                         throw ConversionException("Error: Field \"" + 
    4475           0 :                                         name + "\": Invalid XML syntax", tableName);
    4476             :                 }
    4477           0 :                 StringTokenizer t(xmlField," ");
    4478             :                 try {
    4479           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4480           0 :                         if (ndim != 1) {
    4481           0 :                                 throw ConversionException("Error: Field \"" + 
    4482           0 :                                         name + "\": Invalid array format", tableName);
    4483             :                         }
    4484           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4485           0 :                         vector<Complex> value (dim0);
    4486           0 :                         if (dim0 == 0)
    4487           0 :                                 return value;
    4488           0 :                         for (int i = 0; i < dim0; ++i) {
    4489             :         
    4490           0 :                                 value[i] = Complex::getComplex(t);
    4491             :         
    4492             :                         }
    4493           0 :                         if (t.hasMoreTokens()) {
    4494           0 :                                 throw ConversionException("Error: Field \"" + 
    4495           0 :                                         name + "\": Syntax error.", tableName);
    4496             :                         }
    4497           0 :                         return value;
    4498           0 :                 } catch (const NumberFormatException &e) {
    4499           0 :                         throw ConversionException("Error: Field \"" + 
    4500           0 :                                 name + "\": " + e.getMessage(), tableName);
    4501           0 :                 } catch (const OutOfBoundsException &e) {
    4502           0 :                         throw  ConversionException("Error: Field \"" + 
    4503           0 :                                 name + "\": Unexpected end of string", tableName);
    4504           0 :                 } catch (const TagFormatException &e) {
    4505           0 :                         throw ConversionException("Error: Field \"" + 
    4506           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4507           0 :                 }               
    4508           0 :         }
    4509             :                 
    4510       67308 :         vector< vector<Complex> > Parser::get2DComplex(const string &name, const string &tableName, const string &xmlDoc)
    4511             :         {
    4512       67308 :                 string xmlField = Parser::getField(xmlDoc,name);
    4513       67308 :                 if (xmlField.length() == 0) {
    4514           0 :                         throw ConversionException("Error: Field \"" + 
    4515           0 :                                         name + "\": Invalid XML syntax", tableName);
    4516             :                 }
    4517      134616 :                 StringTokenizer t(xmlField," ");
    4518             :                 try {
    4519       67308 :                         int ndim = Integer::parseInt(t.nextToken());
    4520       67308 :                         if (ndim != 2) {
    4521           0 :                                 throw ConversionException("Error: Field \"" + 
    4522           0 :                                         name + "\": Invalid array format", tableName);
    4523             :                         }
    4524       67308 :                         int dim0 = Integer::parseInt(t.nextToken());
    4525       67308 :                         int dim1 = Integer::parseInt(t.nextToken());
    4526       67308 :                         vector< vector<Complex> > value;
    4527             : 
    4528       67308 :                         if (dim0 == 0 || dim1 == 0)
    4529           0 :                                 return value;
    4530             : 
    4531       67308 :                         vector<Complex> v_aux;
    4532      201908 :                         for (int i = 0; i < dim0; ++i) {
    4533      134600 :                                 v_aux.clear();
    4534      403784 :                                 for (int j = 0; j < dim1; ++j) {
    4535             :         
    4536      269184 :                                         v_aux.push_back(Complex::getComplex(t));
    4537             :         
    4538             :                                 }
    4539      134600 :                                 value.push_back(v_aux);
    4540             :                         }
    4541       67308 :                         if (t.hasMoreTokens()) {
    4542           0 :                                 throw ConversionException("Error: Field \"" + 
    4543           0 :                                         name + "\": Syntax error.", tableName);
    4544             :                         }
    4545       67308 :                         return value;
    4546       67308 :                 } catch (const NumberFormatException &e) {
    4547           0 :                         throw ConversionException("Error: Field \"" + 
    4548           0 :                                 name + "\": " + e.getMessage(), tableName);
    4549           0 :                 } catch (const OutOfBoundsException &e) {
    4550           0 :                         throw  ConversionException("Error: Field \"" + 
    4551           0 :                                 name + "\": Unexpected end of string", tableName);
    4552           0 :                 } catch (const TagFormatException &e) {
    4553           0 :                         throw ConversionException("Error: Field \"" + 
    4554           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4555           0 :                 }               
    4556       67308 :         }       
    4557             :         
    4558           0 :         vector< vector< vector<Complex> > > Parser::get3DComplex(const string &name, const string &tableName, const string &xmlDoc)
    4559             :         {
    4560           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4561           0 :                 if (xmlField.length() == 0) {
    4562           0 :                         throw ConversionException("Error: Field \"" + 
    4563           0 :                                         name + "\": Invalid XML syntax", tableName);
    4564             :                 }
    4565           0 :                 StringTokenizer t(xmlField," ");
    4566             :                 try {
    4567           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4568           0 :                         if (ndim != 3) {
    4569           0 :                                 throw ConversionException("Error: Field \"" + 
    4570           0 :                                         name + "\": Invalid array format", tableName);
    4571             :                         }
    4572           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4573           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    4574           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    4575           0 :                         vector< vector< vector<Complex> > > value ;
    4576           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    4577           0 :                                 return value;
    4578             :                         
    4579           0 :                         vector<vector<Complex> > vv_aux;
    4580           0 :                         vector<Complex> v_aux;
    4581           0 :                         for (int i = 0; i < dim0; ++i) {
    4582           0 :                                 vv_aux.clear();
    4583           0 :                                 for (int j = 0; j < dim1; ++j) {
    4584           0 :                                         v_aux.clear();
    4585           0 :                                         for (int k = 0; k < dim2; ++k) {
    4586             :         
    4587           0 :                                                 v_aux.push_back(Complex::getComplex(t));
    4588             :         
    4589             :                                         }
    4590           0 :                                         vv_aux.push_back(v_aux);
    4591             :                                 }
    4592           0 :                                 value.push_back(vv_aux);
    4593             :                         }
    4594           0 :                         if (t.hasMoreTokens()) {
    4595           0 :                                 throw ConversionException("Error: Field \"" + 
    4596           0 :                                         name + "\": Syntax error.", tableName);
    4597             :                         }
    4598           0 :                         return value;
    4599           0 :                 } catch (const NumberFormatException &e) {
    4600           0 :                         throw ConversionException("Error: Field \"" + 
    4601           0 :                                 name + "\": " + e.getMessage(), tableName);
    4602           0 :                 } catch (const OutOfBoundsException &e) {
    4603           0 :                         throw  ConversionException("Error: Field \"" + 
    4604           0 :                                 name + "\": Unexpected end of string", tableName);
    4605           0 :                 } catch (const TagFormatException &e) {
    4606           0 :                         throw ConversionException("Error: Field \"" + 
    4607           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4608           0 :                 }               
    4609           0 :         }
    4610             :         
    4611           0 :         vector< vector< vector< vector<Complex> > > >Parser::get4DComplex(const string &name, const string &tableName, const string &xmlDoc)
    4612             :         {
    4613           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4614           0 :                 if (xmlField.length() == 0) {
    4615           0 :                         throw ConversionException("Error: Field \"" + 
    4616           0 :                                         name + "\": Invalid XML syntax", tableName);
    4617             :                 }
    4618           0 :                 StringTokenizer t(xmlField," ");
    4619             :                 try {
    4620           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4621           0 :                         if (ndim != 4) {
    4622           0 :                                 throw ConversionException("Error: Field \"" + 
    4623           0 :                                         name + "\": Invalid array format", tableName);
    4624             :                         }
    4625           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4626           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    4627           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    4628           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    4629           0 :                         vector<vector< vector< vector<Complex> > > >value;
    4630           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    4631           0 :                                 return value;
    4632             :                         
    4633           0 :                         vector<vector<vector<Complex> > >vvv_aux;
    4634           0 :                         vector<vector< Complex> > vv_aux;
    4635           0 :                         vector<Complex> v_aux;
    4636           0 :                         for (int i = 0; i < dim0; ++i) {
    4637           0 :                                 vvv_aux.clear();
    4638           0 :                                 for (int j = 0; j < dim1; ++j) {
    4639           0 :                                         vv_aux.clear();
    4640           0 :                                         for (int k = 0; k < dim2; ++k) {
    4641           0 :                                                 v_aux.clear();
    4642           0 :                                                 for (int l = 0; l < dim3; l++) {
    4643             :         
    4644           0 :                                                         v_aux.push_back(Complex::getComplex(t));
    4645             :         
    4646             :                                                 }
    4647           0 :                                                 vv_aux.push_back(v_aux);
    4648             :                                         }
    4649           0 :                                         vvv_aux.push_back(vv_aux);
    4650             :                                 }
    4651           0 :                                 value.push_back(vvv_aux);
    4652             :                         }
    4653           0 :                         if (t.hasMoreTokens()) {
    4654           0 :                                 throw ConversionException("Error: Field \"" + 
    4655           0 :                                         name + "\": Syntax error.", tableName);
    4656             :                         }
    4657           0 :                         return value;
    4658           0 :                 } catch (const NumberFormatException &e) {
    4659           0 :                         throw ConversionException("Error: Field \"" + 
    4660           0 :                                 name + "\": " + e.getMessage(), tableName);
    4661           0 :                 } catch (const OutOfBoundsException &e) {
    4662           0 :                         throw  ConversionException("Error: Field \"" + 
    4663           0 :                                 name + "\": Unexpected end of string", tableName);
    4664           0 :                 } catch (const TagFormatException &e) {
    4665           0 :                         throw ConversionException("Error: Field \"" + 
    4666           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4667           0 :                 }               
    4668           0 :         }       
    4669             :         
    4670             : 
    4671             :                 
    4672             : 
    4673             : 
    4674             :         // Field type: Entity
    4675             : 
    4676           0 :         void Parser::toXML(Entity data, const string &name, string &buf) {
    4677           0 :                 buf.append("<" + name + "> ");
    4678             :         
    4679           0 :                 buf.append(data.toString());
    4680             :                 
    4681           0 :                 buf.append(" </" + name + "> ");
    4682           0 :         }
    4683             : 
    4684             :         
    4685             :         
    4686             :         
    4687           0 :         void Parser::toXML(vector<Entity> data, const string &name, string &buf) {
    4688           0 :                 buf.append("<" + name + "> ");
    4689           0 :                 buf.append("1 ");
    4690           0 :                 buf.append(Integer::toString(data.size()));
    4691           0 :                 buf.append(" ");
    4692           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4693             :         
    4694           0 :                         buf.append(data[i].toString());
    4695             :                 
    4696           0 :                         buf.append(" ");
    4697             :                 }
    4698           0 :                 buf.append(" </" + name + "> ");
    4699           0 :         }
    4700             : 
    4701           0 :         void Parser::toXML(vector< vector<Entity> > data, const string &name, string &buf) {
    4702           0 :                 buf.append("<" + name + "> ");
    4703           0 :                 buf.append("2 ");
    4704           0 :                 buf.append(Integer::toString(data.size()));
    4705           0 :                 buf.append(" ");
    4706           0 :                 buf.append(Integer::toString(data[0].size()));
    4707           0 :                 buf.append(" ");
    4708           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4709           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    4710             :         
    4711           0 :                                 buf.append(data[i][j].toString());
    4712             :                 
    4713           0 :                                 buf.append(" ");
    4714             :                         }
    4715             :                 }
    4716           0 :                 buf.append(" </" + name + "> ");
    4717           0 :         }
    4718             :         
    4719           0 :         void Parser::toXML(vector< vector< vector<Entity> > > data, const string &name, string &buf) {
    4720           0 :                 buf.append("<" + name + "> ");
    4721           0 :                 buf.append("3 ");
    4722           0 :                 buf.append(Integer::toString(data.size()));
    4723           0 :                 buf.append(" ");
    4724           0 :                 buf.append(Integer::toString(data[0].size()));
    4725           0 :                 buf.append(" ");
    4726           0 :                 buf.append(Integer::toString(data[0][0].size()));
    4727           0 :                 buf.append(" ");
    4728           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4729           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    4730           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    4731             :         
    4732           0 :                                         buf.append(data[i][j][k].toString());
    4733             :                 
    4734           0 :                                         buf.append(" ");
    4735             :                                 }
    4736             :                         }
    4737             :                 }
    4738           0 :                 buf.append(" </" + name + "> ");
    4739           0 :         }
    4740             :         
    4741           0 :         void Parser::toXML(vector<vector< vector< vector<Entity> > > >data, const string &name, string &buf) {
    4742           0 :                 buf.append("<" + name + "> ");
    4743           0 :                 buf.append("4 ");
    4744           0 :                 buf.append(Integer::toString(data.size()));
    4745           0 :                 buf.append(" ");
    4746           0 :                 buf.append(Integer::toString(data[0].size()));
    4747           0 :                 buf.append(" ");
    4748           0 :                 buf.append(Integer::toString(data[0][0].size()));
    4749           0 :                 buf.append(" ");
    4750           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    4751           0 :                 buf.append(" ");
    4752           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    4753           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    4754           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    4755           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    4756             :         
    4757           0 :                                                 buf.append(data[i][j][k][l].toString());
    4758             :                 
    4759           0 :                                                 buf.append(" ");
    4760             :                                         }
    4761             :                                 }
    4762             :                         }
    4763             :                 }
    4764           0 :                 buf.append(" </" + name + "> ");
    4765           0 :         }       
    4766             :         
    4767             :                 
    4768             : 
    4769             :         
    4770             :                 
    4771             :         
    4772           0 :         Entity Parser::getEntity(const string &name, const string &tableName, const string &xmlDoc) 
    4773             :         {
    4774           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4775           0 :                 if (xmlField.length() == 0)
    4776           0 :                         throw ConversionException("Error: Missing field \"" + 
    4777           0 :                                 name + "\" or invalid syntax",tableName);
    4778             :         
    4779             :         try {   
    4780           0 :                         return Entity (xmlField);
    4781             :                 }
    4782           0 :                 catch (const InvalidArgumentException &e) {
    4783           0 :                         throw ConversionException("Error: message was '"+ 
    4784           0 :                                                    e.getMessage()+
    4785             :                                                    "'",
    4786           0 :                                                    tableName);
    4787           0 :                 }
    4788             :                 
    4789           0 :         }
    4790             : 
    4791           0 :         vector<Entity> Parser::get1DEntity(const string &name, const string &tableName, const string &xmlDoc)
    4792             :         {
    4793           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4794           0 :                 if (xmlField.length() == 0) {
    4795           0 :                         throw ConversionException("Error: Field \"" + 
    4796           0 :                                         name + "\": Invalid XML syntax", tableName);
    4797             :                 }
    4798           0 :                 StringTokenizer t(xmlField," ");
    4799             :                 try {
    4800           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4801           0 :                         if (ndim != 1) {
    4802           0 :                                 throw ConversionException("Error: Field \"" + 
    4803           0 :                                         name + "\": Invalid array format", tableName);
    4804             :                         }
    4805           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4806           0 :                         vector<Entity> value (dim0);
    4807           0 :                         if (dim0 == 0)
    4808           0 :                                 return value;
    4809           0 :                         for (int i = 0; i < dim0; ++i) {
    4810             :         
    4811           0 :                                 value[i] = Entity::getEntity(t);
    4812             :         
    4813             :                         }
    4814           0 :                         if (t.hasMoreTokens()) {
    4815           0 :                                 throw ConversionException("Error: Field \"" + 
    4816           0 :                                         name + "\": Syntax error.", tableName);
    4817             :                         }
    4818           0 :                         return value;
    4819           0 :                 } catch (const NumberFormatException &e) {
    4820           0 :                         throw ConversionException("Error: Field \"" + 
    4821           0 :                                 name + "\": " + e.getMessage(), tableName);
    4822           0 :                 } catch (const OutOfBoundsException &e) {
    4823           0 :                         throw  ConversionException("Error: Field \"" + 
    4824           0 :                                 name + "\": Unexpected end of string", tableName);
    4825           0 :                 } catch (const TagFormatException &e) {
    4826           0 :                         throw ConversionException("Error: Field \"" + 
    4827           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4828           0 :                 }               
    4829           0 :         }
    4830             :                 
    4831           0 :         vector< vector<Entity> > Parser::get2DEntity(const string &name, const string &tableName, const string &xmlDoc)
    4832             :         {
    4833           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4834           0 :                 if (xmlField.length() == 0) {
    4835           0 :                         throw ConversionException("Error: Field \"" + 
    4836           0 :                                         name + "\": Invalid XML syntax", tableName);
    4837             :                 }
    4838           0 :                 StringTokenizer t(xmlField," ");
    4839             :                 try {
    4840           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4841           0 :                         if (ndim != 2) {
    4842           0 :                                 throw ConversionException("Error: Field \"" + 
    4843           0 :                                         name + "\": Invalid array format", tableName);
    4844             :                         }
    4845           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4846           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    4847           0 :                         vector< vector<Entity> > value;
    4848             : 
    4849           0 :                         if (dim0 == 0 || dim1 == 0)
    4850           0 :                                 return value;
    4851             : 
    4852           0 :                         vector<Entity> v_aux;
    4853           0 :                         for (int i = 0; i < dim0; ++i) {
    4854           0 :                                 v_aux.clear();
    4855           0 :                                 for (int j = 0; j < dim1; ++j) {
    4856             :         
    4857           0 :                                         v_aux.push_back(Entity::getEntity(t));
    4858             :         
    4859             :                                 }
    4860           0 :                                 value.push_back(v_aux);
    4861             :                         }
    4862           0 :                         if (t.hasMoreTokens()) {
    4863           0 :                                 throw ConversionException("Error: Field \"" + 
    4864           0 :                                         name + "\": Syntax error.", tableName);
    4865             :                         }
    4866           0 :                         return value;
    4867           0 :                 } catch (const NumberFormatException &e) {
    4868           0 :                         throw ConversionException("Error: Field \"" + 
    4869           0 :                                 name + "\": " + e.getMessage(), tableName);
    4870           0 :                 } catch (const OutOfBoundsException &e) {
    4871           0 :                         throw  ConversionException("Error: Field \"" + 
    4872           0 :                                 name + "\": Unexpected end of string", tableName);
    4873           0 :                 } catch (const TagFormatException &e) {
    4874           0 :                         throw ConversionException("Error: Field \"" + 
    4875           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4876           0 :                 }               
    4877           0 :         }       
    4878             :         
    4879           0 :         vector< vector< vector<Entity> > > Parser::get3DEntity(const string &name, const string &tableName, const string &xmlDoc)
    4880             :         {
    4881           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4882           0 :                 if (xmlField.length() == 0) {
    4883           0 :                         throw ConversionException("Error: Field \"" + 
    4884           0 :                                         name + "\": Invalid XML syntax", tableName);
    4885             :                 }
    4886           0 :                 StringTokenizer t(xmlField," ");
    4887             :                 try {
    4888           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4889           0 :                         if (ndim != 3) {
    4890           0 :                                 throw ConversionException("Error: Field \"" + 
    4891           0 :                                         name + "\": Invalid array format", tableName);
    4892             :                         }
    4893           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4894           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    4895           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    4896           0 :                         vector< vector< vector<Entity> > > value ;
    4897           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    4898           0 :                                 return value;
    4899             :                         
    4900           0 :                         vector<vector<Entity> > vv_aux;
    4901           0 :                         vector<Entity> v_aux;
    4902           0 :                         for (int i = 0; i < dim0; ++i) {
    4903           0 :                                 vv_aux.clear();
    4904           0 :                                 for (int j = 0; j < dim1; ++j) {
    4905           0 :                                         v_aux.clear();
    4906           0 :                                         for (int k = 0; k < dim2; ++k) {
    4907             :         
    4908           0 :                                                 v_aux.push_back(Entity::getEntity(t));
    4909             :         
    4910             :                                         }
    4911           0 :                                         vv_aux.push_back(v_aux);
    4912             :                                 }
    4913           0 :                                 value.push_back(vv_aux);
    4914             :                         }
    4915           0 :                         if (t.hasMoreTokens()) {
    4916           0 :                                 throw ConversionException("Error: Field \"" + 
    4917           0 :                                         name + "\": Syntax error.", tableName);
    4918             :                         }
    4919           0 :                         return value;
    4920           0 :                 } catch (const NumberFormatException &e) {
    4921           0 :                         throw ConversionException("Error: Field \"" + 
    4922           0 :                                 name + "\": " + e.getMessage(), tableName);
    4923           0 :                 } catch (const OutOfBoundsException &e) {
    4924           0 :                         throw  ConversionException("Error: Field \"" + 
    4925           0 :                                 name + "\": Unexpected end of string", tableName);
    4926           0 :                 } catch (const TagFormatException &e) {
    4927           0 :                         throw ConversionException("Error: Field \"" + 
    4928           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4929           0 :                 }               
    4930           0 :         }
    4931             :         
    4932           0 :         vector< vector< vector< vector<Entity> > > >Parser::get4DEntity(const string &name, const string &tableName, const string &xmlDoc)
    4933             :         {
    4934           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    4935           0 :                 if (xmlField.length() == 0) {
    4936           0 :                         throw ConversionException("Error: Field \"" + 
    4937           0 :                                         name + "\": Invalid XML syntax", tableName);
    4938             :                 }
    4939           0 :                 StringTokenizer t(xmlField," ");
    4940             :                 try {
    4941           0 :                         int ndim = Integer::parseInt(t.nextToken());
    4942           0 :                         if (ndim != 4) {
    4943           0 :                                 throw ConversionException("Error: Field \"" + 
    4944           0 :                                         name + "\": Invalid array format", tableName);
    4945             :                         }
    4946           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    4947           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    4948           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    4949           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    4950           0 :                         vector<vector< vector< vector<Entity> > > >value;
    4951           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    4952           0 :                                 return value;
    4953             :                         
    4954           0 :                         vector<vector<vector<Entity> > >vvv_aux;
    4955           0 :                         vector<vector< Entity> > vv_aux;
    4956           0 :                         vector<Entity> v_aux;
    4957           0 :                         for (int i = 0; i < dim0; ++i) {
    4958           0 :                                 vvv_aux.clear();
    4959           0 :                                 for (int j = 0; j < dim1; ++j) {
    4960           0 :                                         vv_aux.clear();
    4961           0 :                                         for (int k = 0; k < dim2; ++k) {
    4962           0 :                                                 v_aux.clear();
    4963           0 :                                                 for (int l = 0; l < dim3; l++) {
    4964             :         
    4965           0 :                                                         v_aux.push_back(Entity::getEntity(t));
    4966             :         
    4967             :                                                 }
    4968           0 :                                                 vv_aux.push_back(v_aux);
    4969             :                                         }
    4970           0 :                                         vvv_aux.push_back(vv_aux);
    4971             :                                 }
    4972           0 :                                 value.push_back(vvv_aux);
    4973             :                         }
    4974           0 :                         if (t.hasMoreTokens()) {
    4975           0 :                                 throw ConversionException("Error: Field \"" + 
    4976           0 :                                         name + "\": Syntax error.", tableName);
    4977             :                         }
    4978           0 :                         return value;
    4979           0 :                 } catch (const NumberFormatException &e) {
    4980           0 :                         throw ConversionException("Error: Field \"" + 
    4981           0 :                                 name + "\": " + e.getMessage(), tableName);
    4982           0 :                 } catch (const OutOfBoundsException &e) {
    4983           0 :                         throw  ConversionException("Error: Field \"" + 
    4984           0 :                                 name + "\": Unexpected end of string", tableName);
    4985           0 :                 } catch (const TagFormatException &e) {
    4986           0 :                         throw ConversionException("Error: Field \"" + 
    4987           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    4988           0 :                 }               
    4989           0 :         }       
    4990             :         
    4991             : 
    4992             :                 
    4993             : 
    4994             : 
    4995             :         // Field type: EntityId
    4996             : 
    4997           0 :         void Parser::toXML(EntityId data, const string &name, string &buf) {
    4998           0 :                 buf.append("<" + name + "> ");
    4999             :         
    5000           0 :                 buf.append(data.toString());
    5001             :                 
    5002           0 :                 buf.append(" </" + name + "> ");
    5003           0 :         }
    5004             : 
    5005             :         
    5006             :         
    5007             :         
    5008           0 :         void Parser::toXML(vector<EntityId> data, const string &name, string &buf) {
    5009           0 :                 buf.append("<" + name + "> ");
    5010           0 :                 buf.append("1 ");
    5011           0 :                 buf.append(Integer::toString(data.size()));
    5012           0 :                 buf.append(" ");
    5013           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5014             :         
    5015           0 :                         buf.append(data[i].toString());
    5016             :                 
    5017           0 :                         buf.append(" ");
    5018             :                 }
    5019           0 :                 buf.append(" </" + name + "> ");
    5020           0 :         }
    5021             : 
    5022           0 :         void Parser::toXML(vector< vector<EntityId> > data, const string &name, string &buf) {
    5023           0 :                 buf.append("<" + name + "> ");
    5024           0 :                 buf.append("2 ");
    5025           0 :                 buf.append(Integer::toString(data.size()));
    5026           0 :                 buf.append(" ");
    5027           0 :                 buf.append(Integer::toString(data[0].size()));
    5028           0 :                 buf.append(" ");
    5029           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5030           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5031             :         
    5032           0 :                                 buf.append(data[i][j].toString());
    5033             :                 
    5034           0 :                                 buf.append(" ");
    5035             :                         }
    5036             :                 }
    5037           0 :                 buf.append(" </" + name + "> ");
    5038           0 :         }
    5039             :         
    5040           0 :         void Parser::toXML(vector< vector< vector<EntityId> > > data, const string &name, string &buf) {
    5041           0 :                 buf.append("<" + name + "> ");
    5042           0 :                 buf.append("3 ");
    5043           0 :                 buf.append(Integer::toString(data.size()));
    5044           0 :                 buf.append(" ");
    5045           0 :                 buf.append(Integer::toString(data[0].size()));
    5046           0 :                 buf.append(" ");
    5047           0 :                 buf.append(Integer::toString(data[0][0].size()));
    5048           0 :                 buf.append(" ");
    5049           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5050           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5051           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    5052             :         
    5053           0 :                                         buf.append(data[i][j][k].toString());
    5054             :                 
    5055           0 :                                         buf.append(" ");
    5056             :                                 }
    5057             :                         }
    5058             :                 }
    5059           0 :                 buf.append(" </" + name + "> ");
    5060           0 :         }
    5061             :         
    5062           0 :         void Parser::toXML(vector<vector< vector< vector<EntityId> > > >data, const string &name, string &buf) {
    5063           0 :                 buf.append("<" + name + "> ");
    5064           0 :                 buf.append("4 ");
    5065           0 :                 buf.append(Integer::toString(data.size()));
    5066           0 :                 buf.append(" ");
    5067           0 :                 buf.append(Integer::toString(data[0].size()));
    5068           0 :                 buf.append(" ");
    5069           0 :                 buf.append(Integer::toString(data[0][0].size()));
    5070           0 :                 buf.append(" ");
    5071           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    5072           0 :                 buf.append(" ");
    5073           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5074           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5075           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    5076           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    5077             :         
    5078           0 :                                                 buf.append(data[i][j][k][l].toString());
    5079             :                 
    5080           0 :                                                 buf.append(" ");
    5081             :                                         }
    5082             :                                 }
    5083             :                         }
    5084             :                 }
    5085           0 :                 buf.append(" </" + name + "> ");
    5086           0 :         }       
    5087             :         
    5088             :                 
    5089             : 
    5090             :         
    5091             :                 
    5092             :         
    5093           0 :         EntityId Parser::getEntityId(const string &name, const string &tableName, const string &xmlDoc) 
    5094             :         {
    5095           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5096           0 :                 if (xmlField.length() == 0)
    5097           0 :                         throw ConversionException("Error: Missing field \"" + 
    5098           0 :                                 name + "\" or invalid syntax",tableName);
    5099             :         
    5100             :         try {   
    5101           0 :                         return EntityId (xmlField);
    5102             :                 }
    5103           0 :                 catch (const InvalidArgumentException &e) {
    5104           0 :                         throw ConversionException("Error: message was '"+ 
    5105           0 :                                                    e.getMessage()+
    5106             :                                                    "'",
    5107           0 :                                                    tableName);
    5108           0 :                 }
    5109             :                 
    5110           0 :         }
    5111             : 
    5112           0 :         vector<EntityId> Parser::get1DEntityId(const string &name, const string &tableName, const string &xmlDoc)
    5113             :         {
    5114           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5115           0 :                 if (xmlField.length() == 0) {
    5116           0 :                         throw ConversionException("Error: Field \"" + 
    5117           0 :                                         name + "\": Invalid XML syntax", tableName);
    5118             :                 }
    5119           0 :                 StringTokenizer t(xmlField," ");
    5120             :                 try {
    5121           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5122           0 :                         if (ndim != 1) {
    5123           0 :                                 throw ConversionException("Error: Field \"" + 
    5124           0 :                                         name + "\": Invalid array format", tableName);
    5125             :                         }
    5126           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5127           0 :                         vector<EntityId> value (dim0);
    5128           0 :                         if (dim0 == 0)
    5129           0 :                                 return value;
    5130           0 :                         for (int i = 0; i < dim0; ++i) {
    5131             :         
    5132           0 :                                 value[i] = EntityId::getEntityId(t);
    5133             :         
    5134             :                         }
    5135           0 :                         if (t.hasMoreTokens()) {
    5136           0 :                                 throw ConversionException("Error: Field \"" + 
    5137           0 :                                         name + "\": Syntax error.", tableName);
    5138             :                         }
    5139           0 :                         return value;
    5140           0 :                 } catch (const NumberFormatException &e) {
    5141           0 :                         throw ConversionException("Error: Field \"" + 
    5142           0 :                                 name + "\": " + e.getMessage(), tableName);
    5143           0 :                 } catch (const OutOfBoundsException &e) {
    5144           0 :                         throw  ConversionException("Error: Field \"" + 
    5145           0 :                                 name + "\": Unexpected end of string", tableName);
    5146           0 :                 } catch (const TagFormatException &e) {
    5147           0 :                         throw ConversionException("Error: Field \"" + 
    5148           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5149           0 :                 }               
    5150           0 :         }
    5151             :                 
    5152           0 :         vector< vector<EntityId> > Parser::get2DEntityId(const string &name, const string &tableName, const string &xmlDoc)
    5153             :         {
    5154           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5155           0 :                 if (xmlField.length() == 0) {
    5156           0 :                         throw ConversionException("Error: Field \"" + 
    5157           0 :                                         name + "\": Invalid XML syntax", tableName);
    5158             :                 }
    5159           0 :                 StringTokenizer t(xmlField," ");
    5160             :                 try {
    5161           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5162           0 :                         if (ndim != 2) {
    5163           0 :                                 throw ConversionException("Error: Field \"" + 
    5164           0 :                                         name + "\": Invalid array format", tableName);
    5165             :                         }
    5166           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5167           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    5168           0 :                         vector< vector<EntityId> > value;
    5169             : 
    5170           0 :                         if (dim0 == 0 || dim1 == 0)
    5171           0 :                                 return value;
    5172             : 
    5173           0 :                         vector<EntityId> v_aux;
    5174           0 :                         for (int i = 0; i < dim0; ++i) {
    5175           0 :                                 v_aux.clear();
    5176           0 :                                 for (int j = 0; j < dim1; ++j) {
    5177             :         
    5178           0 :                                         v_aux.push_back(EntityId::getEntityId(t));
    5179             :         
    5180             :                                 }
    5181           0 :                                 value.push_back(v_aux);
    5182             :                         }
    5183           0 :                         if (t.hasMoreTokens()) {
    5184           0 :                                 throw ConversionException("Error: Field \"" + 
    5185           0 :                                         name + "\": Syntax error.", tableName);
    5186             :                         }
    5187           0 :                         return value;
    5188           0 :                 } catch (const NumberFormatException &e) {
    5189           0 :                         throw ConversionException("Error: Field \"" + 
    5190           0 :                                 name + "\": " + e.getMessage(), tableName);
    5191           0 :                 } catch (const OutOfBoundsException &e) {
    5192           0 :                         throw  ConversionException("Error: Field \"" + 
    5193           0 :                                 name + "\": Unexpected end of string", tableName);
    5194           0 :                 } catch (const TagFormatException &e) {
    5195           0 :                         throw ConversionException("Error: Field \"" + 
    5196           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5197           0 :                 }               
    5198           0 :         }       
    5199             :         
    5200           0 :         vector< vector< vector<EntityId> > > Parser::get3DEntityId(const string &name, const string &tableName, const string &xmlDoc)
    5201             :         {
    5202           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5203           0 :                 if (xmlField.length() == 0) {
    5204           0 :                         throw ConversionException("Error: Field \"" + 
    5205           0 :                                         name + "\": Invalid XML syntax", tableName);
    5206             :                 }
    5207           0 :                 StringTokenizer t(xmlField," ");
    5208             :                 try {
    5209           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5210           0 :                         if (ndim != 3) {
    5211           0 :                                 throw ConversionException("Error: Field \"" + 
    5212           0 :                                         name + "\": Invalid array format", tableName);
    5213             :                         }
    5214           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5215           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    5216           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    5217           0 :                         vector< vector< vector<EntityId> > > value ;
    5218           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    5219           0 :                                 return value;
    5220             :                         
    5221           0 :                         vector<vector<EntityId> > vv_aux;
    5222           0 :                         vector<EntityId> v_aux;
    5223           0 :                         for (int i = 0; i < dim0; ++i) {
    5224           0 :                                 vv_aux.clear();
    5225           0 :                                 for (int j = 0; j < dim1; ++j) {
    5226           0 :                                         v_aux.clear();
    5227           0 :                                         for (int k = 0; k < dim2; ++k) {
    5228             :         
    5229           0 :                                                 v_aux.push_back(EntityId::getEntityId(t));
    5230             :         
    5231             :                                         }
    5232           0 :                                         vv_aux.push_back(v_aux);
    5233             :                                 }
    5234           0 :                                 value.push_back(vv_aux);
    5235             :                         }
    5236           0 :                         if (t.hasMoreTokens()) {
    5237           0 :                                 throw ConversionException("Error: Field \"" + 
    5238           0 :                                         name + "\": Syntax error.", tableName);
    5239             :                         }
    5240           0 :                         return value;
    5241           0 :                 } catch (const NumberFormatException &e) {
    5242           0 :                         throw ConversionException("Error: Field \"" + 
    5243           0 :                                 name + "\": " + e.getMessage(), tableName);
    5244           0 :                 } catch (const OutOfBoundsException &e) {
    5245           0 :                         throw  ConversionException("Error: Field \"" + 
    5246           0 :                                 name + "\": Unexpected end of string", tableName);
    5247           0 :                 } catch (const TagFormatException &e) {
    5248           0 :                         throw ConversionException("Error: Field \"" + 
    5249           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5250           0 :                 }               
    5251           0 :         }
    5252             :         
    5253           0 :         vector< vector< vector< vector<EntityId> > > >Parser::get4DEntityId(const string &name, const string &tableName, const string &xmlDoc)
    5254             :         {
    5255           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5256           0 :                 if (xmlField.length() == 0) {
    5257           0 :                         throw ConversionException("Error: Field \"" + 
    5258           0 :                                         name + "\": Invalid XML syntax", tableName);
    5259             :                 }
    5260           0 :                 StringTokenizer t(xmlField," ");
    5261             :                 try {
    5262           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5263           0 :                         if (ndim != 4) {
    5264           0 :                                 throw ConversionException("Error: Field \"" + 
    5265           0 :                                         name + "\": Invalid array format", tableName);
    5266             :                         }
    5267           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5268           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    5269           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    5270           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    5271           0 :                         vector<vector< vector< vector<EntityId> > > >value;
    5272           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    5273           0 :                                 return value;
    5274             :                         
    5275           0 :                         vector<vector<vector<EntityId> > >vvv_aux;
    5276           0 :                         vector<vector< EntityId> > vv_aux;
    5277           0 :                         vector<EntityId> v_aux;
    5278           0 :                         for (int i = 0; i < dim0; ++i) {
    5279           0 :                                 vvv_aux.clear();
    5280           0 :                                 for (int j = 0; j < dim1; ++j) {
    5281           0 :                                         vv_aux.clear();
    5282           0 :                                         for (int k = 0; k < dim2; ++k) {
    5283           0 :                                                 v_aux.clear();
    5284           0 :                                                 for (int l = 0; l < dim3; l++) {
    5285             :         
    5286           0 :                                                         v_aux.push_back(EntityId::getEntityId(t));
    5287             :         
    5288             :                                                 }
    5289           0 :                                                 vv_aux.push_back(v_aux);
    5290             :                                         }
    5291           0 :                                         vvv_aux.push_back(vv_aux);
    5292             :                                 }
    5293           0 :                                 value.push_back(vvv_aux);
    5294             :                         }
    5295           0 :                         if (t.hasMoreTokens()) {
    5296           0 :                                 throw ConversionException("Error: Field \"" + 
    5297           0 :                                         name + "\": Syntax error.", tableName);
    5298             :                         }
    5299           0 :                         return value;
    5300           0 :                 } catch (const NumberFormatException &e) {
    5301           0 :                         throw ConversionException("Error: Field \"" + 
    5302           0 :                                 name + "\": " + e.getMessage(), tableName);
    5303           0 :                 } catch (const OutOfBoundsException &e) {
    5304           0 :                         throw  ConversionException("Error: Field \"" + 
    5305           0 :                                 name + "\": Unexpected end of string", tableName);
    5306           0 :                 } catch (const TagFormatException &e) {
    5307           0 :                         throw ConversionException("Error: Field \"" + 
    5308           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5309           0 :                 }               
    5310           0 :         }       
    5311             :         
    5312             : 
    5313             :                 
    5314             : 
    5315             : 
    5316             :         // Field type: EntityRef
    5317             : 
    5318        2231 :         void Parser::toXML(EntityRef data, const string &name, string &buf) {
    5319        2231 :                 buf.append("<" + name + "> ");
    5320             :         
    5321        2231 :                 buf.append(data.toString());
    5322             :                 
    5323        2231 :                 buf.append(" </" + name + "> ");
    5324        2231 :         }
    5325             : 
    5326             :         
    5327             :         
    5328             :         
    5329           0 :         void Parser::toXML(vector<EntityRef> data, const string &name, string &buf) {
    5330           0 :                 buf.append("<" + name + "> ");
    5331           0 :                 buf.append("1 ");
    5332           0 :                 buf.append(Integer::toString(data.size()));
    5333           0 :                 buf.append(" ");
    5334           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5335             :         
    5336           0 :                         buf.append(data[i].toString());
    5337             :                 
    5338           0 :                         buf.append(" ");
    5339             :                 }
    5340           0 :                 buf.append(" </" + name + "> ");
    5341           0 :         }
    5342             : 
    5343           0 :         void Parser::toXML(vector< vector<EntityRef> > data, const string &name, string &buf) {
    5344           0 :                 buf.append("<" + name + "> ");
    5345           0 :                 buf.append("2 ");
    5346           0 :                 buf.append(Integer::toString(data.size()));
    5347           0 :                 buf.append(" ");
    5348           0 :                 buf.append(Integer::toString(data[0].size()));
    5349           0 :                 buf.append(" ");
    5350           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5351           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5352             :         
    5353           0 :                                 buf.append(data[i][j].toString());
    5354             :                 
    5355           0 :                                 buf.append(" ");
    5356             :                         }
    5357             :                 }
    5358           0 :                 buf.append(" </" + name + "> ");
    5359           0 :         }
    5360             :         
    5361           0 :         void Parser::toXML(vector< vector< vector<EntityRef> > > data, const string &name, string &buf) {
    5362           0 :                 buf.append("<" + name + "> ");
    5363           0 :                 buf.append("3 ");
    5364           0 :                 buf.append(Integer::toString(data.size()));
    5365           0 :                 buf.append(" ");
    5366           0 :                 buf.append(Integer::toString(data[0].size()));
    5367           0 :                 buf.append(" ");
    5368           0 :                 buf.append(Integer::toString(data[0][0].size()));
    5369           0 :                 buf.append(" ");
    5370           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5371           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5372           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    5373             :         
    5374           0 :                                         buf.append(data[i][j][k].toString());
    5375             :                 
    5376           0 :                                         buf.append(" ");
    5377             :                                 }
    5378             :                         }
    5379             :                 }
    5380           0 :                 buf.append(" </" + name + "> ");
    5381           0 :         }
    5382             :         
    5383           0 :         void Parser::toXML(vector<vector< vector< vector<EntityRef> > > >data, const string &name, string &buf) {
    5384           0 :                 buf.append("<" + name + "> ");
    5385           0 :                 buf.append("4 ");
    5386           0 :                 buf.append(Integer::toString(data.size()));
    5387           0 :                 buf.append(" ");
    5388           0 :                 buf.append(Integer::toString(data[0].size()));
    5389           0 :                 buf.append(" ");
    5390           0 :                 buf.append(Integer::toString(data[0][0].size()));
    5391           0 :                 buf.append(" ");
    5392           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    5393           0 :                 buf.append(" ");
    5394           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5395           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5396           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    5397           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    5398             :         
    5399           0 :                                                 buf.append(data[i][j][k][l].toString());
    5400             :                 
    5401           0 :                                                 buf.append(" ");
    5402             :                                         }
    5403             :                                 }
    5404             :                         }
    5405             :                 }
    5406           0 :                 buf.append(" </" + name + "> ");
    5407           0 :         }       
    5408             :         
    5409             :                 
    5410             : 
    5411             :         
    5412             :                 
    5413             :         
    5414        8705 :         EntityRef Parser::getEntityRef(const string &name, const string &tableName, const string &xmlDoc) 
    5415             :         {
    5416        8705 :                 string xmlField = Parser::getField(xmlDoc,name);
    5417        8705 :                 if (xmlField.length() == 0)
    5418           0 :                         throw ConversionException("Error: Missing field \"" + 
    5419           0 :                                 name + "\" or invalid syntax",tableName);
    5420             :         
    5421             :         try {   
    5422       17410 :                         return EntityRef (xmlField);
    5423             :                 }
    5424           0 :                 catch (const InvalidArgumentException &e) {
    5425           0 :                         throw ConversionException("Error: message was '"+ 
    5426           0 :                                                    e.getMessage()+
    5427             :                                                    "'",
    5428           0 :                                                    tableName);
    5429           0 :                 }
    5430             :                 
    5431        8705 :         }
    5432             : 
    5433           0 :         vector<EntityRef> Parser::get1DEntityRef(const string &name, const string &tableName, const string &xmlDoc)
    5434             :         {
    5435           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5436           0 :                 if (xmlField.length() == 0) {
    5437           0 :                         throw ConversionException("Error: Field \"" + 
    5438           0 :                                         name + "\": Invalid XML syntax", tableName);
    5439             :                 }
    5440           0 :                 StringTokenizer t(xmlField," ");
    5441             :                 try {
    5442           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5443           0 :                         if (ndim != 1) {
    5444           0 :                                 throw ConversionException("Error: Field \"" + 
    5445           0 :                                         name + "\": Invalid array format", tableName);
    5446             :                         }
    5447           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5448           0 :                         vector<EntityRef> value (dim0);
    5449           0 :                         if (dim0 == 0)
    5450           0 :                                 return value;
    5451           0 :                         for (int i = 0; i < dim0; ++i) {
    5452             :         
    5453           0 :                                 value[i] = EntityRef::getEntityRef(t);
    5454             :         
    5455             :                         }
    5456           0 :                         if (t.hasMoreTokens()) {
    5457           0 :                                 throw ConversionException("Error: Field \"" + 
    5458           0 :                                         name + "\": Syntax error.", tableName);
    5459             :                         }
    5460           0 :                         return value;
    5461           0 :                 } catch (const NumberFormatException &e) {
    5462           0 :                         throw ConversionException("Error: Field \"" + 
    5463           0 :                                 name + "\": " + e.getMessage(), tableName);
    5464           0 :                 } catch (const OutOfBoundsException &e) {
    5465           0 :                         throw  ConversionException("Error: Field \"" + 
    5466           0 :                                 name + "\": Unexpected end of string", tableName);
    5467           0 :                 } catch (const TagFormatException &e) {
    5468           0 :                         throw ConversionException("Error: Field \"" + 
    5469           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5470           0 :                 }               
    5471           0 :         }
    5472             :                 
    5473           0 :         vector< vector<EntityRef> > Parser::get2DEntityRef(const string &name, const string &tableName, const string &xmlDoc)
    5474             :         {
    5475           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5476           0 :                 if (xmlField.length() == 0) {
    5477           0 :                         throw ConversionException("Error: Field \"" + 
    5478           0 :                                         name + "\": Invalid XML syntax", tableName);
    5479             :                 }
    5480           0 :                 StringTokenizer t(xmlField," ");
    5481             :                 try {
    5482           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5483           0 :                         if (ndim != 2) {
    5484           0 :                                 throw ConversionException("Error: Field \"" + 
    5485           0 :                                         name + "\": Invalid array format", tableName);
    5486             :                         }
    5487           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5488           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    5489           0 :                         vector< vector<EntityRef> > value;
    5490             : 
    5491           0 :                         if (dim0 == 0 || dim1 == 0)
    5492           0 :                                 return value;
    5493             : 
    5494           0 :                         vector<EntityRef> v_aux;
    5495           0 :                         for (int i = 0; i < dim0; ++i) {
    5496           0 :                                 v_aux.clear();
    5497           0 :                                 for (int j = 0; j < dim1; ++j) {
    5498             :         
    5499           0 :                                         v_aux.push_back(EntityRef::getEntityRef(t));
    5500             :         
    5501             :                                 }
    5502           0 :                                 value.push_back(v_aux);
    5503             :                         }
    5504           0 :                         if (t.hasMoreTokens()) {
    5505           0 :                                 throw ConversionException("Error: Field \"" + 
    5506           0 :                                         name + "\": Syntax error.", tableName);
    5507             :                         }
    5508           0 :                         return value;
    5509           0 :                 } catch (const NumberFormatException &e) {
    5510           0 :                         throw ConversionException("Error: Field \"" + 
    5511           0 :                                 name + "\": " + e.getMessage(), tableName);
    5512           0 :                 } catch (const OutOfBoundsException &e) {
    5513           0 :                         throw  ConversionException("Error: Field \"" + 
    5514           0 :                                 name + "\": Unexpected end of string", tableName);
    5515           0 :                 } catch (const TagFormatException &e) {
    5516           0 :                         throw ConversionException("Error: Field \"" + 
    5517           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5518           0 :                 }               
    5519           0 :         }       
    5520             :         
    5521           0 :         vector< vector< vector<EntityRef> > > Parser::get3DEntityRef(const string &name, const string &tableName, const string &xmlDoc)
    5522             :         {
    5523           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5524           0 :                 if (xmlField.length() == 0) {
    5525           0 :                         throw ConversionException("Error: Field \"" + 
    5526           0 :                                         name + "\": Invalid XML syntax", tableName);
    5527             :                 }
    5528           0 :                 StringTokenizer t(xmlField," ");
    5529             :                 try {
    5530           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5531           0 :                         if (ndim != 3) {
    5532           0 :                                 throw ConversionException("Error: Field \"" + 
    5533           0 :                                         name + "\": Invalid array format", tableName);
    5534             :                         }
    5535           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5536           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    5537           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    5538           0 :                         vector< vector< vector<EntityRef> > > value ;
    5539           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    5540           0 :                                 return value;
    5541             :                         
    5542           0 :                         vector<vector<EntityRef> > vv_aux;
    5543           0 :                         vector<EntityRef> v_aux;
    5544           0 :                         for (int i = 0; i < dim0; ++i) {
    5545           0 :                                 vv_aux.clear();
    5546           0 :                                 for (int j = 0; j < dim1; ++j) {
    5547           0 :                                         v_aux.clear();
    5548           0 :                                         for (int k = 0; k < dim2; ++k) {
    5549             :         
    5550           0 :                                                 v_aux.push_back(EntityRef::getEntityRef(t));
    5551             :         
    5552             :                                         }
    5553           0 :                                         vv_aux.push_back(v_aux);
    5554             :                                 }
    5555           0 :                                 value.push_back(vv_aux);
    5556             :                         }
    5557           0 :                         if (t.hasMoreTokens()) {
    5558           0 :                                 throw ConversionException("Error: Field \"" + 
    5559           0 :                                         name + "\": Syntax error.", tableName);
    5560             :                         }
    5561           0 :                         return value;
    5562           0 :                 } catch (const NumberFormatException &e) {
    5563           0 :                         throw ConversionException("Error: Field \"" + 
    5564           0 :                                 name + "\": " + e.getMessage(), tableName);
    5565           0 :                 } catch (const OutOfBoundsException &e) {
    5566           0 :                         throw  ConversionException("Error: Field \"" + 
    5567           0 :                                 name + "\": Unexpected end of string", tableName);
    5568           0 :                 } catch (const TagFormatException &e) {
    5569           0 :                         throw ConversionException("Error: Field \"" + 
    5570           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5571           0 :                 }               
    5572           0 :         }
    5573             :         
    5574           0 :         vector< vector< vector< vector<EntityRef> > > >Parser::get4DEntityRef(const string &name, const string &tableName, const string &xmlDoc)
    5575             :         {
    5576           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5577           0 :                 if (xmlField.length() == 0) {
    5578           0 :                         throw ConversionException("Error: Field \"" + 
    5579           0 :                                         name + "\": Invalid XML syntax", tableName);
    5580             :                 }
    5581           0 :                 StringTokenizer t(xmlField," ");
    5582             :                 try {
    5583           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5584           0 :                         if (ndim != 4) {
    5585           0 :                                 throw ConversionException("Error: Field \"" + 
    5586           0 :                                         name + "\": Invalid array format", tableName);
    5587             :                         }
    5588           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5589           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    5590           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    5591           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    5592           0 :                         vector<vector< vector< vector<EntityRef> > > >value;
    5593           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    5594           0 :                                 return value;
    5595             :                         
    5596           0 :                         vector<vector<vector<EntityRef> > >vvv_aux;
    5597           0 :                         vector<vector< EntityRef> > vv_aux;
    5598           0 :                         vector<EntityRef> v_aux;
    5599           0 :                         for (int i = 0; i < dim0; ++i) {
    5600           0 :                                 vvv_aux.clear();
    5601           0 :                                 for (int j = 0; j < dim1; ++j) {
    5602           0 :                                         vv_aux.clear();
    5603           0 :                                         for (int k = 0; k < dim2; ++k) {
    5604           0 :                                                 v_aux.clear();
    5605           0 :                                                 for (int l = 0; l < dim3; l++) {
    5606             :         
    5607           0 :                                                         v_aux.push_back(EntityRef::getEntityRef(t));
    5608             :         
    5609             :                                                 }
    5610           0 :                                                 vv_aux.push_back(v_aux);
    5611             :                                         }
    5612           0 :                                         vvv_aux.push_back(vv_aux);
    5613             :                                 }
    5614           0 :                                 value.push_back(vvv_aux);
    5615             :                         }
    5616           0 :                         if (t.hasMoreTokens()) {
    5617           0 :                                 throw ConversionException("Error: Field \"" + 
    5618           0 :                                         name + "\": Syntax error.", tableName);
    5619             :                         }
    5620           0 :                         return value;
    5621           0 :                 } catch (const NumberFormatException &e) {
    5622           0 :                         throw ConversionException("Error: Field \"" + 
    5623           0 :                                 name + "\": " + e.getMessage(), tableName);
    5624           0 :                 } catch (const OutOfBoundsException &e) {
    5625           0 :                         throw  ConversionException("Error: Field \"" + 
    5626           0 :                                 name + "\": Unexpected end of string", tableName);
    5627           0 :                 } catch (const TagFormatException &e) {
    5628           0 :                         throw ConversionException("Error: Field \"" + 
    5629           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5630           0 :                 }               
    5631           0 :         }       
    5632             :         
    5633             : 
    5634             :                 
    5635             : 
    5636             : 
    5637             :         // Field type: Flux
    5638             : 
    5639           0 :         void Parser::toXML(Flux data, const string &name, string &buf) {
    5640           0 :                 buf.append("<" + name + "> ");
    5641             :         
    5642           0 :                 buf.append(data.toString());
    5643             :                 
    5644           0 :                 buf.append(" </" + name + "> ");
    5645           0 :         }
    5646             : 
    5647             :         
    5648             :         
    5649             :         
    5650           0 :         void Parser::toXML(vector<Flux> data, const string &name, string &buf) {
    5651           0 :                 buf.append("<" + name + "> ");
    5652           0 :                 buf.append("1 ");
    5653           0 :                 buf.append(Integer::toString(data.size()));
    5654           0 :                 buf.append(" ");
    5655           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5656             :         
    5657           0 :                         buf.append(data[i].toString());
    5658             :                 
    5659           0 :                         buf.append(" ");
    5660             :                 }
    5661           0 :                 buf.append(" </" + name + "> ");
    5662           0 :         }
    5663             : 
    5664           0 :         void Parser::toXML(vector< vector<Flux> > data, const string &name, string &buf) {
    5665           0 :                 buf.append("<" + name + "> ");
    5666           0 :                 buf.append("2 ");
    5667           0 :                 buf.append(Integer::toString(data.size()));
    5668           0 :                 buf.append(" ");
    5669           0 :                 buf.append(Integer::toString(data[0].size()));
    5670           0 :                 buf.append(" ");
    5671           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5672           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5673             :         
    5674           0 :                                 buf.append(data[i][j].toString());
    5675             :                 
    5676           0 :                                 buf.append(" ");
    5677             :                         }
    5678             :                 }
    5679           0 :                 buf.append(" </" + name + "> ");
    5680           0 :         }
    5681             :         
    5682           0 :         void Parser::toXML(vector< vector< vector<Flux> > > data, const string &name, string &buf) {
    5683           0 :                 buf.append("<" + name + "> ");
    5684           0 :                 buf.append("3 ");
    5685           0 :                 buf.append(Integer::toString(data.size()));
    5686           0 :                 buf.append(" ");
    5687           0 :                 buf.append(Integer::toString(data[0].size()));
    5688           0 :                 buf.append(" ");
    5689           0 :                 buf.append(Integer::toString(data[0][0].size()));
    5690           0 :                 buf.append(" ");
    5691           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5692           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5693           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    5694             :         
    5695           0 :                                         buf.append(data[i][j][k].toString());
    5696             :                 
    5697           0 :                                         buf.append(" ");
    5698             :                                 }
    5699             :                         }
    5700             :                 }
    5701           0 :                 buf.append(" </" + name + "> ");
    5702           0 :         }
    5703             :         
    5704           0 :         void Parser::toXML(vector<vector< vector< vector<Flux> > > >data, const string &name, string &buf) {
    5705           0 :                 buf.append("<" + name + "> ");
    5706           0 :                 buf.append("4 ");
    5707           0 :                 buf.append(Integer::toString(data.size()));
    5708           0 :                 buf.append(" ");
    5709           0 :                 buf.append(Integer::toString(data[0].size()));
    5710           0 :                 buf.append(" ");
    5711           0 :                 buf.append(Integer::toString(data[0][0].size()));
    5712           0 :                 buf.append(" ");
    5713           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    5714           0 :                 buf.append(" ");
    5715           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5716           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5717           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    5718           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    5719             :         
    5720           0 :                                                 buf.append(data[i][j][k][l].toString());
    5721             :                 
    5722           0 :                                                 buf.append(" ");
    5723             :                                         }
    5724             :                                 }
    5725             :                         }
    5726             :                 }
    5727           0 :                 buf.append(" </" + name + "> ");
    5728           0 :         }       
    5729             :         
    5730             :                 
    5731             : 
    5732             :         
    5733             :                 
    5734             :         
    5735           0 :         Flux Parser::getFlux(const string &name, const string &tableName, const string &xmlDoc) 
    5736             :         {
    5737           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5738           0 :                 if (xmlField.length() == 0)
    5739           0 :                         throw ConversionException("Error: Missing field \"" + 
    5740           0 :                                 name + "\" or invalid syntax",tableName);
    5741             :         
    5742             :         try {   
    5743           0 :                         return Flux (xmlField);
    5744             :                 }
    5745           0 :                 catch (const InvalidArgumentException &e) {
    5746           0 :                         throw ConversionException("Error: message was '"+ 
    5747           0 :                                                    e.getMessage()+
    5748             :                                                    "'",
    5749           0 :                                                    tableName);
    5750           0 :                 }
    5751             :                 
    5752           0 :         }
    5753             : 
    5754           0 :         vector<Flux> Parser::get1DFlux(const string &name, const string &tableName, const string &xmlDoc)
    5755             :         {
    5756           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5757           0 :                 if (xmlField.length() == 0) {
    5758           0 :                         throw ConversionException("Error: Field \"" + 
    5759           0 :                                         name + "\": Invalid XML syntax", tableName);
    5760             :                 }
    5761           0 :                 StringTokenizer t(xmlField," ");
    5762             :                 try {
    5763           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5764           0 :                         if (ndim != 1) {
    5765           0 :                                 throw ConversionException("Error: Field \"" + 
    5766           0 :                                         name + "\": Invalid array format", tableName);
    5767             :                         }
    5768           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5769           0 :                         vector<Flux> value (dim0);
    5770           0 :                         if (dim0 == 0)
    5771           0 :                                 return value;
    5772           0 :                         for (int i = 0; i < dim0; ++i) {
    5773             :         
    5774           0 :                                 value[i] = Flux::getFlux(t);
    5775             :         
    5776             :                         }
    5777           0 :                         if (t.hasMoreTokens()) {
    5778           0 :                                 throw ConversionException("Error: Field \"" + 
    5779           0 :                                         name + "\": Syntax error.", tableName);
    5780             :                         }
    5781           0 :                         return value;
    5782           0 :                 } catch (const NumberFormatException &e) {
    5783           0 :                         throw ConversionException("Error: Field \"" + 
    5784           0 :                                 name + "\": " + e.getMessage(), tableName);
    5785           0 :                 } catch (const OutOfBoundsException &e) {
    5786           0 :                         throw  ConversionException("Error: Field \"" + 
    5787           0 :                                 name + "\": Unexpected end of string", tableName);
    5788           0 :                 } catch (const TagFormatException &e) {
    5789           0 :                         throw ConversionException("Error: Field \"" + 
    5790           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5791           0 :                 }               
    5792           0 :         }
    5793             :                 
    5794        3245 :         vector< vector<Flux> > Parser::get2DFlux(const string &name, const string &tableName, const string &xmlDoc)
    5795             :         {
    5796        3245 :                 string xmlField = Parser::getField(xmlDoc,name);
    5797        3245 :                 if (xmlField.length() == 0) {
    5798           0 :                         throw ConversionException("Error: Field \"" + 
    5799           0 :                                         name + "\": Invalid XML syntax", tableName);
    5800             :                 }
    5801        6490 :                 StringTokenizer t(xmlField," ");
    5802             :                 try {
    5803        3245 :                         int ndim = Integer::parseInt(t.nextToken());
    5804        3245 :                         if (ndim != 2) {
    5805           0 :                                 throw ConversionException("Error: Field \"" + 
    5806           0 :                                         name + "\": Invalid array format", tableName);
    5807             :                         }
    5808        3245 :                         int dim0 = Integer::parseInt(t.nextToken());
    5809        3245 :                         int dim1 = Integer::parseInt(t.nextToken());
    5810        3245 :                         vector< vector<Flux> > value;
    5811             : 
    5812        3245 :                         if (dim0 == 0 || dim1 == 0)
    5813           0 :                                 return value;
    5814             : 
    5815        3245 :                         vector<Flux> v_aux;
    5816        9330 :                         for (int i = 0; i < dim0; ++i) {
    5817        6085 :                                 v_aux.clear();
    5818       30425 :                                 for (int j = 0; j < dim1; ++j) {
    5819             :         
    5820       24340 :                                         v_aux.push_back(Flux::getFlux(t));
    5821             :         
    5822             :                                 }
    5823        6085 :                                 value.push_back(v_aux);
    5824             :                         }
    5825        3245 :                         if (t.hasMoreTokens()) {
    5826           0 :                                 throw ConversionException("Error: Field \"" + 
    5827           0 :                                         name + "\": Syntax error.", tableName);
    5828             :                         }
    5829        3245 :                         return value;
    5830        3245 :                 } catch (const NumberFormatException &e) {
    5831           0 :                         throw ConversionException("Error: Field \"" + 
    5832           0 :                                 name + "\": " + e.getMessage(), tableName);
    5833           0 :                 } catch (const OutOfBoundsException &e) {
    5834           0 :                         throw  ConversionException("Error: Field \"" + 
    5835           0 :                                 name + "\": Unexpected end of string", tableName);
    5836           0 :                 } catch (const TagFormatException &e) {
    5837           0 :                         throw ConversionException("Error: Field \"" + 
    5838           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5839           0 :                 }               
    5840        3245 :         }       
    5841             :         
    5842           0 :         vector< vector< vector<Flux> > > Parser::get3DFlux(const string &name, const string &tableName, const string &xmlDoc)
    5843             :         {
    5844           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5845           0 :                 if (xmlField.length() == 0) {
    5846           0 :                         throw ConversionException("Error: Field \"" + 
    5847           0 :                                         name + "\": Invalid XML syntax", tableName);
    5848             :                 }
    5849           0 :                 StringTokenizer t(xmlField," ");
    5850             :                 try {
    5851           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5852           0 :                         if (ndim != 3) {
    5853           0 :                                 throw ConversionException("Error: Field \"" + 
    5854           0 :                                         name + "\": Invalid array format", tableName);
    5855             :                         }
    5856           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5857           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    5858           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    5859           0 :                         vector< vector< vector<Flux> > > value ;
    5860           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    5861           0 :                                 return value;
    5862             :                         
    5863           0 :                         vector<vector<Flux> > vv_aux;
    5864           0 :                         vector<Flux> v_aux;
    5865           0 :                         for (int i = 0; i < dim0; ++i) {
    5866           0 :                                 vv_aux.clear();
    5867           0 :                                 for (int j = 0; j < dim1; ++j) {
    5868           0 :                                         v_aux.clear();
    5869           0 :                                         for (int k = 0; k < dim2; ++k) {
    5870             :         
    5871           0 :                                                 v_aux.push_back(Flux::getFlux(t));
    5872             :         
    5873             :                                         }
    5874           0 :                                         vv_aux.push_back(v_aux);
    5875             :                                 }
    5876           0 :                                 value.push_back(vv_aux);
    5877             :                         }
    5878           0 :                         if (t.hasMoreTokens()) {
    5879           0 :                                 throw ConversionException("Error: Field \"" + 
    5880           0 :                                         name + "\": Syntax error.", tableName);
    5881             :                         }
    5882           0 :                         return value;
    5883           0 :                 } catch (const NumberFormatException &e) {
    5884           0 :                         throw ConversionException("Error: Field \"" + 
    5885           0 :                                 name + "\": " + e.getMessage(), tableName);
    5886           0 :                 } catch (const OutOfBoundsException &e) {
    5887           0 :                         throw  ConversionException("Error: Field \"" + 
    5888           0 :                                 name + "\": Unexpected end of string", tableName);
    5889           0 :                 } catch (const TagFormatException &e) {
    5890           0 :                         throw ConversionException("Error: Field \"" + 
    5891           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5892           0 :                 }               
    5893           0 :         }
    5894             :         
    5895           0 :         vector< vector< vector< vector<Flux> > > >Parser::get4DFlux(const string &name, const string &tableName, const string &xmlDoc)
    5896             :         {
    5897           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    5898           0 :                 if (xmlField.length() == 0) {
    5899           0 :                         throw ConversionException("Error: Field \"" + 
    5900           0 :                                         name + "\": Invalid XML syntax", tableName);
    5901             :                 }
    5902           0 :                 StringTokenizer t(xmlField," ");
    5903             :                 try {
    5904           0 :                         int ndim = Integer::parseInt(t.nextToken());
    5905           0 :                         if (ndim != 4) {
    5906           0 :                                 throw ConversionException("Error: Field \"" + 
    5907           0 :                                         name + "\": Invalid array format", tableName);
    5908             :                         }
    5909           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    5910           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    5911           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    5912           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    5913           0 :                         vector<vector< vector< vector<Flux> > > >value;
    5914           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    5915           0 :                                 return value;
    5916             :                         
    5917           0 :                         vector<vector<vector<Flux> > >vvv_aux;
    5918           0 :                         vector<vector< Flux> > vv_aux;
    5919           0 :                         vector<Flux> v_aux;
    5920           0 :                         for (int i = 0; i < dim0; ++i) {
    5921           0 :                                 vvv_aux.clear();
    5922           0 :                                 for (int j = 0; j < dim1; ++j) {
    5923           0 :                                         vv_aux.clear();
    5924           0 :                                         for (int k = 0; k < dim2; ++k) {
    5925           0 :                                                 v_aux.clear();
    5926           0 :                                                 for (int l = 0; l < dim3; l++) {
    5927             :         
    5928           0 :                                                         v_aux.push_back(Flux::getFlux(t));
    5929             :         
    5930             :                                                 }
    5931           0 :                                                 vv_aux.push_back(v_aux);
    5932             :                                         }
    5933           0 :                                         vvv_aux.push_back(vv_aux);
    5934             :                                 }
    5935           0 :                                 value.push_back(vvv_aux);
    5936             :                         }
    5937           0 :                         if (t.hasMoreTokens()) {
    5938           0 :                                 throw ConversionException("Error: Field \"" + 
    5939           0 :                                         name + "\": Syntax error.", tableName);
    5940             :                         }
    5941           0 :                         return value;
    5942           0 :                 } catch (const NumberFormatException &e) {
    5943           0 :                         throw ConversionException("Error: Field \"" + 
    5944           0 :                                 name + "\": " + e.getMessage(), tableName);
    5945           0 :                 } catch (const OutOfBoundsException &e) {
    5946           0 :                         throw  ConversionException("Error: Field \"" + 
    5947           0 :                                 name + "\": Unexpected end of string", tableName);
    5948           0 :                 } catch (const TagFormatException &e) {
    5949           0 :                         throw ConversionException("Error: Field \"" + 
    5950           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    5951           0 :                 }               
    5952           0 :         }       
    5953             :         
    5954             : 
    5955             :                 
    5956             : 
    5957             : 
    5958             :         // Field type: Frequency
    5959             : 
    5960         166 :         void Parser::toXML(Frequency data, const string &name, string &buf) {
    5961         166 :                 buf.append("<" + name + "> ");
    5962             :         
    5963         166 :                 buf.append(data.toString());
    5964             :                 
    5965         166 :                 buf.append(" </" + name + "> ");
    5966         166 :         }
    5967             : 
    5968             :         
    5969             :         
    5970             :         
    5971         428 :         void Parser::toXML(vector<Frequency> data, const string &name, string &buf) {
    5972         428 :                 buf.append("<" + name + "> ");
    5973         428 :                 buf.append("1 ");
    5974         428 :                 buf.append(Integer::toString(data.size()));
    5975         428 :                 buf.append(" ");
    5976      156785 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5977             :         
    5978      156357 :                         buf.append(data[i].toString());
    5979             :                 
    5980      156357 :                         buf.append(" ");
    5981             :                 }
    5982         428 :                 buf.append(" </" + name + "> ");
    5983         428 :         }
    5984             : 
    5985           0 :         void Parser::toXML(vector< vector<Frequency> > data, const string &name, string &buf) {
    5986           0 :                 buf.append("<" + name + "> ");
    5987           0 :                 buf.append("2 ");
    5988           0 :                 buf.append(Integer::toString(data.size()));
    5989           0 :                 buf.append(" ");
    5990           0 :                 buf.append(Integer::toString(data[0].size()));
    5991           0 :                 buf.append(" ");
    5992           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    5993           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    5994             :         
    5995           0 :                                 buf.append(data[i][j].toString());
    5996             :                 
    5997           0 :                                 buf.append(" ");
    5998             :                         }
    5999             :                 }
    6000           0 :                 buf.append(" </" + name + "> ");
    6001           0 :         }
    6002             :         
    6003           0 :         void Parser::toXML(vector< vector< vector<Frequency> > > data, const string &name, string &buf) {
    6004           0 :                 buf.append("<" + name + "> ");
    6005           0 :                 buf.append("3 ");
    6006           0 :                 buf.append(Integer::toString(data.size()));
    6007           0 :                 buf.append(" ");
    6008           0 :                 buf.append(Integer::toString(data[0].size()));
    6009           0 :                 buf.append(" ");
    6010           0 :                 buf.append(Integer::toString(data[0][0].size()));
    6011           0 :                 buf.append(" ");
    6012           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6013           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6014           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    6015             :         
    6016           0 :                                         buf.append(data[i][j][k].toString());
    6017             :                 
    6018           0 :                                         buf.append(" ");
    6019             :                                 }
    6020             :                         }
    6021             :                 }
    6022           0 :                 buf.append(" </" + name + "> ");
    6023           0 :         }
    6024             :         
    6025           0 :         void Parser::toXML(vector<vector< vector< vector<Frequency> > > >data, const string &name, string &buf) {
    6026           0 :                 buf.append("<" + name + "> ");
    6027           0 :                 buf.append("4 ");
    6028           0 :                 buf.append(Integer::toString(data.size()));
    6029           0 :                 buf.append(" ");
    6030           0 :                 buf.append(Integer::toString(data[0].size()));
    6031           0 :                 buf.append(" ");
    6032           0 :                 buf.append(Integer::toString(data[0][0].size()));
    6033           0 :                 buf.append(" ");
    6034           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    6035           0 :                 buf.append(" ");
    6036           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6037           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6038           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    6039           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    6040             :         
    6041           0 :                                                 buf.append(data[i][j][k][l].toString());
    6042             :                 
    6043           0 :                                                 buf.append(" ");
    6044             :                                         }
    6045             :                                 }
    6046             :                         }
    6047             :                 }
    6048           0 :                 buf.append(" </" + name + "> ");
    6049           0 :         }       
    6050             :         
    6051             :                 
    6052             : 
    6053             :         
    6054             :                 
    6055             :         
    6056        8383 :         Frequency Parser::getFrequency(const string &name, const string &tableName, const string &xmlDoc) 
    6057             :         {
    6058        8383 :                 string xmlField = Parser::getField(xmlDoc,name);
    6059        8383 :                 if (xmlField.length() == 0)
    6060           0 :                         throw ConversionException("Error: Missing field \"" + 
    6061           0 :                                 name + "\" or invalid syntax",tableName);
    6062             :         
    6063             :         try {   
    6064       16766 :                         return Frequency (xmlField);
    6065             :                 }
    6066           0 :                 catch (const InvalidArgumentException &e) {
    6067           0 :                         throw ConversionException("Error: message was '"+ 
    6068           0 :                                                    e.getMessage()+
    6069             :                                                    "'",
    6070           0 :                                                    tableName);
    6071           0 :                 }
    6072             :                 
    6073        8383 :         }
    6074             : 
    6075       11520 :         vector<Frequency> Parser::get1DFrequency(const string &name, const string &tableName, const string &xmlDoc)
    6076             :         {
    6077       11520 :                 string xmlField = Parser::getField(xmlDoc,name);
    6078       11520 :                 if (xmlField.length() == 0) {
    6079           0 :                         throw ConversionException("Error: Field \"" + 
    6080           0 :                                         name + "\": Invalid XML syntax", tableName);
    6081             :                 }
    6082       23040 :                 StringTokenizer t(xmlField," ");
    6083             :                 try {
    6084       11520 :                         int ndim = Integer::parseInt(t.nextToken());
    6085       11520 :                         if (ndim != 1) {
    6086           0 :                                 throw ConversionException("Error: Field \"" + 
    6087           0 :                                         name + "\": Invalid array format", tableName);
    6088             :                         }
    6089       11520 :                         int dim0 = Integer::parseInt(t.nextToken());
    6090       11520 :                         vector<Frequency> value (dim0);
    6091       11520 :                         if (dim0 == 0)
    6092         712 :                                 return value;
    6093       37937 :                         for (int i = 0; i < dim0; ++i) {
    6094             :         
    6095       27129 :                                 value[i] = Frequency::getFrequency(t);
    6096             :         
    6097             :                         }
    6098       10808 :                         if (t.hasMoreTokens()) {
    6099           0 :                                 throw ConversionException("Error: Field \"" + 
    6100           0 :                                         name + "\": Syntax error.", tableName);
    6101             :                         }
    6102       10808 :                         return value;
    6103       11520 :                 } catch (const NumberFormatException &e) {
    6104           0 :                         throw ConversionException("Error: Field \"" + 
    6105           0 :                                 name + "\": " + e.getMessage(), tableName);
    6106           0 :                 } catch (const OutOfBoundsException &e) {
    6107           0 :                         throw  ConversionException("Error: Field \"" + 
    6108           0 :                                 name + "\": Unexpected end of string", tableName);
    6109           0 :                 } catch (const TagFormatException &e) {
    6110           0 :                         throw ConversionException("Error: Field \"" + 
    6111           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6112           0 :                 }               
    6113       11520 :         }
    6114             :                 
    6115           1 :         vector< vector<Frequency> > Parser::get2DFrequency(const string &name, const string &tableName, const string &xmlDoc)
    6116             :         {
    6117           1 :                 string xmlField = Parser::getField(xmlDoc,name);
    6118           1 :                 if (xmlField.length() == 0) {
    6119           0 :                         throw ConversionException("Error: Field \"" + 
    6120           0 :                                         name + "\": Invalid XML syntax", tableName);
    6121             :                 }
    6122           2 :                 StringTokenizer t(xmlField," ");
    6123             :                 try {
    6124           1 :                         int ndim = Integer::parseInt(t.nextToken());
    6125           1 :                         if (ndim != 2) {
    6126           0 :                                 throw ConversionException("Error: Field \"" + 
    6127           0 :                                         name + "\": Invalid array format", tableName);
    6128             :                         }
    6129           1 :                         int dim0 = Integer::parseInt(t.nextToken());
    6130           1 :                         int dim1 = Integer::parseInt(t.nextToken());
    6131           1 :                         vector< vector<Frequency> > value;
    6132             : 
    6133           1 :                         if (dim0 == 0 || dim1 == 0)
    6134           0 :                                 return value;
    6135             : 
    6136           1 :                         vector<Frequency> v_aux;
    6137           5 :                         for (int i = 0; i < dim0; ++i) {
    6138           4 :                                 v_aux.clear();
    6139          12 :                                 for (int j = 0; j < dim1; ++j) {
    6140             :         
    6141           8 :                                         v_aux.push_back(Frequency::getFrequency(t));
    6142             :         
    6143             :                                 }
    6144           4 :                                 value.push_back(v_aux);
    6145             :                         }
    6146           1 :                         if (t.hasMoreTokens()) {
    6147           0 :                                 throw ConversionException("Error: Field \"" + 
    6148           0 :                                         name + "\": Syntax error.", tableName);
    6149             :                         }
    6150           1 :                         return value;
    6151           1 :                 } catch (const NumberFormatException &e) {
    6152           0 :                         throw ConversionException("Error: Field \"" + 
    6153           0 :                                 name + "\": " + e.getMessage(), tableName);
    6154           0 :                 } catch (const OutOfBoundsException &e) {
    6155           0 :                         throw  ConversionException("Error: Field \"" + 
    6156           0 :                                 name + "\": Unexpected end of string", tableName);
    6157           0 :                 } catch (const TagFormatException &e) {
    6158           0 :                         throw ConversionException("Error: Field \"" + 
    6159           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6160           0 :                 }               
    6161           1 :         }       
    6162             :         
    6163           0 :         vector< vector< vector<Frequency> > > Parser::get3DFrequency(const string &name, const string &tableName, const string &xmlDoc)
    6164             :         {
    6165           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    6166           0 :                 if (xmlField.length() == 0) {
    6167           0 :                         throw ConversionException("Error: Field \"" + 
    6168           0 :                                         name + "\": Invalid XML syntax", tableName);
    6169             :                 }
    6170           0 :                 StringTokenizer t(xmlField," ");
    6171             :                 try {
    6172           0 :                         int ndim = Integer::parseInt(t.nextToken());
    6173           0 :                         if (ndim != 3) {
    6174           0 :                                 throw ConversionException("Error: Field \"" + 
    6175           0 :                                         name + "\": Invalid array format", tableName);
    6176             :                         }
    6177           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    6178           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    6179           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    6180           0 :                         vector< vector< vector<Frequency> > > value ;
    6181           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    6182           0 :                                 return value;
    6183             :                         
    6184           0 :                         vector<vector<Frequency> > vv_aux;
    6185           0 :                         vector<Frequency> v_aux;
    6186           0 :                         for (int i = 0; i < dim0; ++i) {
    6187           0 :                                 vv_aux.clear();
    6188           0 :                                 for (int j = 0; j < dim1; ++j) {
    6189           0 :                                         v_aux.clear();
    6190           0 :                                         for (int k = 0; k < dim2; ++k) {
    6191             :         
    6192           0 :                                                 v_aux.push_back(Frequency::getFrequency(t));
    6193             :         
    6194             :                                         }
    6195           0 :                                         vv_aux.push_back(v_aux);
    6196             :                                 }
    6197           0 :                                 value.push_back(vv_aux);
    6198             :                         }
    6199           0 :                         if (t.hasMoreTokens()) {
    6200           0 :                                 throw ConversionException("Error: Field \"" + 
    6201           0 :                                         name + "\": Syntax error.", tableName);
    6202             :                         }
    6203           0 :                         return value;
    6204           0 :                 } catch (const NumberFormatException &e) {
    6205           0 :                         throw ConversionException("Error: Field \"" + 
    6206           0 :                                 name + "\": " + e.getMessage(), tableName);
    6207           0 :                 } catch (const OutOfBoundsException &e) {
    6208           0 :                         throw  ConversionException("Error: Field \"" + 
    6209           0 :                                 name + "\": Unexpected end of string", tableName);
    6210           0 :                 } catch (const TagFormatException &e) {
    6211           0 :                         throw ConversionException("Error: Field \"" + 
    6212           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6213           0 :                 }               
    6214           0 :         }
    6215             :         
    6216           0 :         vector< vector< vector< vector<Frequency> > > >Parser::get4DFrequency(const string &name, const string &tableName, const string &xmlDoc)
    6217             :         {
    6218           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    6219           0 :                 if (xmlField.length() == 0) {
    6220           0 :                         throw ConversionException("Error: Field \"" + 
    6221           0 :                                         name + "\": Invalid XML syntax", tableName);
    6222             :                 }
    6223           0 :                 StringTokenizer t(xmlField," ");
    6224             :                 try {
    6225           0 :                         int ndim = Integer::parseInt(t.nextToken());
    6226           0 :                         if (ndim != 4) {
    6227           0 :                                 throw ConversionException("Error: Field \"" + 
    6228           0 :                                         name + "\": Invalid array format", tableName);
    6229             :                         }
    6230           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    6231           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    6232           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    6233           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    6234           0 :                         vector<vector< vector< vector<Frequency> > > >value;
    6235           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    6236           0 :                                 return value;
    6237             :                         
    6238           0 :                         vector<vector<vector<Frequency> > >vvv_aux;
    6239           0 :                         vector<vector< Frequency> > vv_aux;
    6240           0 :                         vector<Frequency> v_aux;
    6241           0 :                         for (int i = 0; i < dim0; ++i) {
    6242           0 :                                 vvv_aux.clear();
    6243           0 :                                 for (int j = 0; j < dim1; ++j) {
    6244           0 :                                         vv_aux.clear();
    6245           0 :                                         for (int k = 0; k < dim2; ++k) {
    6246           0 :                                                 v_aux.clear();
    6247           0 :                                                 for (int l = 0; l < dim3; l++) {
    6248             :         
    6249           0 :                                                         v_aux.push_back(Frequency::getFrequency(t));
    6250             :         
    6251             :                                                 }
    6252           0 :                                                 vv_aux.push_back(v_aux);
    6253             :                                         }
    6254           0 :                                         vvv_aux.push_back(vv_aux);
    6255             :                                 }
    6256           0 :                                 value.push_back(vvv_aux);
    6257             :                         }
    6258           0 :                         if (t.hasMoreTokens()) {
    6259           0 :                                 throw ConversionException("Error: Field \"" + 
    6260           0 :                                         name + "\": Syntax error.", tableName);
    6261             :                         }
    6262           0 :                         return value;
    6263           0 :                 } catch (const NumberFormatException &e) {
    6264           0 :                         throw ConversionException("Error: Field \"" + 
    6265           0 :                                 name + "\": " + e.getMessage(), tableName);
    6266           0 :                 } catch (const OutOfBoundsException &e) {
    6267           0 :                         throw  ConversionException("Error: Field \"" + 
    6268           0 :                                 name + "\": Unexpected end of string", tableName);
    6269           0 :                 } catch (const TagFormatException &e) {
    6270           0 :                         throw ConversionException("Error: Field \"" + 
    6271           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6272           0 :                 }               
    6273           0 :         }       
    6274             :         
    6275             : 
    6276             :                 
    6277             : 
    6278             : 
    6279             :         // Field type: Humidity
    6280             : 
    6281           0 :         void Parser::toXML(Humidity data, const string &name, string &buf) {
    6282           0 :                 buf.append("<" + name + "> ");
    6283             :         
    6284           0 :                 buf.append(data.toString());
    6285             :                 
    6286           0 :                 buf.append(" </" + name + "> ");
    6287           0 :         }
    6288             : 
    6289             :         
    6290             :         
    6291             :         
    6292           0 :         void Parser::toXML(vector<Humidity> data, const string &name, string &buf) {
    6293           0 :                 buf.append("<" + name + "> ");
    6294           0 :                 buf.append("1 ");
    6295           0 :                 buf.append(Integer::toString(data.size()));
    6296           0 :                 buf.append(" ");
    6297           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6298             :         
    6299           0 :                         buf.append(data[i].toString());
    6300             :                 
    6301           0 :                         buf.append(" ");
    6302             :                 }
    6303           0 :                 buf.append(" </" + name + "> ");
    6304           0 :         }
    6305             : 
    6306           0 :         void Parser::toXML(vector< vector<Humidity> > data, const string &name, string &buf) {
    6307           0 :                 buf.append("<" + name + "> ");
    6308           0 :                 buf.append("2 ");
    6309           0 :                 buf.append(Integer::toString(data.size()));
    6310           0 :                 buf.append(" ");
    6311           0 :                 buf.append(Integer::toString(data[0].size()));
    6312           0 :                 buf.append(" ");
    6313           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6314           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6315             :         
    6316           0 :                                 buf.append(data[i][j].toString());
    6317             :                 
    6318           0 :                                 buf.append(" ");
    6319             :                         }
    6320             :                 }
    6321           0 :                 buf.append(" </" + name + "> ");
    6322           0 :         }
    6323             :         
    6324           0 :         void Parser::toXML(vector< vector< vector<Humidity> > > data, const string &name, string &buf) {
    6325           0 :                 buf.append("<" + name + "> ");
    6326           0 :                 buf.append("3 ");
    6327           0 :                 buf.append(Integer::toString(data.size()));
    6328           0 :                 buf.append(" ");
    6329           0 :                 buf.append(Integer::toString(data[0].size()));
    6330           0 :                 buf.append(" ");
    6331           0 :                 buf.append(Integer::toString(data[0][0].size()));
    6332           0 :                 buf.append(" ");
    6333           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6334           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6335           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    6336             :         
    6337           0 :                                         buf.append(data[i][j][k].toString());
    6338             :                 
    6339           0 :                                         buf.append(" ");
    6340             :                                 }
    6341             :                         }
    6342             :                 }
    6343           0 :                 buf.append(" </" + name + "> ");
    6344           0 :         }
    6345             :         
    6346           0 :         void Parser::toXML(vector<vector< vector< vector<Humidity> > > >data, const string &name, string &buf) {
    6347           0 :                 buf.append("<" + name + "> ");
    6348           0 :                 buf.append("4 ");
    6349           0 :                 buf.append(Integer::toString(data.size()));
    6350           0 :                 buf.append(" ");
    6351           0 :                 buf.append(Integer::toString(data[0].size()));
    6352           0 :                 buf.append(" ");
    6353           0 :                 buf.append(Integer::toString(data[0][0].size()));
    6354           0 :                 buf.append(" ");
    6355           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    6356           0 :                 buf.append(" ");
    6357           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6358           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6359           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    6360           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    6361             :         
    6362           0 :                                                 buf.append(data[i][j][k][l].toString());
    6363             :                 
    6364           0 :                                                 buf.append(" ");
    6365             :                                         }
    6366             :                                 }
    6367             :                         }
    6368             :                 }
    6369           0 :                 buf.append(" </" + name + "> ");
    6370           0 :         }       
    6371             :         
    6372             :                 
    6373             : 
    6374             :         
    6375             :                 
    6376             :         
    6377       15455 :         Humidity Parser::getHumidity(const string &name, const string &tableName, const string &xmlDoc) 
    6378             :         {
    6379       15455 :                 string xmlField = Parser::getField(xmlDoc,name);
    6380       15455 :                 if (xmlField.length() == 0)
    6381           0 :                         throw ConversionException("Error: Missing field \"" + 
    6382           0 :                                 name + "\" or invalid syntax",tableName);
    6383             :         
    6384             :         try {   
    6385       30910 :                         return Humidity (xmlField);
    6386             :                 }
    6387           0 :                 catch (const InvalidArgumentException &e) {
    6388           0 :                         throw ConversionException("Error: message was '"+ 
    6389           0 :                                                    e.getMessage()+
    6390             :                                                    "'",
    6391           0 :                                                    tableName);
    6392           0 :                 }
    6393             :                 
    6394       15455 :         }
    6395             : 
    6396           0 :         vector<Humidity> Parser::get1DHumidity(const string &name, const string &tableName, const string &xmlDoc)
    6397             :         {
    6398           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    6399           0 :                 if (xmlField.length() == 0) {
    6400           0 :                         throw ConversionException("Error: Field \"" + 
    6401           0 :                                         name + "\": Invalid XML syntax", tableName);
    6402             :                 }
    6403           0 :                 StringTokenizer t(xmlField," ");
    6404             :                 try {
    6405           0 :                         int ndim = Integer::parseInt(t.nextToken());
    6406           0 :                         if (ndim != 1) {
    6407           0 :                                 throw ConversionException("Error: Field \"" + 
    6408           0 :                                         name + "\": Invalid array format", tableName);
    6409             :                         }
    6410           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    6411           0 :                         vector<Humidity> value (dim0);
    6412           0 :                         if (dim0 == 0)
    6413           0 :                                 return value;
    6414           0 :                         for (int i = 0; i < dim0; ++i) {
    6415             :         
    6416           0 :                                 value[i] = Humidity::getHumidity(t);
    6417             :         
    6418             :                         }
    6419           0 :                         if (t.hasMoreTokens()) {
    6420           0 :                                 throw ConversionException("Error: Field \"" + 
    6421           0 :                                         name + "\": Syntax error.", tableName);
    6422             :                         }
    6423           0 :                         return value;
    6424           0 :                 } catch (const NumberFormatException &e) {
    6425           0 :                         throw ConversionException("Error: Field \"" + 
    6426           0 :                                 name + "\": " + e.getMessage(), tableName);
    6427           0 :                 } catch (const OutOfBoundsException &e) {
    6428           0 :                         throw  ConversionException("Error: Field \"" + 
    6429           0 :                                 name + "\": Unexpected end of string", tableName);
    6430           0 :                 } catch (const TagFormatException &e) {
    6431           0 :                         throw ConversionException("Error: Field \"" + 
    6432           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6433           0 :                 }               
    6434           0 :         }
    6435             :                 
    6436           0 :         vector< vector<Humidity> > Parser::get2DHumidity(const string &name, const string &tableName, const string &xmlDoc)
    6437             :         {
    6438           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    6439           0 :                 if (xmlField.length() == 0) {
    6440           0 :                         throw ConversionException("Error: Field \"" + 
    6441           0 :                                         name + "\": Invalid XML syntax", tableName);
    6442             :                 }
    6443           0 :                 StringTokenizer t(xmlField," ");
    6444             :                 try {
    6445           0 :                         int ndim = Integer::parseInt(t.nextToken());
    6446           0 :                         if (ndim != 2) {
    6447           0 :                                 throw ConversionException("Error: Field \"" + 
    6448           0 :                                         name + "\": Invalid array format", tableName);
    6449             :                         }
    6450           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    6451           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    6452           0 :                         vector< vector<Humidity> > value;
    6453             : 
    6454           0 :                         if (dim0 == 0 || dim1 == 0)
    6455           0 :                                 return value;
    6456             : 
    6457           0 :                         vector<Humidity> v_aux;
    6458           0 :                         for (int i = 0; i < dim0; ++i) {
    6459           0 :                                 v_aux.clear();
    6460           0 :                                 for (int j = 0; j < dim1; ++j) {
    6461             :         
    6462           0 :                                         v_aux.push_back(Humidity::getHumidity(t));
    6463             :         
    6464             :                                 }
    6465           0 :                                 value.push_back(v_aux);
    6466             :                         }
    6467           0 :                         if (t.hasMoreTokens()) {
    6468           0 :                                 throw ConversionException("Error: Field \"" + 
    6469           0 :                                         name + "\": Syntax error.", tableName);
    6470             :                         }
    6471           0 :                         return value;
    6472           0 :                 } catch (const NumberFormatException &e) {
    6473           0 :                         throw ConversionException("Error: Field \"" + 
    6474           0 :                                 name + "\": " + e.getMessage(), tableName);
    6475           0 :                 } catch (const OutOfBoundsException &e) {
    6476           0 :                         throw  ConversionException("Error: Field \"" + 
    6477           0 :                                 name + "\": Unexpected end of string", tableName);
    6478           0 :                 } catch (const TagFormatException &e) {
    6479           0 :                         throw ConversionException("Error: Field \"" + 
    6480           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6481           0 :                 }               
    6482           0 :         }       
    6483             :         
    6484           0 :         vector< vector< vector<Humidity> > > Parser::get3DHumidity(const string &name, const string &tableName, const string &xmlDoc)
    6485             :         {
    6486           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    6487           0 :                 if (xmlField.length() == 0) {
    6488           0 :                         throw ConversionException("Error: Field \"" + 
    6489           0 :                                         name + "\": Invalid XML syntax", tableName);
    6490             :                 }
    6491           0 :                 StringTokenizer t(xmlField," ");
    6492             :                 try {
    6493           0 :                         int ndim = Integer::parseInt(t.nextToken());
    6494           0 :                         if (ndim != 3) {
    6495           0 :                                 throw ConversionException("Error: Field \"" + 
    6496           0 :                                         name + "\": Invalid array format", tableName);
    6497             :                         }
    6498           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    6499           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    6500           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    6501           0 :                         vector< vector< vector<Humidity> > > value ;
    6502           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    6503           0 :                                 return value;
    6504             :                         
    6505           0 :                         vector<vector<Humidity> > vv_aux;
    6506           0 :                         vector<Humidity> v_aux;
    6507           0 :                         for (int i = 0; i < dim0; ++i) {
    6508           0 :                                 vv_aux.clear();
    6509           0 :                                 for (int j = 0; j < dim1; ++j) {
    6510           0 :                                         v_aux.clear();
    6511           0 :                                         for (int k = 0; k < dim2; ++k) {
    6512             :         
    6513           0 :                                                 v_aux.push_back(Humidity::getHumidity(t));
    6514             :         
    6515             :                                         }
    6516           0 :                                         vv_aux.push_back(v_aux);
    6517             :                                 }
    6518           0 :                                 value.push_back(vv_aux);
    6519             :                         }
    6520           0 :                         if (t.hasMoreTokens()) {
    6521           0 :                                 throw ConversionException("Error: Field \"" + 
    6522           0 :                                         name + "\": Syntax error.", tableName);
    6523             :                         }
    6524           0 :                         return value;
    6525           0 :                 } catch (const NumberFormatException &e) {
    6526           0 :                         throw ConversionException("Error: Field \"" + 
    6527           0 :                                 name + "\": " + e.getMessage(), tableName);
    6528           0 :                 } catch (const OutOfBoundsException &e) {
    6529           0 :                         throw  ConversionException("Error: Field \"" + 
    6530           0 :                                 name + "\": Unexpected end of string", tableName);
    6531           0 :                 } catch (const TagFormatException &e) {
    6532           0 :                         throw ConversionException("Error: Field \"" + 
    6533           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6534           0 :                 }               
    6535           0 :         }
    6536             :         
    6537           0 :         vector< vector< vector< vector<Humidity> > > >Parser::get4DHumidity(const string &name, const string &tableName, const string &xmlDoc)
    6538             :         {
    6539           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    6540           0 :                 if (xmlField.length() == 0) {
    6541           0 :                         throw ConversionException("Error: Field \"" + 
    6542           0 :                                         name + "\": Invalid XML syntax", tableName);
    6543             :                 }
    6544           0 :                 StringTokenizer t(xmlField," ");
    6545             :                 try {
    6546           0 :                         int ndim = Integer::parseInt(t.nextToken());
    6547           0 :                         if (ndim != 4) {
    6548           0 :                                 throw ConversionException("Error: Field \"" + 
    6549           0 :                                         name + "\": Invalid array format", tableName);
    6550             :                         }
    6551           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    6552           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    6553           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    6554           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    6555           0 :                         vector<vector< vector< vector<Humidity> > > >value;
    6556           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    6557           0 :                                 return value;
    6558             :                         
    6559           0 :                         vector<vector<vector<Humidity> > >vvv_aux;
    6560           0 :                         vector<vector< Humidity> > vv_aux;
    6561           0 :                         vector<Humidity> v_aux;
    6562           0 :                         for (int i = 0; i < dim0; ++i) {
    6563           0 :                                 vvv_aux.clear();
    6564           0 :                                 for (int j = 0; j < dim1; ++j) {
    6565           0 :                                         vv_aux.clear();
    6566           0 :                                         for (int k = 0; k < dim2; ++k) {
    6567           0 :                                                 v_aux.clear();
    6568           0 :                                                 for (int l = 0; l < dim3; l++) {
    6569             :         
    6570           0 :                                                         v_aux.push_back(Humidity::getHumidity(t));
    6571             :         
    6572             :                                                 }
    6573           0 :                                                 vv_aux.push_back(v_aux);
    6574             :                                         }
    6575           0 :                                         vvv_aux.push_back(vv_aux);
    6576             :                                 }
    6577           0 :                                 value.push_back(vvv_aux);
    6578             :                         }
    6579           0 :                         if (t.hasMoreTokens()) {
    6580           0 :                                 throw ConversionException("Error: Field \"" + 
    6581           0 :                                         name + "\": Syntax error.", tableName);
    6582             :                         }
    6583           0 :                         return value;
    6584           0 :                 } catch (const NumberFormatException &e) {
    6585           0 :                         throw ConversionException("Error: Field \"" + 
    6586           0 :                                 name + "\": " + e.getMessage(), tableName);
    6587           0 :                 } catch (const OutOfBoundsException &e) {
    6588           0 :                         throw  ConversionException("Error: Field \"" + 
    6589           0 :                                 name + "\": Unexpected end of string", tableName);
    6590           0 :                 } catch (const TagFormatException &e) {
    6591           0 :                         throw ConversionException("Error: Field \"" + 
    6592           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6593           0 :                 }               
    6594           0 :         }       
    6595             :         
    6596             : 
    6597             :                 
    6598             : 
    6599             : 
    6600             :         // Field type: Interval
    6601             : 
    6602         767 :         void Parser::toXML(Interval data, const string &name, string &buf) {
    6603         767 :                 buf.append("<" + name + "> ");
    6604             :         
    6605         767 :                 buf.append(data.toString());
    6606             :                 
    6607         767 :                 buf.append(" </" + name + "> ");
    6608         767 :         }
    6609             : 
    6610             :         
    6611             :         
    6612             :         
    6613          13 :         void Parser::toXML(vector<Interval> data, const string &name, string &buf) {
    6614          13 :                 buf.append("<" + name + "> ");
    6615          13 :                 buf.append("1 ");
    6616          13 :                 buf.append(Integer::toString(data.size()));
    6617          13 :                 buf.append(" ");
    6618          26 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6619             :         
    6620          13 :                         buf.append(data[i].toString());
    6621             :                 
    6622          13 :                         buf.append(" ");
    6623             :                 }
    6624          13 :                 buf.append(" </" + name + "> ");
    6625          13 :         }
    6626             : 
    6627           0 :         void Parser::toXML(vector< vector<Interval> > data, const string &name, string &buf) {
    6628           0 :                 buf.append("<" + name + "> ");
    6629           0 :                 buf.append("2 ");
    6630           0 :                 buf.append(Integer::toString(data.size()));
    6631           0 :                 buf.append(" ");
    6632           0 :                 buf.append(Integer::toString(data[0].size()));
    6633           0 :                 buf.append(" ");
    6634           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6635           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6636             :         
    6637           0 :                                 buf.append(data[i][j].toString());
    6638             :                 
    6639           0 :                                 buf.append(" ");
    6640             :                         }
    6641             :                 }
    6642           0 :                 buf.append(" </" + name + "> ");
    6643           0 :         }
    6644             :         
    6645           0 :         void Parser::toXML(vector< vector< vector<Interval> > > data, const string &name, string &buf) {
    6646           0 :                 buf.append("<" + name + "> ");
    6647           0 :                 buf.append("3 ");
    6648           0 :                 buf.append(Integer::toString(data.size()));
    6649           0 :                 buf.append(" ");
    6650           0 :                 buf.append(Integer::toString(data[0].size()));
    6651           0 :                 buf.append(" ");
    6652           0 :                 buf.append(Integer::toString(data[0][0].size()));
    6653           0 :                 buf.append(" ");
    6654           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6655           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6656           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    6657             :         
    6658           0 :                                         buf.append(data[i][j][k].toString());
    6659             :                 
    6660           0 :                                         buf.append(" ");
    6661             :                                 }
    6662             :                         }
    6663             :                 }
    6664           0 :                 buf.append(" </" + name + "> ");
    6665           0 :         }
    6666             :         
    6667           0 :         void Parser::toXML(vector<vector< vector< vector<Interval> > > >data, const string &name, string &buf) {
    6668           0 :                 buf.append("<" + name + "> ");
    6669           0 :                 buf.append("4 ");
    6670           0 :                 buf.append(Integer::toString(data.size()));
    6671           0 :                 buf.append(" ");
    6672           0 :                 buf.append(Integer::toString(data[0].size()));
    6673           0 :                 buf.append(" ");
    6674           0 :                 buf.append(Integer::toString(data[0][0].size()));
    6675           0 :                 buf.append(" ");
    6676           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    6677           0 :                 buf.append(" ");
    6678           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6679           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6680           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    6681           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    6682             :         
    6683           0 :                                                 buf.append(data[i][j][k][l].toString());
    6684             :                 
    6685           0 :                                                 buf.append(" ");
    6686             :                                         }
    6687             :                                 }
    6688             :                         }
    6689             :                 }
    6690           0 :                 buf.append(" </" + name + "> ");
    6691           0 :         }       
    6692             :         
    6693             :                 
    6694             : 
    6695             :         
    6696             :                 
    6697             :         
    6698        7890 :         Interval Parser::getInterval(const string &name, const string &tableName, const string &xmlDoc) 
    6699             :         {
    6700        7890 :                 string xmlField = Parser::getField(xmlDoc,name);
    6701        7890 :                 if (xmlField.length() == 0)
    6702           0 :                         throw ConversionException("Error: Missing field \"" + 
    6703           0 :                                 name + "\" or invalid syntax",tableName);
    6704             :         
    6705             :         try {   
    6706       15780 :                         return Interval (xmlField);
    6707             :                 }
    6708           0 :                 catch (const InvalidArgumentException &e) {
    6709           0 :                         throw ConversionException("Error: message was '"+ 
    6710           0 :                                                    e.getMessage()+
    6711             :                                                    "'",
    6712           0 :                                                    tableName);
    6713           0 :                 }
    6714             :                 
    6715        7890 :         }
    6716             : 
    6717          78 :         vector<Interval> Parser::get1DInterval(const string &name, const string &tableName, const string &xmlDoc)
    6718             :         {
    6719          78 :                 string xmlField = Parser::getField(xmlDoc,name);
    6720          78 :                 if (xmlField.length() == 0) {
    6721           0 :                         throw ConversionException("Error: Field \"" + 
    6722           0 :                                         name + "\": Invalid XML syntax", tableName);
    6723             :                 }
    6724         156 :                 StringTokenizer t(xmlField," ");
    6725             :                 try {
    6726          78 :                         int ndim = Integer::parseInt(t.nextToken());
    6727          78 :                         if (ndim != 1) {
    6728           0 :                                 throw ConversionException("Error: Field \"" + 
    6729           0 :                                         name + "\": Invalid array format", tableName);
    6730             :                         }
    6731          78 :                         int dim0 = Integer::parseInt(t.nextToken());
    6732          78 :                         vector<Interval> value (dim0);
    6733          78 :                         if (dim0 == 0)
    6734           0 :                                 return value;
    6735         156 :                         for (int i = 0; i < dim0; ++i) {
    6736             :         
    6737          78 :                                 value[i] = Interval::getInterval(t);
    6738             :         
    6739             :                         }
    6740          78 :                         if (t.hasMoreTokens()) {
    6741           0 :                                 throw ConversionException("Error: Field \"" + 
    6742           0 :                                         name + "\": Syntax error.", tableName);
    6743             :                         }
    6744          78 :                         return value;
    6745          78 :                 } catch (const NumberFormatException &e) {
    6746           0 :                         throw ConversionException("Error: Field \"" + 
    6747           0 :                                 name + "\": " + e.getMessage(), tableName);
    6748           0 :                 } catch (const OutOfBoundsException &e) {
    6749           0 :                         throw  ConversionException("Error: Field \"" + 
    6750           0 :                                 name + "\": Unexpected end of string", tableName);
    6751           0 :                 } catch (const TagFormatException &e) {
    6752           0 :                         throw ConversionException("Error: Field \"" + 
    6753           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6754           0 :                 }               
    6755          78 :         }
    6756             :                 
    6757           0 :         vector< vector<Interval> > Parser::get2DInterval(const string &name, const string &tableName, const string &xmlDoc)
    6758             :         {
    6759           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    6760           0 :                 if (xmlField.length() == 0) {
    6761           0 :                         throw ConversionException("Error: Field \"" + 
    6762           0 :                                         name + "\": Invalid XML syntax", tableName);
    6763             :                 }
    6764           0 :                 StringTokenizer t(xmlField," ");
    6765             :                 try {
    6766           0 :                         int ndim = Integer::parseInt(t.nextToken());
    6767           0 :                         if (ndim != 2) {
    6768           0 :                                 throw ConversionException("Error: Field \"" + 
    6769           0 :                                         name + "\": Invalid array format", tableName);
    6770             :                         }
    6771           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    6772           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    6773           0 :                         vector< vector<Interval> > value;
    6774             : 
    6775           0 :                         if (dim0 == 0 || dim1 == 0)
    6776           0 :                                 return value;
    6777             : 
    6778           0 :                         vector<Interval> v_aux;
    6779           0 :                         for (int i = 0; i < dim0; ++i) {
    6780           0 :                                 v_aux.clear();
    6781           0 :                                 for (int j = 0; j < dim1; ++j) {
    6782             :         
    6783           0 :                                         v_aux.push_back(Interval::getInterval(t));
    6784             :         
    6785             :                                 }
    6786           0 :                                 value.push_back(v_aux);
    6787             :                         }
    6788           0 :                         if (t.hasMoreTokens()) {
    6789           0 :                                 throw ConversionException("Error: Field \"" + 
    6790           0 :                                         name + "\": Syntax error.", tableName);
    6791             :                         }
    6792           0 :                         return value;
    6793           0 :                 } catch (const NumberFormatException &e) {
    6794           0 :                         throw ConversionException("Error: Field \"" + 
    6795           0 :                                 name + "\": " + e.getMessage(), tableName);
    6796           0 :                 } catch (const OutOfBoundsException &e) {
    6797           0 :                         throw  ConversionException("Error: Field \"" + 
    6798           0 :                                 name + "\": Unexpected end of string", tableName);
    6799           0 :                 } catch (const TagFormatException &e) {
    6800           0 :                         throw ConversionException("Error: Field \"" + 
    6801           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6802           0 :                 }               
    6803           0 :         }       
    6804             :         
    6805           0 :         vector< vector< vector<Interval> > > Parser::get3DInterval(const string &name, const string &tableName, const string &xmlDoc)
    6806             :         {
    6807           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    6808           0 :                 if (xmlField.length() == 0) {
    6809           0 :                         throw ConversionException("Error: Field \"" + 
    6810           0 :                                         name + "\": Invalid XML syntax", tableName);
    6811             :                 }
    6812           0 :                 StringTokenizer t(xmlField," ");
    6813             :                 try {
    6814           0 :                         int ndim = Integer::parseInt(t.nextToken());
    6815           0 :                         if (ndim != 3) {
    6816           0 :                                 throw ConversionException("Error: Field \"" + 
    6817           0 :                                         name + "\": Invalid array format", tableName);
    6818             :                         }
    6819           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    6820           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    6821           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    6822           0 :                         vector< vector< vector<Interval> > > value ;
    6823           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    6824           0 :                                 return value;
    6825             :                         
    6826           0 :                         vector<vector<Interval> > vv_aux;
    6827           0 :                         vector<Interval> v_aux;
    6828           0 :                         for (int i = 0; i < dim0; ++i) {
    6829           0 :                                 vv_aux.clear();
    6830           0 :                                 for (int j = 0; j < dim1; ++j) {
    6831           0 :                                         v_aux.clear();
    6832           0 :                                         for (int k = 0; k < dim2; ++k) {
    6833             :         
    6834           0 :                                                 v_aux.push_back(Interval::getInterval(t));
    6835             :         
    6836             :                                         }
    6837           0 :                                         vv_aux.push_back(v_aux);
    6838             :                                 }
    6839           0 :                                 value.push_back(vv_aux);
    6840             :                         }
    6841           0 :                         if (t.hasMoreTokens()) {
    6842           0 :                                 throw ConversionException("Error: Field \"" + 
    6843           0 :                                         name + "\": Syntax error.", tableName);
    6844             :                         }
    6845           0 :                         return value;
    6846           0 :                 } catch (const NumberFormatException &e) {
    6847           0 :                         throw ConversionException("Error: Field \"" + 
    6848           0 :                                 name + "\": " + e.getMessage(), tableName);
    6849           0 :                 } catch (const OutOfBoundsException &e) {
    6850           0 :                         throw  ConversionException("Error: Field \"" + 
    6851           0 :                                 name + "\": Unexpected end of string", tableName);
    6852           0 :                 } catch (const TagFormatException &e) {
    6853           0 :                         throw ConversionException("Error: Field \"" + 
    6854           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6855           0 :                 }               
    6856           0 :         }
    6857             :         
    6858           0 :         vector< vector< vector< vector<Interval> > > >Parser::get4DInterval(const string &name, const string &tableName, const string &xmlDoc)
    6859             :         {
    6860           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    6861           0 :                 if (xmlField.length() == 0) {
    6862           0 :                         throw ConversionException("Error: Field \"" + 
    6863           0 :                                         name + "\": Invalid XML syntax", tableName);
    6864             :                 }
    6865           0 :                 StringTokenizer t(xmlField," ");
    6866             :                 try {
    6867           0 :                         int ndim = Integer::parseInt(t.nextToken());
    6868           0 :                         if (ndim != 4) {
    6869           0 :                                 throw ConversionException("Error: Field \"" + 
    6870           0 :                                         name + "\": Invalid array format", tableName);
    6871             :                         }
    6872           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    6873           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    6874           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    6875           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    6876           0 :                         vector<vector< vector< vector<Interval> > > >value;
    6877           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    6878           0 :                                 return value;
    6879             :                         
    6880           0 :                         vector<vector<vector<Interval> > >vvv_aux;
    6881           0 :                         vector<vector< Interval> > vv_aux;
    6882           0 :                         vector<Interval> v_aux;
    6883           0 :                         for (int i = 0; i < dim0; ++i) {
    6884           0 :                                 vvv_aux.clear();
    6885           0 :                                 for (int j = 0; j < dim1; ++j) {
    6886           0 :                                         vv_aux.clear();
    6887           0 :                                         for (int k = 0; k < dim2; ++k) {
    6888           0 :                                                 v_aux.clear();
    6889           0 :                                                 for (int l = 0; l < dim3; l++) {
    6890             :         
    6891           0 :                                                         v_aux.push_back(Interval::getInterval(t));
    6892             :         
    6893             :                                                 }
    6894           0 :                                                 vv_aux.push_back(v_aux);
    6895             :                                         }
    6896           0 :                                         vvv_aux.push_back(vv_aux);
    6897             :                                 }
    6898           0 :                                 value.push_back(vvv_aux);
    6899             :                         }
    6900           0 :                         if (t.hasMoreTokens()) {
    6901           0 :                                 throw ConversionException("Error: Field \"" + 
    6902           0 :                                         name + "\": Syntax error.", tableName);
    6903             :                         }
    6904           0 :                         return value;
    6905           0 :                 } catch (const NumberFormatException &e) {
    6906           0 :                         throw ConversionException("Error: Field \"" + 
    6907           0 :                                 name + "\": " + e.getMessage(), tableName);
    6908           0 :                 } catch (const OutOfBoundsException &e) {
    6909           0 :                         throw  ConversionException("Error: Field \"" + 
    6910           0 :                                 name + "\": Unexpected end of string", tableName);
    6911           0 :                 } catch (const TagFormatException &e) {
    6912           0 :                         throw ConversionException("Error: Field \"" + 
    6913           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    6914           0 :                 }               
    6915           0 :         }       
    6916             :         
    6917             : 
    6918             :                 
    6919             : 
    6920             : 
    6921             :         // Field type: Length
    6922             : 
    6923        1587 :         void Parser::toXML(Length data, const string &name, string &buf) {
    6924        1587 :                 buf.append("<" + name + "> ");
    6925             :         
    6926        1587 :                 buf.append(data.toString());
    6927             :                 
    6928        1587 :                 buf.append(" </" + name + "> ");
    6929        1587 :         }
    6930             : 
    6931             :         
    6932             :         
    6933             :         
    6934        1649 :         void Parser::toXML(vector<Length> data, const string &name, string &buf) {
    6935        1649 :                 buf.append("<" + name + "> ");
    6936        1649 :                 buf.append("1 ");
    6937        1649 :                 buf.append(Integer::toString(data.size()));
    6938        1649 :                 buf.append(" ");
    6939        6596 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6940             :         
    6941        4947 :                         buf.append(data[i].toString());
    6942             :                 
    6943        4947 :                         buf.append(" ");
    6944             :                 }
    6945        1649 :                 buf.append(" </" + name + "> ");
    6946        1649 :         }
    6947             : 
    6948         896 :         void Parser::toXML(vector< vector<Length> > data, const string &name, string &buf) {
    6949         896 :                 buf.append("<" + name + "> ");
    6950         896 :                 buf.append("2 ");
    6951         896 :                 buf.append(Integer::toString(data.size()));
    6952         896 :                 buf.append(" ");
    6953         896 :                 buf.append(Integer::toString(data[0].size()));
    6954         896 :                 buf.append(" ");
    6955        2688 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6956        7168 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6957             :         
    6958        5376 :                                 buf.append(data[i][j].toString());
    6959             :                 
    6960        5376 :                                 buf.append(" ");
    6961             :                         }
    6962             :                 }
    6963         896 :                 buf.append(" </" + name + "> ");
    6964         896 :         }
    6965             :         
    6966           0 :         void Parser::toXML(vector< vector< vector<Length> > > data, const string &name, string &buf) {
    6967           0 :                 buf.append("<" + name + "> ");
    6968           0 :                 buf.append("3 ");
    6969           0 :                 buf.append(Integer::toString(data.size()));
    6970           0 :                 buf.append(" ");
    6971           0 :                 buf.append(Integer::toString(data[0].size()));
    6972           0 :                 buf.append(" ");
    6973           0 :                 buf.append(Integer::toString(data[0][0].size()));
    6974           0 :                 buf.append(" ");
    6975           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    6976           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    6977           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    6978             :         
    6979           0 :                                         buf.append(data[i][j][k].toString());
    6980             :                 
    6981           0 :                                         buf.append(" ");
    6982             :                                 }
    6983             :                         }
    6984             :                 }
    6985           0 :                 buf.append(" </" + name + "> ");
    6986           0 :         }
    6987             :         
    6988           0 :         void Parser::toXML(vector<vector< vector< vector<Length> > > >data, const string &name, string &buf) {
    6989           0 :                 buf.append("<" + name + "> ");
    6990           0 :                 buf.append("4 ");
    6991           0 :                 buf.append(Integer::toString(data.size()));
    6992           0 :                 buf.append(" ");
    6993           0 :                 buf.append(Integer::toString(data[0].size()));
    6994           0 :                 buf.append(" ");
    6995           0 :                 buf.append(Integer::toString(data[0][0].size()));
    6996           0 :                 buf.append(" ");
    6997           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    6998           0 :                 buf.append(" ");
    6999           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7000           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7001           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    7002           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    7003             :         
    7004           0 :                                                 buf.append(data[i][j][k][l].toString());
    7005             :                 
    7006           0 :                                                 buf.append(" ");
    7007             :                                         }
    7008             :                                 }
    7009             :                         }
    7010             :                 }
    7011           0 :                 buf.append(" </" + name + "> ");
    7012           0 :         }       
    7013             :         
    7014             :                 
    7015             : 
    7016             :         
    7017             :                 
    7018             :         
    7019        2516 :         Length Parser::getLength(const string &name, const string &tableName, const string &xmlDoc) 
    7020             :         {
    7021        2516 :                 string xmlField = Parser::getField(xmlDoc,name);
    7022        2516 :                 if (xmlField.length() == 0)
    7023           0 :                         throw ConversionException("Error: Missing field \"" + 
    7024           0 :                                 name + "\" or invalid syntax",tableName);
    7025             :         
    7026             :         try {   
    7027        5032 :                         return Length (xmlField);
    7028             :                 }
    7029           0 :                 catch (const InvalidArgumentException &e) {
    7030           0 :                         throw ConversionException("Error: message was '"+ 
    7031           0 :                                                    e.getMessage()+
    7032             :                                                    "'",
    7033           0 :                                                    tableName);
    7034           0 :                 }
    7035             :                 
    7036        2516 :         }
    7037             : 
    7038        5619 :         vector<Length> Parser::get1DLength(const string &name, const string &tableName, const string &xmlDoc)
    7039             :         {
    7040        5619 :                 string xmlField = Parser::getField(xmlDoc,name);
    7041        5619 :                 if (xmlField.length() == 0) {
    7042           0 :                         throw ConversionException("Error: Field \"" + 
    7043           0 :                                         name + "\": Invalid XML syntax", tableName);
    7044             :                 }
    7045       11238 :                 StringTokenizer t(xmlField," ");
    7046             :                 try {
    7047        5619 :                         int ndim = Integer::parseInt(t.nextToken());
    7048        5619 :                         if (ndim != 1) {
    7049           0 :                                 throw ConversionException("Error: Field \"" + 
    7050           0 :                                         name + "\": Invalid array format", tableName);
    7051             :                         }
    7052        5619 :                         int dim0 = Integer::parseInt(t.nextToken());
    7053        5619 :                         vector<Length> value (dim0);
    7054        5619 :                         if (dim0 == 0)
    7055           0 :                                 return value;
    7056       22476 :                         for (int i = 0; i < dim0; ++i) {
    7057             :         
    7058       16857 :                                 value[i] = Length::getLength(t);
    7059             :         
    7060             :                         }
    7061        5619 :                         if (t.hasMoreTokens()) {
    7062           0 :                                 throw ConversionException("Error: Field \"" + 
    7063           0 :                                         name + "\": Syntax error.", tableName);
    7064             :                         }
    7065        5619 :                         return value;
    7066        5619 :                 } catch (const NumberFormatException &e) {
    7067           0 :                         throw ConversionException("Error: Field \"" + 
    7068           0 :                                 name + "\": " + e.getMessage(), tableName);
    7069           0 :                 } catch (const OutOfBoundsException &e) {
    7070           0 :                         throw  ConversionException("Error: Field \"" + 
    7071           0 :                                 name + "\": Unexpected end of string", tableName);
    7072           0 :                 } catch (const TagFormatException &e) {
    7073           0 :                         throw ConversionException("Error: Field \"" + 
    7074           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7075           0 :                 }               
    7076        5619 :         }
    7077             :                 
    7078       67308 :         vector< vector<Length> > Parser::get2DLength(const string &name, const string &tableName, const string &xmlDoc)
    7079             :         {
    7080       67308 :                 string xmlField = Parser::getField(xmlDoc,name);
    7081       67308 :                 if (xmlField.length() == 0) {
    7082           0 :                         throw ConversionException("Error: Field \"" + 
    7083           0 :                                         name + "\": Invalid XML syntax", tableName);
    7084             :                 }
    7085      134616 :                 StringTokenizer t(xmlField," ");
    7086             :                 try {
    7087       67308 :                         int ndim = Integer::parseInt(t.nextToken());
    7088       67308 :                         if (ndim != 2) {
    7089           0 :                                 throw ConversionException("Error: Field \"" + 
    7090           0 :                                         name + "\": Invalid array format", tableName);
    7091             :                         }
    7092       67308 :                         int dim0 = Integer::parseInt(t.nextToken());
    7093       67308 :                         int dim1 = Integer::parseInt(t.nextToken());
    7094       67308 :                         vector< vector<Length> > value;
    7095             : 
    7096       67308 :                         if (dim0 == 0 || dim1 == 0)
    7097           0 :                                 return value;
    7098             : 
    7099       67308 :                         vector<Length> v_aux;
    7100      201908 :                         for (int i = 0; i < dim0; ++i) {
    7101      134600 :                                 v_aux.clear();
    7102      538400 :                                 for (int j = 0; j < dim1; ++j) {
    7103             :         
    7104      403800 :                                         v_aux.push_back(Length::getLength(t));
    7105             :         
    7106             :                                 }
    7107      134600 :                                 value.push_back(v_aux);
    7108             :                         }
    7109       67308 :                         if (t.hasMoreTokens()) {
    7110           0 :                                 throw ConversionException("Error: Field \"" + 
    7111           0 :                                         name + "\": Syntax error.", tableName);
    7112             :                         }
    7113       67308 :                         return value;
    7114       67308 :                 } catch (const NumberFormatException &e) {
    7115           0 :                         throw ConversionException("Error: Field \"" + 
    7116           0 :                                 name + "\": " + e.getMessage(), tableName);
    7117           0 :                 } catch (const OutOfBoundsException &e) {
    7118           0 :                         throw  ConversionException("Error: Field \"" + 
    7119           0 :                                 name + "\": Unexpected end of string", tableName);
    7120           0 :                 } catch (const TagFormatException &e) {
    7121           0 :                         throw ConversionException("Error: Field \"" + 
    7122           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7123           0 :                 }               
    7124       67308 :         }       
    7125             :         
    7126           0 :         vector< vector< vector<Length> > > Parser::get3DLength(const string &name, const string &tableName, const string &xmlDoc)
    7127             :         {
    7128           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7129           0 :                 if (xmlField.length() == 0) {
    7130           0 :                         throw ConversionException("Error: Field \"" + 
    7131           0 :                                         name + "\": Invalid XML syntax", tableName);
    7132             :                 }
    7133           0 :                 StringTokenizer t(xmlField," ");
    7134             :                 try {
    7135           0 :                         int ndim = Integer::parseInt(t.nextToken());
    7136           0 :                         if (ndim != 3) {
    7137           0 :                                 throw ConversionException("Error: Field \"" + 
    7138           0 :                                         name + "\": Invalid array format", tableName);
    7139             :                         }
    7140           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    7141           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    7142           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    7143           0 :                         vector< vector< vector<Length> > > value ;
    7144           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    7145           0 :                                 return value;
    7146             :                         
    7147           0 :                         vector<vector<Length> > vv_aux;
    7148           0 :                         vector<Length> v_aux;
    7149           0 :                         for (int i = 0; i < dim0; ++i) {
    7150           0 :                                 vv_aux.clear();
    7151           0 :                                 for (int j = 0; j < dim1; ++j) {
    7152           0 :                                         v_aux.clear();
    7153           0 :                                         for (int k = 0; k < dim2; ++k) {
    7154             :         
    7155           0 :                                                 v_aux.push_back(Length::getLength(t));
    7156             :         
    7157             :                                         }
    7158           0 :                                         vv_aux.push_back(v_aux);
    7159             :                                 }
    7160           0 :                                 value.push_back(vv_aux);
    7161             :                         }
    7162           0 :                         if (t.hasMoreTokens()) {
    7163           0 :                                 throw ConversionException("Error: Field \"" + 
    7164           0 :                                         name + "\": Syntax error.", tableName);
    7165             :                         }
    7166           0 :                         return value;
    7167           0 :                 } catch (const NumberFormatException &e) {
    7168           0 :                         throw ConversionException("Error: Field \"" + 
    7169           0 :                                 name + "\": " + e.getMessage(), tableName);
    7170           0 :                 } catch (const OutOfBoundsException &e) {
    7171           0 :                         throw  ConversionException("Error: Field \"" + 
    7172           0 :                                 name + "\": Unexpected end of string", tableName);
    7173           0 :                 } catch (const TagFormatException &e) {
    7174           0 :                         throw ConversionException("Error: Field \"" + 
    7175           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7176           0 :                 }               
    7177           0 :         }
    7178             :         
    7179           0 :         vector< vector< vector< vector<Length> > > >Parser::get4DLength(const string &name, const string &tableName, const string &xmlDoc)
    7180             :         {
    7181           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7182           0 :                 if (xmlField.length() == 0) {
    7183           0 :                         throw ConversionException("Error: Field \"" + 
    7184           0 :                                         name + "\": Invalid XML syntax", tableName);
    7185             :                 }
    7186           0 :                 StringTokenizer t(xmlField," ");
    7187             :                 try {
    7188           0 :                         int ndim = Integer::parseInt(t.nextToken());
    7189           0 :                         if (ndim != 4) {
    7190           0 :                                 throw ConversionException("Error: Field \"" + 
    7191           0 :                                         name + "\": Invalid array format", tableName);
    7192             :                         }
    7193           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    7194           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    7195           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    7196           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    7197           0 :                         vector<vector< vector< vector<Length> > > >value;
    7198           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    7199           0 :                                 return value;
    7200             :                         
    7201           0 :                         vector<vector<vector<Length> > >vvv_aux;
    7202           0 :                         vector<vector< Length> > vv_aux;
    7203           0 :                         vector<Length> v_aux;
    7204           0 :                         for (int i = 0; i < dim0; ++i) {
    7205           0 :                                 vvv_aux.clear();
    7206           0 :                                 for (int j = 0; j < dim1; ++j) {
    7207           0 :                                         vv_aux.clear();
    7208           0 :                                         for (int k = 0; k < dim2; ++k) {
    7209           0 :                                                 v_aux.clear();
    7210           0 :                                                 for (int l = 0; l < dim3; l++) {
    7211             :         
    7212           0 :                                                         v_aux.push_back(Length::getLength(t));
    7213             :         
    7214             :                                                 }
    7215           0 :                                                 vv_aux.push_back(v_aux);
    7216             :                                         }
    7217           0 :                                         vvv_aux.push_back(vv_aux);
    7218             :                                 }
    7219           0 :                                 value.push_back(vvv_aux);
    7220             :                         }
    7221           0 :                         if (t.hasMoreTokens()) {
    7222           0 :                                 throw ConversionException("Error: Field \"" + 
    7223           0 :                                         name + "\": Syntax error.", tableName);
    7224             :                         }
    7225           0 :                         return value;
    7226           0 :                 } catch (const NumberFormatException &e) {
    7227           0 :                         throw ConversionException("Error: Field \"" + 
    7228           0 :                                 name + "\": " + e.getMessage(), tableName);
    7229           0 :                 } catch (const OutOfBoundsException &e) {
    7230           0 :                         throw  ConversionException("Error: Field \"" + 
    7231           0 :                                 name + "\": Unexpected end of string", tableName);
    7232           0 :                 } catch (const TagFormatException &e) {
    7233           0 :                         throw ConversionException("Error: Field \"" + 
    7234           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7235           0 :                 }               
    7236           0 :         }       
    7237             :         
    7238             : 
    7239             :                 
    7240             : 
    7241             : 
    7242             :         // Field type: Pressure
    7243             : 
    7244           0 :         void Parser::toXML(Pressure data, const string &name, string &buf) {
    7245           0 :                 buf.append("<" + name + "> ");
    7246             :         
    7247           0 :                 buf.append(data.toString());
    7248             :                 
    7249           0 :                 buf.append(" </" + name + "> ");
    7250           0 :         }
    7251             : 
    7252             :         
    7253             :         
    7254             :         
    7255           0 :         void Parser::toXML(vector<Pressure> data, const string &name, string &buf) {
    7256           0 :                 buf.append("<" + name + "> ");
    7257           0 :                 buf.append("1 ");
    7258           0 :                 buf.append(Integer::toString(data.size()));
    7259           0 :                 buf.append(" ");
    7260           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7261             :         
    7262           0 :                         buf.append(data[i].toString());
    7263             :                 
    7264           0 :                         buf.append(" ");
    7265             :                 }
    7266           0 :                 buf.append(" </" + name + "> ");
    7267           0 :         }
    7268             : 
    7269           0 :         void Parser::toXML(vector< vector<Pressure> > data, const string &name, string &buf) {
    7270           0 :                 buf.append("<" + name + "> ");
    7271           0 :                 buf.append("2 ");
    7272           0 :                 buf.append(Integer::toString(data.size()));
    7273           0 :                 buf.append(" ");
    7274           0 :                 buf.append(Integer::toString(data[0].size()));
    7275           0 :                 buf.append(" ");
    7276           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7277           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7278             :         
    7279           0 :                                 buf.append(data[i][j].toString());
    7280             :                 
    7281           0 :                                 buf.append(" ");
    7282             :                         }
    7283             :                 }
    7284           0 :                 buf.append(" </" + name + "> ");
    7285           0 :         }
    7286             :         
    7287           0 :         void Parser::toXML(vector< vector< vector<Pressure> > > data, const string &name, string &buf) {
    7288           0 :                 buf.append("<" + name + "> ");
    7289           0 :                 buf.append("3 ");
    7290           0 :                 buf.append(Integer::toString(data.size()));
    7291           0 :                 buf.append(" ");
    7292           0 :                 buf.append(Integer::toString(data[0].size()));
    7293           0 :                 buf.append(" ");
    7294           0 :                 buf.append(Integer::toString(data[0][0].size()));
    7295           0 :                 buf.append(" ");
    7296           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7297           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7298           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    7299             :         
    7300           0 :                                         buf.append(data[i][j][k].toString());
    7301             :                 
    7302           0 :                                         buf.append(" ");
    7303             :                                 }
    7304             :                         }
    7305             :                 }
    7306           0 :                 buf.append(" </" + name + "> ");
    7307           0 :         }
    7308             :         
    7309           0 :         void Parser::toXML(vector<vector< vector< vector<Pressure> > > >data, const string &name, string &buf) {
    7310           0 :                 buf.append("<" + name + "> ");
    7311           0 :                 buf.append("4 ");
    7312           0 :                 buf.append(Integer::toString(data.size()));
    7313           0 :                 buf.append(" ");
    7314           0 :                 buf.append(Integer::toString(data[0].size()));
    7315           0 :                 buf.append(" ");
    7316           0 :                 buf.append(Integer::toString(data[0][0].size()));
    7317           0 :                 buf.append(" ");
    7318           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    7319           0 :                 buf.append(" ");
    7320           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7321           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7322           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    7323           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    7324             :         
    7325           0 :                                                 buf.append(data[i][j][k][l].toString());
    7326             :                 
    7327           0 :                                                 buf.append(" ");
    7328             :                                         }
    7329             :                                 }
    7330             :                         }
    7331             :                 }
    7332           0 :                 buf.append(" </" + name + "> ");
    7333           0 :         }       
    7334             :         
    7335             :                 
    7336             : 
    7337             :         
    7338             :                 
    7339             :         
    7340       15455 :         Pressure Parser::getPressure(const string &name, const string &tableName, const string &xmlDoc) 
    7341             :         {
    7342       15455 :                 string xmlField = Parser::getField(xmlDoc,name);
    7343       15455 :                 if (xmlField.length() == 0)
    7344           0 :                         throw ConversionException("Error: Missing field \"" + 
    7345           0 :                                 name + "\" or invalid syntax",tableName);
    7346             :         
    7347             :         try {   
    7348       30910 :                         return Pressure (xmlField);
    7349             :                 }
    7350           0 :                 catch (const InvalidArgumentException &e) {
    7351           0 :                         throw ConversionException("Error: message was '"+ 
    7352           0 :                                                    e.getMessage()+
    7353             :                                                    "'",
    7354           0 :                                                    tableName);
    7355           0 :                 }
    7356             :                 
    7357       15455 :         }
    7358             : 
    7359           0 :         vector<Pressure> Parser::get1DPressure(const string &name, const string &tableName, const string &xmlDoc)
    7360             :         {
    7361           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7362           0 :                 if (xmlField.length() == 0) {
    7363           0 :                         throw ConversionException("Error: Field \"" + 
    7364           0 :                                         name + "\": Invalid XML syntax", tableName);
    7365             :                 }
    7366           0 :                 StringTokenizer t(xmlField," ");
    7367             :                 try {
    7368           0 :                         int ndim = Integer::parseInt(t.nextToken());
    7369           0 :                         if (ndim != 1) {
    7370           0 :                                 throw ConversionException("Error: Field \"" + 
    7371           0 :                                         name + "\": Invalid array format", tableName);
    7372             :                         }
    7373           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    7374           0 :                         vector<Pressure> value (dim0);
    7375           0 :                         if (dim0 == 0)
    7376           0 :                                 return value;
    7377           0 :                         for (int i = 0; i < dim0; ++i) {
    7378             :         
    7379           0 :                                 value[i] = Pressure::getPressure(t);
    7380             :         
    7381             :                         }
    7382           0 :                         if (t.hasMoreTokens()) {
    7383           0 :                                 throw ConversionException("Error: Field \"" + 
    7384           0 :                                         name + "\": Syntax error.", tableName);
    7385             :                         }
    7386           0 :                         return value;
    7387           0 :                 } catch (const NumberFormatException &e) {
    7388           0 :                         throw ConversionException("Error: Field \"" + 
    7389           0 :                                 name + "\": " + e.getMessage(), tableName);
    7390           0 :                 } catch (const OutOfBoundsException &e) {
    7391           0 :                         throw  ConversionException("Error: Field \"" + 
    7392           0 :                                 name + "\": Unexpected end of string", tableName);
    7393           0 :                 } catch (const TagFormatException &e) {
    7394           0 :                         throw ConversionException("Error: Field \"" + 
    7395           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7396           0 :                 }               
    7397           0 :         }
    7398             :                 
    7399           0 :         vector< vector<Pressure> > Parser::get2DPressure(const string &name, const string &tableName, const string &xmlDoc)
    7400             :         {
    7401           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7402           0 :                 if (xmlField.length() == 0) {
    7403           0 :                         throw ConversionException("Error: Field \"" + 
    7404           0 :                                         name + "\": Invalid XML syntax", tableName);
    7405             :                 }
    7406           0 :                 StringTokenizer t(xmlField," ");
    7407             :                 try {
    7408           0 :                         int ndim = Integer::parseInt(t.nextToken());
    7409           0 :                         if (ndim != 2) {
    7410           0 :                                 throw ConversionException("Error: Field \"" + 
    7411           0 :                                         name + "\": Invalid array format", tableName);
    7412             :                         }
    7413           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    7414           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    7415           0 :                         vector< vector<Pressure> > value;
    7416             : 
    7417           0 :                         if (dim0 == 0 || dim1 == 0)
    7418           0 :                                 return value;
    7419             : 
    7420           0 :                         vector<Pressure> v_aux;
    7421           0 :                         for (int i = 0; i < dim0; ++i) {
    7422           0 :                                 v_aux.clear();
    7423           0 :                                 for (int j = 0; j < dim1; ++j) {
    7424             :         
    7425           0 :                                         v_aux.push_back(Pressure::getPressure(t));
    7426             :         
    7427             :                                 }
    7428           0 :                                 value.push_back(v_aux);
    7429             :                         }
    7430           0 :                         if (t.hasMoreTokens()) {
    7431           0 :                                 throw ConversionException("Error: Field \"" + 
    7432           0 :                                         name + "\": Syntax error.", tableName);
    7433             :                         }
    7434           0 :                         return value;
    7435           0 :                 } catch (const NumberFormatException &e) {
    7436           0 :                         throw ConversionException("Error: Field \"" + 
    7437           0 :                                 name + "\": " + e.getMessage(), tableName);
    7438           0 :                 } catch (const OutOfBoundsException &e) {
    7439           0 :                         throw  ConversionException("Error: Field \"" + 
    7440           0 :                                 name + "\": Unexpected end of string", tableName);
    7441           0 :                 } catch (const TagFormatException &e) {
    7442           0 :                         throw ConversionException("Error: Field \"" + 
    7443           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7444           0 :                 }               
    7445           0 :         }       
    7446             :         
    7447           0 :         vector< vector< vector<Pressure> > > Parser::get3DPressure(const string &name, const string &tableName, const string &xmlDoc)
    7448             :         {
    7449           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7450           0 :                 if (xmlField.length() == 0) {
    7451           0 :                         throw ConversionException("Error: Field \"" + 
    7452           0 :                                         name + "\": Invalid XML syntax", tableName);
    7453             :                 }
    7454           0 :                 StringTokenizer t(xmlField," ");
    7455             :                 try {
    7456           0 :                         int ndim = Integer::parseInt(t.nextToken());
    7457           0 :                         if (ndim != 3) {
    7458           0 :                                 throw ConversionException("Error: Field \"" + 
    7459           0 :                                         name + "\": Invalid array format", tableName);
    7460             :                         }
    7461           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    7462           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    7463           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    7464           0 :                         vector< vector< vector<Pressure> > > value ;
    7465           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    7466           0 :                                 return value;
    7467             :                         
    7468           0 :                         vector<vector<Pressure> > vv_aux;
    7469           0 :                         vector<Pressure> v_aux;
    7470           0 :                         for (int i = 0; i < dim0; ++i) {
    7471           0 :                                 vv_aux.clear();
    7472           0 :                                 for (int j = 0; j < dim1; ++j) {
    7473           0 :                                         v_aux.clear();
    7474           0 :                                         for (int k = 0; k < dim2; ++k) {
    7475             :         
    7476           0 :                                                 v_aux.push_back(Pressure::getPressure(t));
    7477             :         
    7478             :                                         }
    7479           0 :                                         vv_aux.push_back(v_aux);
    7480             :                                 }
    7481           0 :                                 value.push_back(vv_aux);
    7482             :                         }
    7483           0 :                         if (t.hasMoreTokens()) {
    7484           0 :                                 throw ConversionException("Error: Field \"" + 
    7485           0 :                                         name + "\": Syntax error.", tableName);
    7486             :                         }
    7487           0 :                         return value;
    7488           0 :                 } catch (const NumberFormatException &e) {
    7489           0 :                         throw ConversionException("Error: Field \"" + 
    7490           0 :                                 name + "\": " + e.getMessage(), tableName);
    7491           0 :                 } catch (const OutOfBoundsException &e) {
    7492           0 :                         throw  ConversionException("Error: Field \"" + 
    7493           0 :                                 name + "\": Unexpected end of string", tableName);
    7494           0 :                 } catch (const TagFormatException &e) {
    7495           0 :                         throw ConversionException("Error: Field \"" + 
    7496           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7497           0 :                 }               
    7498           0 :         }
    7499             :         
    7500           0 :         vector< vector< vector< vector<Pressure> > > >Parser::get4DPressure(const string &name, const string &tableName, const string &xmlDoc)
    7501             :         {
    7502           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7503           0 :                 if (xmlField.length() == 0) {
    7504           0 :                         throw ConversionException("Error: Field \"" + 
    7505           0 :                                         name + "\": Invalid XML syntax", tableName);
    7506             :                 }
    7507           0 :                 StringTokenizer t(xmlField," ");
    7508             :                 try {
    7509           0 :                         int ndim = Integer::parseInt(t.nextToken());
    7510           0 :                         if (ndim != 4) {
    7511           0 :                                 throw ConversionException("Error: Field \"" + 
    7512           0 :                                         name + "\": Invalid array format", tableName);
    7513             :                         }
    7514           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    7515           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    7516           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    7517           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    7518           0 :                         vector<vector< vector< vector<Pressure> > > >value;
    7519           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    7520           0 :                                 return value;
    7521             :                         
    7522           0 :                         vector<vector<vector<Pressure> > >vvv_aux;
    7523           0 :                         vector<vector< Pressure> > vv_aux;
    7524           0 :                         vector<Pressure> v_aux;
    7525           0 :                         for (int i = 0; i < dim0; ++i) {
    7526           0 :                                 vvv_aux.clear();
    7527           0 :                                 for (int j = 0; j < dim1; ++j) {
    7528           0 :                                         vv_aux.clear();
    7529           0 :                                         for (int k = 0; k < dim2; ++k) {
    7530           0 :                                                 v_aux.clear();
    7531           0 :                                                 for (int l = 0; l < dim3; l++) {
    7532             :         
    7533           0 :                                                         v_aux.push_back(Pressure::getPressure(t));
    7534             :         
    7535             :                                                 }
    7536           0 :                                                 vv_aux.push_back(v_aux);
    7537             :                                         }
    7538           0 :                                         vvv_aux.push_back(vv_aux);
    7539             :                                 }
    7540           0 :                                 value.push_back(vvv_aux);
    7541             :                         }
    7542           0 :                         if (t.hasMoreTokens()) {
    7543           0 :                                 throw ConversionException("Error: Field \"" + 
    7544           0 :                                         name + "\": Syntax error.", tableName);
    7545             :                         }
    7546           0 :                         return value;
    7547           0 :                 } catch (const NumberFormatException &e) {
    7548           0 :                         throw ConversionException("Error: Field \"" + 
    7549           0 :                                 name + "\": " + e.getMessage(), tableName);
    7550           0 :                 } catch (const OutOfBoundsException &e) {
    7551           0 :                         throw  ConversionException("Error: Field \"" + 
    7552           0 :                                 name + "\": Unexpected end of string", tableName);
    7553           0 :                 } catch (const TagFormatException &e) {
    7554           0 :                         throw ConversionException("Error: Field \"" + 
    7555           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7556           0 :                 }               
    7557           0 :         }       
    7558             :         
    7559             : 
    7560             :                 
    7561             : 
    7562             : 
    7563             :         // Field type: Speed
    7564             : 
    7565           0 :         void Parser::toXML(Speed data, const string &name, string &buf) {
    7566           0 :                 buf.append("<" + name + "> ");
    7567             :         
    7568           0 :                 buf.append(data.toString());
    7569             :                 
    7570           0 :                 buf.append(" </" + name + "> ");
    7571           0 :         }
    7572             : 
    7573             :         
    7574             :         
    7575             :         
    7576           0 :         void Parser::toXML(vector<Speed> data, const string &name, string &buf) {
    7577           0 :                 buf.append("<" + name + "> ");
    7578           0 :                 buf.append("1 ");
    7579           0 :                 buf.append(Integer::toString(data.size()));
    7580           0 :                 buf.append(" ");
    7581           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7582             :         
    7583           0 :                         buf.append(data[i].toString());
    7584             :                 
    7585           0 :                         buf.append(" ");
    7586             :                 }
    7587           0 :                 buf.append(" </" + name + "> ");
    7588           0 :         }
    7589             : 
    7590           0 :         void Parser::toXML(vector< vector<Speed> > data, const string &name, string &buf) {
    7591           0 :                 buf.append("<" + name + "> ");
    7592           0 :                 buf.append("2 ");
    7593           0 :                 buf.append(Integer::toString(data.size()));
    7594           0 :                 buf.append(" ");
    7595           0 :                 buf.append(Integer::toString(data[0].size()));
    7596           0 :                 buf.append(" ");
    7597           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7598           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7599             :         
    7600           0 :                                 buf.append(data[i][j].toString());
    7601             :                 
    7602           0 :                                 buf.append(" ");
    7603             :                         }
    7604             :                 }
    7605           0 :                 buf.append(" </" + name + "> ");
    7606           0 :         }
    7607             :         
    7608           0 :         void Parser::toXML(vector< vector< vector<Speed> > > data, const string &name, string &buf) {
    7609           0 :                 buf.append("<" + name + "> ");
    7610           0 :                 buf.append("3 ");
    7611           0 :                 buf.append(Integer::toString(data.size()));
    7612           0 :                 buf.append(" ");
    7613           0 :                 buf.append(Integer::toString(data[0].size()));
    7614           0 :                 buf.append(" ");
    7615           0 :                 buf.append(Integer::toString(data[0][0].size()));
    7616           0 :                 buf.append(" ");
    7617           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7618           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7619           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    7620             :         
    7621           0 :                                         buf.append(data[i][j][k].toString());
    7622             :                 
    7623           0 :                                         buf.append(" ");
    7624             :                                 }
    7625             :                         }
    7626             :                 }
    7627           0 :                 buf.append(" </" + name + "> ");
    7628           0 :         }
    7629             :         
    7630           0 :         void Parser::toXML(vector<vector< vector< vector<Speed> > > >data, const string &name, string &buf) {
    7631           0 :                 buf.append("<" + name + "> ");
    7632           0 :                 buf.append("4 ");
    7633           0 :                 buf.append(Integer::toString(data.size()));
    7634           0 :                 buf.append(" ");
    7635           0 :                 buf.append(Integer::toString(data[0].size()));
    7636           0 :                 buf.append(" ");
    7637           0 :                 buf.append(Integer::toString(data[0][0].size()));
    7638           0 :                 buf.append(" ");
    7639           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    7640           0 :                 buf.append(" ");
    7641           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7642           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7643           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    7644           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    7645             :         
    7646           0 :                                                 buf.append(data[i][j][k][l].toString());
    7647             :                 
    7648           0 :                                                 buf.append(" ");
    7649             :                                         }
    7650             :                                 }
    7651             :                         }
    7652             :                 }
    7653           0 :                 buf.append(" </" + name + "> ");
    7654           0 :         }       
    7655             :         
    7656             :                 
    7657             : 
    7658             :         
    7659             :                 
    7660             :         
    7661       30910 :         Speed Parser::getSpeed(const string &name, const string &tableName, const string &xmlDoc) 
    7662             :         {
    7663       30910 :                 string xmlField = Parser::getField(xmlDoc,name);
    7664       30910 :                 if (xmlField.length() == 0)
    7665           0 :                         throw ConversionException("Error: Missing field \"" + 
    7666           0 :                                 name + "\" or invalid syntax",tableName);
    7667             :         
    7668             :         try {   
    7669       61820 :                         return Speed (xmlField);
    7670             :                 }
    7671           0 :                 catch (const InvalidArgumentException &e) {
    7672           0 :                         throw ConversionException("Error: message was '"+ 
    7673           0 :                                                    e.getMessage()+
    7674             :                                                    "'",
    7675           0 :                                                    tableName);
    7676           0 :                 }
    7677             :                 
    7678       30910 :         }
    7679             : 
    7680        2032 :         vector<Speed> Parser::get1DSpeed(const string &name, const string &tableName, const string &xmlDoc)
    7681             :         {
    7682        2032 :                 string xmlField = Parser::getField(xmlDoc,name);
    7683        2032 :                 if (xmlField.length() == 0) {
    7684           0 :                         throw ConversionException("Error: Field \"" + 
    7685           0 :                                         name + "\": Invalid XML syntax", tableName);
    7686             :                 }
    7687        4064 :                 StringTokenizer t(xmlField," ");
    7688             :                 try {
    7689        2032 :                         int ndim = Integer::parseInt(t.nextToken());
    7690        2032 :                         if (ndim != 1) {
    7691           0 :                                 throw ConversionException("Error: Field \"" + 
    7692           0 :                                         name + "\": Invalid array format", tableName);
    7693             :                         }
    7694        2032 :                         int dim0 = Integer::parseInt(t.nextToken());
    7695        2032 :                         vector<Speed> value (dim0);
    7696        2032 :                         if (dim0 == 0)
    7697         712 :                                 return value;
    7698        2640 :                         for (int i = 0; i < dim0; ++i) {
    7699             :         
    7700        1320 :                                 value[i] = Speed::getSpeed(t);
    7701             :         
    7702             :                         }
    7703        1320 :                         if (t.hasMoreTokens()) {
    7704           0 :                                 throw ConversionException("Error: Field \"" + 
    7705           0 :                                         name + "\": Syntax error.", tableName);
    7706             :                         }
    7707        1320 :                         return value;
    7708        2032 :                 } catch (const NumberFormatException &e) {
    7709           0 :                         throw ConversionException("Error: Field \"" + 
    7710           0 :                                 name + "\": " + e.getMessage(), tableName);
    7711           0 :                 } catch (const OutOfBoundsException &e) {
    7712           0 :                         throw  ConversionException("Error: Field \"" + 
    7713           0 :                                 name + "\": Unexpected end of string", tableName);
    7714           0 :                 } catch (const TagFormatException &e) {
    7715           0 :                         throw ConversionException("Error: Field \"" + 
    7716           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7717           0 :                 }               
    7718        2032 :         }
    7719             :                 
    7720           0 :         vector< vector<Speed> > Parser::get2DSpeed(const string &name, const string &tableName, const string &xmlDoc)
    7721             :         {
    7722           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7723           0 :                 if (xmlField.length() == 0) {
    7724           0 :                         throw ConversionException("Error: Field \"" + 
    7725           0 :                                         name + "\": Invalid XML syntax", tableName);
    7726             :                 }
    7727           0 :                 StringTokenizer t(xmlField," ");
    7728             :                 try {
    7729           0 :                         int ndim = Integer::parseInt(t.nextToken());
    7730           0 :                         if (ndim != 2) {
    7731           0 :                                 throw ConversionException("Error: Field \"" + 
    7732           0 :                                         name + "\": Invalid array format", tableName);
    7733             :                         }
    7734           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    7735           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    7736           0 :                         vector< vector<Speed> > value;
    7737             : 
    7738           0 :                         if (dim0 == 0 || dim1 == 0)
    7739           0 :                                 return value;
    7740             : 
    7741           0 :                         vector<Speed> v_aux;
    7742           0 :                         for (int i = 0; i < dim0; ++i) {
    7743           0 :                                 v_aux.clear();
    7744           0 :                                 for (int j = 0; j < dim1; ++j) {
    7745             :         
    7746           0 :                                         v_aux.push_back(Speed::getSpeed(t));
    7747             :         
    7748             :                                 }
    7749           0 :                                 value.push_back(v_aux);
    7750             :                         }
    7751           0 :                         if (t.hasMoreTokens()) {
    7752           0 :                                 throw ConversionException("Error: Field \"" + 
    7753           0 :                                         name + "\": Syntax error.", tableName);
    7754             :                         }
    7755           0 :                         return value;
    7756           0 :                 } catch (const NumberFormatException &e) {
    7757           0 :                         throw ConversionException("Error: Field \"" + 
    7758           0 :                                 name + "\": " + e.getMessage(), tableName);
    7759           0 :                 } catch (const OutOfBoundsException &e) {
    7760           0 :                         throw  ConversionException("Error: Field \"" + 
    7761           0 :                                 name + "\": Unexpected end of string", tableName);
    7762           0 :                 } catch (const TagFormatException &e) {
    7763           0 :                         throw ConversionException("Error: Field \"" + 
    7764           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7765           0 :                 }               
    7766           0 :         }       
    7767             :         
    7768           0 :         vector< vector< vector<Speed> > > Parser::get3DSpeed(const string &name, const string &tableName, const string &xmlDoc)
    7769             :         {
    7770           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7771           0 :                 if (xmlField.length() == 0) {
    7772           0 :                         throw ConversionException("Error: Field \"" + 
    7773           0 :                                         name + "\": Invalid XML syntax", tableName);
    7774             :                 }
    7775           0 :                 StringTokenizer t(xmlField," ");
    7776             :                 try {
    7777           0 :                         int ndim = Integer::parseInt(t.nextToken());
    7778           0 :                         if (ndim != 3) {
    7779           0 :                                 throw ConversionException("Error: Field \"" + 
    7780           0 :                                         name + "\": Invalid array format", tableName);
    7781             :                         }
    7782           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    7783           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    7784           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    7785           0 :                         vector< vector< vector<Speed> > > value ;
    7786           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    7787           0 :                                 return value;
    7788             :                         
    7789           0 :                         vector<vector<Speed> > vv_aux;
    7790           0 :                         vector<Speed> v_aux;
    7791           0 :                         for (int i = 0; i < dim0; ++i) {
    7792           0 :                                 vv_aux.clear();
    7793           0 :                                 for (int j = 0; j < dim1; ++j) {
    7794           0 :                                         v_aux.clear();
    7795           0 :                                         for (int k = 0; k < dim2; ++k) {
    7796             :         
    7797           0 :                                                 v_aux.push_back(Speed::getSpeed(t));
    7798             :         
    7799             :                                         }
    7800           0 :                                         vv_aux.push_back(v_aux);
    7801             :                                 }
    7802           0 :                                 value.push_back(vv_aux);
    7803             :                         }
    7804           0 :                         if (t.hasMoreTokens()) {
    7805           0 :                                 throw ConversionException("Error: Field \"" + 
    7806           0 :                                         name + "\": Syntax error.", tableName);
    7807             :                         }
    7808           0 :                         return value;
    7809           0 :                 } catch (const NumberFormatException &e) {
    7810           0 :                         throw ConversionException("Error: Field \"" + 
    7811           0 :                                 name + "\": " + e.getMessage(), tableName);
    7812           0 :                 } catch (const OutOfBoundsException &e) {
    7813           0 :                         throw  ConversionException("Error: Field \"" + 
    7814           0 :                                 name + "\": Unexpected end of string", tableName);
    7815           0 :                 } catch (const TagFormatException &e) {
    7816           0 :                         throw ConversionException("Error: Field \"" + 
    7817           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7818           0 :                 }               
    7819           0 :         }
    7820             :         
    7821           0 :         vector< vector< vector< vector<Speed> > > >Parser::get4DSpeed(const string &name, const string &tableName, const string &xmlDoc)
    7822             :         {
    7823           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7824           0 :                 if (xmlField.length() == 0) {
    7825           0 :                         throw ConversionException("Error: Field \"" + 
    7826           0 :                                         name + "\": Invalid XML syntax", tableName);
    7827             :                 }
    7828           0 :                 StringTokenizer t(xmlField," ");
    7829             :                 try {
    7830           0 :                         int ndim = Integer::parseInt(t.nextToken());
    7831           0 :                         if (ndim != 4) {
    7832           0 :                                 throw ConversionException("Error: Field \"" + 
    7833           0 :                                         name + "\": Invalid array format", tableName);
    7834             :                         }
    7835           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    7836           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    7837           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    7838           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    7839           0 :                         vector<vector< vector< vector<Speed> > > >value;
    7840           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    7841           0 :                                 return value;
    7842             :                         
    7843           0 :                         vector<vector<vector<Speed> > >vvv_aux;
    7844           0 :                         vector<vector< Speed> > vv_aux;
    7845           0 :                         vector<Speed> v_aux;
    7846           0 :                         for (int i = 0; i < dim0; ++i) {
    7847           0 :                                 vvv_aux.clear();
    7848           0 :                                 for (int j = 0; j < dim1; ++j) {
    7849           0 :                                         vv_aux.clear();
    7850           0 :                                         for (int k = 0; k < dim2; ++k) {
    7851           0 :                                                 v_aux.clear();
    7852           0 :                                                 for (int l = 0; l < dim3; l++) {
    7853             :         
    7854           0 :                                                         v_aux.push_back(Speed::getSpeed(t));
    7855             :         
    7856             :                                                 }
    7857           0 :                                                 vv_aux.push_back(v_aux);
    7858             :                                         }
    7859           0 :                                         vvv_aux.push_back(vv_aux);
    7860             :                                 }
    7861           0 :                                 value.push_back(vvv_aux);
    7862             :                         }
    7863           0 :                         if (t.hasMoreTokens()) {
    7864           0 :                                 throw ConversionException("Error: Field \"" + 
    7865           0 :                                         name + "\": Syntax error.", tableName);
    7866             :                         }
    7867           0 :                         return value;
    7868           0 :                 } catch (const NumberFormatException &e) {
    7869           0 :                         throw ConversionException("Error: Field \"" + 
    7870           0 :                                 name + "\": " + e.getMessage(), tableName);
    7871           0 :                 } catch (const OutOfBoundsException &e) {
    7872           0 :                         throw  ConversionException("Error: Field \"" + 
    7873           0 :                                 name + "\": Unexpected end of string", tableName);
    7874           0 :                 } catch (const TagFormatException &e) {
    7875           0 :                         throw ConversionException("Error: Field \"" + 
    7876           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    7877           0 :                 }               
    7878           0 :         }       
    7879             :         
    7880             : 
    7881             :                 
    7882             : 
    7883             : 
    7884             :         // Field type: Tag
    7885             : 
    7886        7738 :         void Parser::toXML(Tag data, const string &name, string &buf) {
    7887        7738 :                 buf.append("<" + name + "> ");
    7888             :         
    7889        7738 :                 buf.append(data.toString());
    7890             :                 
    7891        7738 :                 buf.append(" </" + name + "> ");
    7892        7738 :         }
    7893             : 
    7894             :         
    7895             :         
    7896           0 :          void Parser::toXML(set< Tag > data, const string &name, string &buf) {
    7897           0 :                 buf.append("<" + name + "> ");
    7898           0 :                 set < Tag >::iterator iter;
    7899           0 :                 for (iter=data.begin(); iter!=data.end(); iter++) {
    7900             :                         
    7901           0 :                         buf.append((*iter).toString()+" ");
    7902             :                         
    7903             :                 }       
    7904           0 :         }
    7905             :         
    7906             :         
    7907         975 :         void Parser::toXML(vector<Tag> data, const string &name, string &buf) {
    7908         975 :                 buf.append("<" + name + "> ");
    7909         975 :                 buf.append("1 ");
    7910         975 :                 buf.append(Integer::toString(data.size()));
    7911         975 :                 buf.append(" ");
    7912       24426 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7913             :         
    7914       23451 :                         buf.append(data[i].toString());
    7915             :                 
    7916       23451 :                         buf.append(" ");
    7917             :                 }
    7918         975 :                 buf.append(" </" + name + "> ");
    7919         975 :         }
    7920             : 
    7921           0 :         void Parser::toXML(vector< vector<Tag> > data, const string &name, string &buf) {
    7922           0 :                 buf.append("<" + name + "> ");
    7923           0 :                 buf.append("2 ");
    7924           0 :                 buf.append(Integer::toString(data.size()));
    7925           0 :                 buf.append(" ");
    7926           0 :                 buf.append(Integer::toString(data[0].size()));
    7927           0 :                 buf.append(" ");
    7928           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7929           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7930             :         
    7931           0 :                                 buf.append(data[i][j].toString());
    7932             :                 
    7933           0 :                                 buf.append(" ");
    7934             :                         }
    7935             :                 }
    7936           0 :                 buf.append(" </" + name + "> ");
    7937           0 :         }
    7938             :         
    7939           0 :         void Parser::toXML(vector< vector< vector<Tag> > > data, const string &name, string &buf) {
    7940           0 :                 buf.append("<" + name + "> ");
    7941           0 :                 buf.append("3 ");
    7942           0 :                 buf.append(Integer::toString(data.size()));
    7943           0 :                 buf.append(" ");
    7944           0 :                 buf.append(Integer::toString(data[0].size()));
    7945           0 :                 buf.append(" ");
    7946           0 :                 buf.append(Integer::toString(data[0][0].size()));
    7947           0 :                 buf.append(" ");
    7948           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7949           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7950           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    7951             :         
    7952           0 :                                         buf.append(data[i][j][k].toString());
    7953             :                 
    7954           0 :                                         buf.append(" ");
    7955             :                                 }
    7956             :                         }
    7957             :                 }
    7958           0 :                 buf.append(" </" + name + "> ");
    7959           0 :         }
    7960             :         
    7961           0 :         void Parser::toXML(vector<vector< vector< vector<Tag> > > >data, const string &name, string &buf) {
    7962           0 :                 buf.append("<" + name + "> ");
    7963           0 :                 buf.append("4 ");
    7964           0 :                 buf.append(Integer::toString(data.size()));
    7965           0 :                 buf.append(" ");
    7966           0 :                 buf.append(Integer::toString(data[0].size()));
    7967           0 :                 buf.append(" ");
    7968           0 :                 buf.append(Integer::toString(data[0][0].size()));
    7969           0 :                 buf.append(" ");
    7970           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    7971           0 :                 buf.append(" ");
    7972           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    7973           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    7974           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    7975           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    7976             :         
    7977           0 :                                                 buf.append(data[i][j][k][l].toString());
    7978             :                 
    7979           0 :                                                 buf.append(" ");
    7980             :                                         }
    7981             :                                 }
    7982             :                         }
    7983             :                 }
    7984           0 :                 buf.append(" </" + name + "> ");
    7985           0 :         }       
    7986             :         
    7987             :                 
    7988             : 
    7989             :         
    7990             :         
    7991           0 :         set< Tag >  Parser::getTagSet(const string &name, const string &tableName, const string &xmlDoc) {
    7992           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    7993           0 :                 if (xmlField.length() == 0)
    7994           0 :                         throw ConversionException("Error: Missing field \"" + 
    7995           0 :                                 name + "\" or invalid syntax",tableName);
    7996           0 :                 StringTokenizer t(xmlField," ");
    7997           0 :                 set < Tag > result;
    7998             :                 
    7999           0 :                 while (t.hasMoreTokens()) {
    8000             :                 
    8001             :                         
    8002             :                         try {
    8003           0 :                                 result.insert(Tag::parseTag(t.nextToken()));
    8004             :                         }
    8005           0 :                         catch (const TagFormatException &e) {
    8006           0 :                                 throw ConversionException("Error: Field \"" + 
    8007           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    8008           0 :                         }       
    8009             :                 
    8010             :                 }
    8011           0 :                 return result;                                                  
    8012           0 :         }
    8013             :                 
    8014             :         
    8015      308793 :         Tag Parser::getTag(const string &name, const string &tableName, const string &xmlDoc) 
    8016             :         {
    8017      308793 :                 string xmlField = Parser::getField(xmlDoc,name);
    8018      308793 :                 if (xmlField.length() == 0)
    8019           0 :                         throw ConversionException("Error: Missing field \"" + 
    8020           0 :                                 name + "\" or invalid syntax",tableName);
    8021             :         
    8022             :                 try {
    8023      617586 :                         return Tag::parseTag(xmlField);
    8024             :                 }
    8025           0 :                 catch (const TagFormatException &e) {
    8026           0 :                         throw ConversionException("Error: Field \"" + 
    8027           0 :                         name + "\": " + e.getMessage(), tableName);                              
    8028           0 :                 }
    8029             :                 
    8030      308793 :         }
    8031             : 
    8032       11222 :         vector<Tag> Parser::get1DTag(const string &name, const string &tableName, const string &xmlDoc)
    8033             :         {
    8034       11222 :                 string xmlField = Parser::getField(xmlDoc,name);
    8035       11222 :                 if (xmlField.length() == 0) {
    8036           0 :                         throw ConversionException("Error: Field \"" + 
    8037           0 :                                         name + "\": Invalid XML syntax", tableName);
    8038             :                 }
    8039       22444 :                 StringTokenizer t(xmlField," ");
    8040             :                 try {
    8041       11222 :                         int ndim = Integer::parseInt(t.nextToken());
    8042       11222 :                         if (ndim != 1) {
    8043           0 :                                 throw ConversionException("Error: Field \"" + 
    8044           0 :                                         name + "\": Invalid array format", tableName);
    8045             :                         }
    8046       11222 :                         int dim0 = Integer::parseInt(t.nextToken());
    8047       11222 :                         vector<Tag> value (dim0);
    8048       11222 :                         if (dim0 == 0)
    8049           0 :                                 return value;
    8050      129422 :                         for (int i = 0; i < dim0; ++i) {
    8051             :         
    8052      118200 :                                         value[i] = Tag::parseTag(t.nextToken());
    8053             :         
    8054             :                         }
    8055       11222 :                         if (t.hasMoreTokens()) {
    8056           0 :                                 throw ConversionException("Error: Field \"" + 
    8057           0 :                                         name + "\": Syntax error.", tableName);
    8058             :                         }
    8059       11222 :                         return value;
    8060       11222 :                 } catch (const NumberFormatException &e) {
    8061           0 :                         throw ConversionException("Error: Field \"" + 
    8062           0 :                                 name + "\": " + e.getMessage(), tableName);
    8063           0 :                 } catch (const OutOfBoundsException &e) {
    8064           0 :                         throw  ConversionException("Error: Field \"" + 
    8065           0 :                                 name + "\": Unexpected end of string", tableName);
    8066           0 :                 } catch (const TagFormatException &e) {
    8067           0 :                         throw ConversionException("Error: Field \"" + 
    8068           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    8069           0 :                 }               
    8070       11222 :         }
    8071             :                 
    8072           0 :         vector< vector<Tag> > Parser::get2DTag(const string &name, const string &tableName, const string &xmlDoc)
    8073             :         {
    8074           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    8075           0 :                 if (xmlField.length() == 0) {
    8076           0 :                         throw ConversionException("Error: Field \"" + 
    8077           0 :                                         name + "\": Invalid XML syntax", tableName);
    8078             :                 }
    8079           0 :                 StringTokenizer t(xmlField," ");
    8080             :                 try {
    8081           0 :                         int ndim = Integer::parseInt(t.nextToken());
    8082           0 :                         if (ndim != 2) {
    8083           0 :                                 throw ConversionException("Error: Field \"" + 
    8084           0 :                                         name + "\": Invalid array format", tableName);
    8085             :                         }
    8086           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    8087           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    8088           0 :                         vector< vector<Tag> > value;
    8089             : 
    8090           0 :                         if (dim0 == 0 || dim1 == 0)
    8091           0 :                                 return value;
    8092             : 
    8093           0 :                         vector<Tag> v_aux;
    8094           0 :                         for (int i = 0; i < dim0; ++i) {
    8095           0 :                                 v_aux.clear();
    8096           0 :                                 for (int j = 0; j < dim1; ++j) {
    8097             :         
    8098           0 :                                         v_aux.push_back(Tag::parseTag(t.nextToken()));
    8099             :         
    8100             :                                 }
    8101           0 :                                 value.push_back(v_aux);
    8102             :                         }
    8103           0 :                         if (t.hasMoreTokens()) {
    8104           0 :                                 throw ConversionException("Error: Field \"" + 
    8105           0 :                                         name + "\": Syntax error.", tableName);
    8106             :                         }
    8107           0 :                         return value;
    8108           0 :                 } catch (const NumberFormatException &e) {
    8109           0 :                         throw ConversionException("Error: Field \"" + 
    8110           0 :                                 name + "\": " + e.getMessage(), tableName);
    8111           0 :                 } catch (const OutOfBoundsException &e) {
    8112           0 :                         throw  ConversionException("Error: Field \"" + 
    8113           0 :                                 name + "\": Unexpected end of string", tableName);
    8114           0 :                 } catch (const TagFormatException &e) {
    8115           0 :                         throw ConversionException("Error: Field \"" + 
    8116           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    8117           0 :                 }               
    8118           0 :         }       
    8119             :         
    8120           0 :         vector< vector< vector<Tag> > > Parser::get3DTag(const string &name, const string &tableName, const string &xmlDoc)
    8121             :         {
    8122           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    8123           0 :                 if (xmlField.length() == 0) {
    8124           0 :                         throw ConversionException("Error: Field \"" + 
    8125           0 :                                         name + "\": Invalid XML syntax", tableName);
    8126             :                 }
    8127           0 :                 StringTokenizer t(xmlField," ");
    8128             :                 try {
    8129           0 :                         int ndim = Integer::parseInt(t.nextToken());
    8130           0 :                         if (ndim != 3) {
    8131           0 :                                 throw ConversionException("Error: Field \"" + 
    8132           0 :                                         name + "\": Invalid array format", tableName);
    8133             :                         }
    8134           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    8135           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    8136           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    8137           0 :                         vector< vector< vector<Tag> > > value ;
    8138           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    8139           0 :                                 return value;
    8140             :                         
    8141           0 :                         vector<vector<Tag> > vv_aux;
    8142           0 :                         vector<Tag> v_aux;
    8143           0 :                         for (int i = 0; i < dim0; ++i) {
    8144           0 :                                 vv_aux.clear();
    8145           0 :                                 for (int j = 0; j < dim1; ++j) {
    8146           0 :                                         v_aux.clear();
    8147           0 :                                         for (int k = 0; k < dim2; ++k) {
    8148             :         
    8149           0 :                                                 v_aux.push_back(Tag::parseTag(t.nextToken()));                                                  
    8150             :         
    8151             :                                         }
    8152           0 :                                         vv_aux.push_back(v_aux);
    8153             :                                 }
    8154           0 :                                 value.push_back(vv_aux);
    8155             :                         }
    8156           0 :                         if (t.hasMoreTokens()) {
    8157           0 :                                 throw ConversionException("Error: Field \"" + 
    8158           0 :                                         name + "\": Syntax error.", tableName);
    8159             :                         }
    8160           0 :                         return value;
    8161           0 :                 } catch (const NumberFormatException &e) {
    8162           0 :                         throw ConversionException("Error: Field \"" + 
    8163           0 :                                 name + "\": " + e.getMessage(), tableName);
    8164           0 :                 } catch (const OutOfBoundsException &e) {
    8165           0 :                         throw  ConversionException("Error: Field \"" + 
    8166           0 :                                 name + "\": Unexpected end of string", tableName);
    8167           0 :                 } catch (const TagFormatException &e) {
    8168           0 :                         throw ConversionException("Error: Field \"" + 
    8169           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    8170           0 :                 }               
    8171           0 :         }
    8172             :         
    8173           0 :         vector< vector< vector< vector<Tag> > > >Parser::get4DTag(const string &name, const string &tableName, const string &xmlDoc)
    8174             :         {
    8175           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    8176           0 :                 if (xmlField.length() == 0) {
    8177           0 :                         throw ConversionException("Error: Field \"" + 
    8178           0 :                                         name + "\": Invalid XML syntax", tableName);
    8179             :                 }
    8180           0 :                 StringTokenizer t(xmlField," ");
    8181             :                 try {
    8182           0 :                         int ndim = Integer::parseInt(t.nextToken());
    8183           0 :                         if (ndim != 4) {
    8184           0 :                                 throw ConversionException("Error: Field \"" + 
    8185           0 :                                         name + "\": Invalid array format", tableName);
    8186             :                         }
    8187           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    8188           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    8189           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    8190           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    8191           0 :                         vector<vector< vector< vector<Tag> > > >value;
    8192           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    8193           0 :                                 return value;
    8194             :                         
    8195           0 :                         vector<vector<vector<Tag> > >vvv_aux;
    8196           0 :                         vector<vector< Tag> > vv_aux;
    8197           0 :                         vector<Tag> v_aux;
    8198           0 :                         for (int i = 0; i < dim0; ++i) {
    8199           0 :                                 vvv_aux.clear();
    8200           0 :                                 for (int j = 0; j < dim1; ++j) {
    8201           0 :                                         vv_aux.clear();
    8202           0 :                                         for (int k = 0; k < dim2; ++k) {
    8203           0 :                                                 v_aux.clear();
    8204           0 :                                                 for (int l = 0; l < dim3; l++) {
    8205             :         
    8206           0 :                                                         v_aux.push_back(Tag::parseTag(t.nextToken()));                                                  
    8207             :         
    8208             :                                                 }
    8209           0 :                                                 vv_aux.push_back(v_aux);
    8210             :                                         }
    8211           0 :                                         vvv_aux.push_back(vv_aux);
    8212             :                                 }
    8213           0 :                                 value.push_back(vvv_aux);
    8214             :                         }
    8215           0 :                         if (t.hasMoreTokens()) {
    8216           0 :                                 throw ConversionException("Error: Field \"" + 
    8217           0 :                                         name + "\": Syntax error.", tableName);
    8218             :                         }
    8219           0 :                         return value;
    8220           0 :                 } catch (const NumberFormatException &e) {
    8221           0 :                         throw ConversionException("Error: Field \"" + 
    8222           0 :                                 name + "\": " + e.getMessage(), tableName);
    8223           0 :                 } catch (const OutOfBoundsException &e) {
    8224           0 :                         throw  ConversionException("Error: Field \"" + 
    8225           0 :                                 name + "\": Unexpected end of string", tableName);
    8226           0 :                 } catch (const TagFormatException &e) {
    8227           0 :                         throw ConversionException("Error: Field \"" + 
    8228           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    8229           0 :                 }               
    8230           0 :         }       
    8231             :         
    8232             : 
    8233             :                 
    8234             : 
    8235             : 
    8236             :         // Field type: Temperature
    8237             : 
    8238           0 :         void Parser::toXML(Temperature data, const string &name, string &buf) {
    8239           0 :                 buf.append("<" + name + "> ");
    8240             :         
    8241           0 :                 buf.append(data.toString());
    8242             :                 
    8243           0 :                 buf.append(" </" + name + "> ");
    8244           0 :         }
    8245             : 
    8246             :         
    8247             :         
    8248             :         
    8249           0 :         void Parser::toXML(vector<Temperature> data, const string &name, string &buf) {
    8250           0 :                 buf.append("<" + name + "> ");
    8251           0 :                 buf.append("1 ");
    8252           0 :                 buf.append(Integer::toString(data.size()));
    8253           0 :                 buf.append(" ");
    8254           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    8255             :         
    8256           0 :                         buf.append(data[i].toString());
    8257             :                 
    8258           0 :                         buf.append(" ");
    8259             :                 }
    8260           0 :                 buf.append(" </" + name + "> ");
    8261           0 :         }
    8262             : 
    8263           0 :         void Parser::toXML(vector< vector<Temperature> > data, const string &name, string &buf) {
    8264           0 :                 buf.append("<" + name + "> ");
    8265           0 :                 buf.append("2 ");
    8266           0 :                 buf.append(Integer::toString(data.size()));
    8267           0 :                 buf.append(" ");
    8268           0 :                 buf.append(Integer::toString(data[0].size()));
    8269           0 :                 buf.append(" ");
    8270           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    8271           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    8272             :         
    8273           0 :                                 buf.append(data[i][j].toString());
    8274             :                 
    8275           0 :                                 buf.append(" ");
    8276             :                         }
    8277             :                 }
    8278           0 :                 buf.append(" </" + name + "> ");
    8279           0 :         }
    8280             :         
    8281           0 :         void Parser::toXML(vector< vector< vector<Temperature> > > data, const string &name, string &buf) {
    8282           0 :                 buf.append("<" + name + "> ");
    8283           0 :                 buf.append("3 ");
    8284           0 :                 buf.append(Integer::toString(data.size()));
    8285           0 :                 buf.append(" ");
    8286           0 :                 buf.append(Integer::toString(data[0].size()));
    8287           0 :                 buf.append(" ");
    8288           0 :                 buf.append(Integer::toString(data[0][0].size()));
    8289           0 :                 buf.append(" ");
    8290           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    8291           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    8292           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    8293             :         
    8294           0 :                                         buf.append(data[i][j][k].toString());
    8295             :                 
    8296           0 :                                         buf.append(" ");
    8297             :                                 }
    8298             :                         }
    8299             :                 }
    8300           0 :                 buf.append(" </" + name + "> ");
    8301           0 :         }
    8302             :         
    8303           0 :         void Parser::toXML(vector<vector< vector< vector<Temperature> > > >data, const string &name, string &buf) {
    8304           0 :                 buf.append("<" + name + "> ");
    8305           0 :                 buf.append("4 ");
    8306           0 :                 buf.append(Integer::toString(data.size()));
    8307           0 :                 buf.append(" ");
    8308           0 :                 buf.append(Integer::toString(data[0].size()));
    8309           0 :                 buf.append(" ");
    8310           0 :                 buf.append(Integer::toString(data[0][0].size()));
    8311           0 :                 buf.append(" ");
    8312           0 :                 buf.append(Integer::toString(data[0][0][0].size()));
    8313           0 :                 buf.append(" ");
    8314           0 :                 for (unsigned int i = 0; i < data.size(); ++i) {
    8315           0 :                         for (unsigned int j = 0; j < data[i].size(); ++j) {
    8316           0 :                                 for (unsigned int k = 0; k < data[i][j].size(); ++k) {
    8317           0 :                                         for (unsigned int l = 0; l < data[i][j][k].size(); l++) {
    8318             :         
    8319           0 :                                                 buf.append(data[i][j][k][l].toString());
    8320             :                 
    8321           0 :                                                 buf.append(" ");
    8322             :                                         }
    8323             :                                 }
    8324             :                         }
    8325             :                 }
    8326           0 :                 buf.append(" </" + name + "> ");
    8327           0 :         }       
    8328             :         
    8329             :                 
    8330             : 
    8331             :         
    8332             :                 
    8333             :         
    8334       15931 :         Temperature Parser::getTemperature(const string &name, const string &tableName, const string &xmlDoc) 
    8335             :         {
    8336       15931 :                 string xmlField = Parser::getField(xmlDoc,name);
    8337       15931 :                 if (xmlField.length() == 0)
    8338           0 :                         throw ConversionException("Error: Missing field \"" + 
    8339           0 :                                 name + "\" or invalid syntax",tableName);
    8340             :         
    8341             :         try {   
    8342       31862 :                         return Temperature (xmlField);
    8343             :                 }
    8344           0 :                 catch (const InvalidArgumentException &e) {
    8345           0 :                         throw ConversionException("Error: message was '"+ 
    8346           0 :                                                    e.getMessage()+
    8347             :                                                    "'",
    8348           0 :                                                    tableName);
    8349           0 :                 }
    8350             :                 
    8351       15931 :         }
    8352             : 
    8353       35224 :         vector<Temperature> Parser::get1DTemperature(const string &name, const string &tableName, const string &xmlDoc)
    8354             :         {
    8355       35224 :                 string xmlField = Parser::getField(xmlDoc,name);
    8356       35224 :                 if (xmlField.length() == 0) {
    8357           0 :                         throw ConversionException("Error: Field \"" + 
    8358           0 :                                         name + "\": Invalid XML syntax", tableName);
    8359             :                 }
    8360       70448 :                 StringTokenizer t(xmlField," ");
    8361             :                 try {
    8362       35224 :                         int ndim = Integer::parseInt(t.nextToken());
    8363       35224 :                         if (ndim != 1) {
    8364           0 :                                 throw ConversionException("Error: Field \"" + 
    8365           0 :                                         name + "\": Invalid array format", tableName);
    8366             :                         }
    8367       35224 :                         int dim0 = Integer::parseInt(t.nextToken());
    8368       35224 :                         vector<Temperature> value (dim0);
    8369       35224 :                         if (dim0 == 0)
    8370           0 :                                 return value;
    8371      105672 :                         for (int i = 0; i < dim0; ++i) {
    8372             :         
    8373       70448 :                                 value[i] = Temperature::getTemperature(t);
    8374             :         
    8375             :                         }
    8376       35224 :                         if (t.hasMoreTokens()) {
    8377           0 :                                 throw ConversionException("Error: Field \"" + 
    8378           0 :                                         name + "\": Syntax error.", tableName);
    8379             :                         }
    8380       35224 :                         return value;
    8381       35224 :                 } catch (const NumberFormatException &e) {
    8382           0 :                         throw ConversionException("Error: Field \"" + 
    8383           0 :                                 name + "\": " + e.getMessage(), tableName);
    8384           0 :                 } catch (const OutOfBoundsException &e) {
    8385           0 :                         throw  ConversionException("Error: Field \"" + 
    8386           0 :                                 name + "\": Unexpected end of string", tableName);
    8387           0 :                 } catch (const TagFormatException &e) {
    8388           0 :                         throw ConversionException("Error: Field \"" + 
    8389           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    8390           0 :                 }               
    8391       35224 :         }
    8392             :                 
    8393       45184 :         vector< vector<Temperature> > Parser::get2DTemperature(const string &name, const string &tableName, const string &xmlDoc)
    8394             :         {
    8395       45184 :                 string xmlField = Parser::getField(xmlDoc,name);
    8396       45184 :                 if (xmlField.length() == 0) {
    8397           0 :                         throw ConversionException("Error: Field \"" + 
    8398           0 :                                         name + "\": Invalid XML syntax", tableName);
    8399             :                 }
    8400       90368 :                 StringTokenizer t(xmlField," ");
    8401             :                 try {
    8402       45184 :                         int ndim = Integer::parseInt(t.nextToken());
    8403       45184 :                         if (ndim != 2) {
    8404           0 :                                 throw ConversionException("Error: Field \"" + 
    8405           0 :                                         name + "\": Invalid array format", tableName);
    8406             :                         }
    8407       45184 :                         int dim0 = Integer::parseInt(t.nextToken());
    8408       45184 :                         int dim1 = Integer::parseInt(t.nextToken());
    8409       45184 :                         vector< vector<Temperature> > value;
    8410             : 
    8411       45184 :                         if (dim0 == 0 || dim1 == 0)
    8412           0 :                                 return value;
    8413             : 
    8414       45184 :                         vector<Temperature> v_aux;
    8415      135552 :                         for (int i = 0; i < dim0; ++i) {
    8416       90368 :                                 v_aux.clear();
    8417    11657472 :                                 for (int j = 0; j < dim1; ++j) {
    8418             :         
    8419    11567104 :                                         v_aux.push_back(Temperature::getTemperature(t));
    8420             :         
    8421             :                                 }
    8422       90368 :                                 value.push_back(v_aux);
    8423             :                         }
    8424       45184 :                         if (t.hasMoreTokens()) {
    8425           0 :                                 throw ConversionException("Error: Field \"" + 
    8426           0 :                                         name + "\": Syntax error.", tableName);
    8427             :                         }
    8428       45184 :                         return value;
    8429       45184 :                 } catch (const NumberFormatException &e) {
    8430           0 :                         throw ConversionException("Error: Field \"" + 
    8431           0 :                                 name + "\": " + e.getMessage(), tableName);
    8432           0 :                 } catch (const OutOfBoundsException &e) {
    8433           0 :                         throw  ConversionException("Error: Field \"" + 
    8434           0 :                                 name + "\": Unexpected end of string", tableName);
    8435           0 :                 } catch (const TagFormatException &e) {
    8436           0 :                         throw ConversionException("Error: Field \"" + 
    8437           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    8438           0 :                 }               
    8439       45184 :         }       
    8440             :         
    8441           0 :         vector< vector< vector<Temperature> > > Parser::get3DTemperature(const string &name, const string &tableName, const string &xmlDoc)
    8442             :         {
    8443           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    8444           0 :                 if (xmlField.length() == 0) {
    8445           0 :                         throw ConversionException("Error: Field \"" + 
    8446           0 :                                         name + "\": Invalid XML syntax", tableName);
    8447             :                 }
    8448           0 :                 StringTokenizer t(xmlField," ");
    8449             :                 try {
    8450           0 :                         int ndim = Integer::parseInt(t.nextToken());
    8451           0 :                         if (ndim != 3) {
    8452           0 :                                 throw ConversionException("Error: Field \"" + 
    8453           0 :                                         name + "\": Invalid array format", tableName);
    8454             :                         }
    8455           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    8456           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    8457           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    8458           0 :                         vector< vector< vector<Temperature> > > value ;
    8459           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0)
    8460           0 :                                 return value;
    8461             :                         
    8462           0 :                         vector<vector<Temperature> > vv_aux;
    8463           0 :                         vector<Temperature> v_aux;
    8464           0 :                         for (int i = 0; i < dim0; ++i) {
    8465           0 :                                 vv_aux.clear();
    8466           0 :                                 for (int j = 0; j < dim1; ++j) {
    8467           0 :                                         v_aux.clear();
    8468           0 :                                         for (int k = 0; k < dim2; ++k) {
    8469             :         
    8470           0 :                                                 v_aux.push_back(Temperature::getTemperature(t));
    8471             :         
    8472             :                                         }
    8473           0 :                                         vv_aux.push_back(v_aux);
    8474             :                                 }
    8475           0 :                                 value.push_back(vv_aux);
    8476             :                         }
    8477           0 :                         if (t.hasMoreTokens()) {
    8478           0 :                                 throw ConversionException("Error: Field \"" + 
    8479           0 :                                         name + "\": Syntax error.", tableName);
    8480             :                         }
    8481           0 :                         return value;
    8482           0 :                 } catch (const NumberFormatException &e) {
    8483           0 :                         throw ConversionException("Error: Field \"" + 
    8484           0 :                                 name + "\": " + e.getMessage(), tableName);
    8485           0 :                 } catch (const OutOfBoundsException &e) {
    8486           0 :                         throw  ConversionException("Error: Field \"" + 
    8487           0 :                                 name + "\": Unexpected end of string", tableName);
    8488           0 :                 } catch (const TagFormatException &e) {
    8489           0 :                         throw ConversionException("Error: Field \"" + 
    8490           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    8491           0 :                 }               
    8492           0 :         }
    8493             :         
    8494           0 :         vector< vector< vector< vector<Temperature> > > >Parser::get4DTemperature(const string &name, const string &tableName, const string &xmlDoc)
    8495             :         {
    8496           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    8497           0 :                 if (xmlField.length() == 0) {
    8498           0 :                         throw ConversionException("Error: Field \"" + 
    8499           0 :                                         name + "\": Invalid XML syntax", tableName);
    8500             :                 }
    8501           0 :                 StringTokenizer t(xmlField," ");
    8502             :                 try {
    8503           0 :                         int ndim = Integer::parseInt(t.nextToken());
    8504           0 :                         if (ndim != 4) {
    8505           0 :                                 throw ConversionException("Error: Field \"" + 
    8506           0 :                                         name + "\": Invalid array format", tableName);
    8507             :                         }
    8508           0 :                         int dim0 = Integer::parseInt(t.nextToken());
    8509           0 :                         int dim1 = Integer::parseInt(t.nextToken());
    8510           0 :                         int dim2 = Integer::parseInt(t.nextToken());
    8511           0 :                         int dim3 = Integer::parseInt(t.nextToken());
    8512           0 :                         vector<vector< vector< vector<Temperature> > > >value;
    8513           0 :                         if (dim0 == 0 || dim1 == 0 || dim2 == 0 ||  dim3 == 0)
    8514           0 :                                 return value;
    8515             :                         
    8516           0 :                         vector<vector<vector<Temperature> > >vvv_aux;
    8517           0 :                         vector<vector< Temperature> > vv_aux;
    8518           0 :                         vector<Temperature> v_aux;
    8519           0 :                         for (int i = 0; i < dim0; ++i) {
    8520           0 :                                 vvv_aux.clear();
    8521           0 :                                 for (int j = 0; j < dim1; ++j) {
    8522           0 :                                         vv_aux.clear();
    8523           0 :                                         for (int k = 0; k < dim2; ++k) {
    8524           0 :                                                 v_aux.clear();
    8525           0 :                                                 for (int l = 0; l < dim3; l++) {
    8526             :         
    8527           0 :                                                         v_aux.push_back(Temperature::getTemperature(t));
    8528             :         
    8529             :                                                 }
    8530           0 :                                                 vv_aux.push_back(v_aux);
    8531             :                                         }
    8532           0 :                                         vvv_aux.push_back(vv_aux);
    8533             :                                 }
    8534           0 :                                 value.push_back(vvv_aux);
    8535             :                         }
    8536           0 :                         if (t.hasMoreTokens()) {
    8537           0 :                                 throw ConversionException("Error: Field \"" + 
    8538           0 :                                         name + "\": Syntax error.", tableName);
    8539             :                         }
    8540           0 :                         return value;
    8541           0 :                 } catch (const NumberFormatException &e) {
    8542           0 :                         throw ConversionException("Error: Field \"" + 
    8543           0 :                                 name + "\": " + e.getMessage(), tableName);
    8544           0 :                 } catch (const OutOfBoundsException &e) {
    8545           0 :                         throw  ConversionException("Error: Field \"" + 
    8546           0 :                                 name + "\": Unexpected end of string", tableName);
    8547           0 :                 } catch (const TagFormatException &e) {
    8548           0 :                         throw ConversionException("Error: Field \"" + 
    8549           0 :                                 name + "\": " + e.getMessage(), tableName);                              
    8550           0 :                 }               
    8551           0 :         }       
    8552             :         
    8553             : 
    8554             :                 
    8555             : 
    8556             : 
    8557             :  
    8558             :     // Generated methods for conversion to and from XML
    8559             :         // data representations with  a Base64 encoded content.
    8560             :         // The methods are generated only for 1, 2 and 3 dimensional arrays
    8561             :         // of data whose BasicType have a non null BaseWrapperName.
    8562             :         // In practice this represents data whose type is one of the basic numeric types
    8563             :         // or is built upon a basic numeric type. 
    8564             : 
    8565             :         
    8566             :         
    8567             :         
    8568             :         
    8569             :         
    8570           0 :         void Parser::toXMLBase64(vector<int> data, const string &name, string &buf){
    8571           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    8572           0 :                 string encoded;
    8573             :                 
    8574           0 :                 buf.append("<" + name + "> ");
    8575           0 :                 int ndim = 1;
    8576           0 :                 int dim1 = data.size();
    8577             :  
    8578           0 :                 oss.write((char *)&ndim, sizeof(int));
    8579           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    8580             : 
    8581           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
    8582             :                 
    8583           0 :                 int v = data.at(i);
    8584             :                 
    8585           0 :                 oss.write((char *) &v, sizeof(v));
    8586             :         }
    8587             : 
    8588           0 :                 Base64 b64;
    8589           0 :             b64.encode(oss.str(), encoded, false);
    8590           0 :             buf.append(encoded);
    8591           0 :                 buf.append(" </" + name + "> ");      
    8592           0 :         }
    8593             :         
    8594             :         
    8595           0 :         void Parser::toXMLBase64(vector< vector<int> > data, const string &name, string &buf){
    8596           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    8597           0 :                 string encoded;
    8598             :                 
    8599           0 :                 buf.append("<" + name + "> ");
    8600           0 :                 int ndim = 2;
    8601           0 :                 int dim1 = data.size();
    8602           0 :                 int dim2 = data.at(0).size();
    8603             : 
    8604           0 :                 oss.write((char *)&ndim, sizeof(int));
    8605           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    8606           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    8607           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    8608           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
    8609             :                 
    8610           0 :                         int v = data.at(i).at(j);
    8611             :                 
    8612           0 :                         oss.write((char *) &v, sizeof(v));
    8613             :                 }
    8614             : 
    8615           0 :                 Base64 b64;
    8616           0 :             b64.encode(oss.str(), encoded, false);
    8617           0 :             buf.append(encoded);
    8618           0 :                 buf.append(" </" + name + "> ")
    8619             :                 ;
    8620           0 :         }
    8621             :         
    8622             :         
    8623           0 :         void Parser::toXMLBase64(vector< vector< vector<int> > > data, const string &name, string &buf){
    8624           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    8625           0 :                 string encoded;
    8626             :                 
    8627           0 :                 buf.append("<" + name + "> ");
    8628           0 :                 int ndim = 3;
    8629           0 :                 int dim1 = data.size();
    8630           0 :                 int dim2 = data.at(0).size();
    8631           0 :                 int dim3 = data.at(0).at(0).size();
    8632             : 
    8633           0 :                 oss.write((char *)&ndim, sizeof(int));
    8634           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    8635           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    8636           0 :                 oss.write((char *)&dim3, sizeof(dim3));
    8637           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    8638           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
    8639           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
    8640             :                 
    8641           0 :                                 int v = data.at(i).at(j).at(k);
    8642             :                 
    8643           0 :                                 oss.write((char *) &v, sizeof(v));
    8644             :                         }
    8645             : 
    8646           0 :                 Base64 b64;
    8647           0 :             b64.encode(oss.str(), encoded, false);
    8648           0 :             buf.append(encoded);
    8649           0 :                 buf.append(" </" + name + "> ")
    8650             :                 ;
    8651           0 :         }
    8652             :         
    8653             :         
    8654           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<int> > > >data, const string &name, string &buf){
    8655           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    8656           0 :                 string encoded;
    8657             :                 
    8658           0 :                 buf.append("<" + name + "> ");
    8659           0 :                 int ndim = 3;
    8660           0 :                 int dim1 = data.size();
    8661           0 :                 int dim2 = data.at(0).size();
    8662           0 :                 int dim3 = data.at(0).at(0).size();
    8663           0 :                 int dim4 = data.at(0).at(0).at(0).size();
    8664             :                 
    8665           0 :                 oss.write((char *)&ndim, sizeof(int));
    8666           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    8667           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    8668           0 :                 oss.write((char *)&dim3, sizeof(dim3));
    8669           0 :                 oss.write((char *)&dim4, sizeof(dim4));
    8670           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    8671           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
    8672           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
    8673           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
    8674             :                 
    8675           0 :                                         int v = data.at(i).at(j).at(k).at(l);
    8676             :                 
    8677           0 :                                 oss.write((char *) &v, sizeof(v));
    8678             :                                 }
    8679             : 
    8680           0 :                 Base64 b64;
    8681           0 :             b64.encode(oss.str(), encoded, false);
    8682           0 :             buf.append(encoded);
    8683           0 :                 buf.append(" </" + name + "> ")
    8684             :                 ;
    8685           0 :         }
    8686             :         
    8687             :         
    8688             : #ifndef Int_CPP
    8689             :                 
    8690             : #define Int_CPP int     
    8691             :                 
    8692             : #endif
    8693             :         
    8694             : 
    8695             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
    8696             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
    8697             :                 
    8698             :     
    8699           0 :         vector<int>& Parser::get1DIntegerFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<int>& attribute)
    8700             :         {
    8701           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    8702           0 :                 if (xmlField.length() == 0) {
    8703           0 :                         throw ConversionException("Error: Field \"" + 
    8704           0 :                                         name + "\": Invalid XML syntax", tableName);
    8705             :                 }
    8706             :                 
    8707           0 :                 string decodedString;
    8708           0 :                 Base64 b64;
    8709           0 :                 b64.decode(xmlField, decodedString);
    8710             :                 
    8711           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    8712           0 :                 iss.str(decodedString);
    8713             :                 
    8714           0 :                 attribute.clear();
    8715             :                 
    8716           0 :                 unsigned int ndim = 0;
    8717             :                 //iss.read((char *)&ndim, sizeof(ndim));
    8718           0 :                 TRYREAD(iss,ndim);
    8719             :                 
    8720           0 :                 unsigned int dim1 = 0;
    8721             :                 //iss.read((char *)&dim1, sizeof(dim1));
    8722           0 :                 TRYREAD(iss,dim1);
    8723           0 :                 if (ndim != 1) {
    8724           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
    8725             :                         }
    8726             :                 
    8727           0 :                 attribute.reserve(dim1);
    8728             :                 
    8729             :                 Int_CPP v;
    8730           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    8731             :                         //iss.read((char*) &v, sizeof(v));
    8732           0 :                         TRYREAD(iss,v);
    8733             :                 
    8734           0 :                         attribute.push_back(v);
    8735             :                         
    8736             :                 }
    8737           0 :                 return attribute;
    8738           0 :         }
    8739             :         
    8740             :          
    8741           0 :         vector <vector<int> >& Parser::get2DIntegerFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<int> >& attribute)
    8742             :         {
    8743           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    8744           0 :                 if (xmlField.length() == 0) {
    8745           0 :                         throw ConversionException("Error: Field \"" + 
    8746           0 :                                         name + "\": Invalid XML syntax", tableName);
    8747             :                 }
    8748             :                 
    8749           0 :                 string decodedString;
    8750           0 :                 Base64 b64;
    8751           0 :                 b64.decode(xmlField, decodedString);
    8752             :                 
    8753           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    8754           0 :                 iss.str(decodedString);
    8755             :                 
    8756           0 :                 attribute.clear();
    8757             :                 
    8758           0 :                 unsigned int ndim = 0;
    8759             :                 //iss.read((char *)&ndim, sizeof(ndim));
    8760           0 :                 TRYREAD(iss,ndim);
    8761             :                 
    8762           0 :                 if (ndim != 2) {
    8763           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
    8764             :                 }
    8765             :         
    8766           0 :                 unsigned int dim1 = 0;
    8767             :                 //iss.read((char *)&dim1, sizeof(dim1));
    8768           0 :                 TRYREAD(iss,dim1);
    8769             :                 
    8770           0 :                 unsigned int dim2 = 0;
    8771             :                 //iss.read((char *)&dim2, sizeof(dim2));
    8772           0 :                 TRYREAD(iss,dim2);
    8773             :                 
    8774           0 :                 attribute.reserve(dim1);
    8775             :                 
    8776             :                 Int_CPP v;
    8777           0 :                 vector<int> aux2;
    8778           0 :                 aux2.reserve(dim2);
    8779           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    8780           0 :                         aux2.clear();
    8781           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    8782             :                                 //iss.read((char*) &v, sizeof(v));
    8783           0 :                                 TRYREAD(iss,v);
    8784             :                 
    8785           0 :                                 aux2.push_back(v);
    8786             :                 
    8787             :                         }
    8788           0 :                         attribute.push_back(aux2);      
    8789             :                 }
    8790           0 :                 return attribute;
    8791           0 :         }
    8792             :                 
    8793             :         
    8794           0 :         vector <vector <vector<int> > >& Parser::get3DIntegerFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<int> > >& attribute)
    8795             :         {
    8796           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    8797           0 :                 if (xmlField.length() == 0) {
    8798           0 :                         throw ConversionException("Error: Field \"" + 
    8799           0 :                                         name + "\": Invalid XML syntax", tableName);
    8800             :                 }
    8801             :                 
    8802           0 :                 string decodedString;
    8803           0 :                 Base64 b64;
    8804           0 :                 b64.decode(xmlField, decodedString);
    8805             :                 
    8806           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    8807           0 :                 iss.str(decodedString);
    8808             :                 
    8809           0 :                 attribute.clear();
    8810             :                 
    8811           0 :                 unsigned int ndim = 0;
    8812             :                 //iss.read((char *)&ndim, sizeof(ndim));
    8813           0 :                 TRYREAD(iss, ndim);     
    8814           0 :                 if (ndim != 3) {
    8815           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
    8816             :                 }
    8817             :                                 
    8818           0 :                 unsigned int dim1 = 0;
    8819             :                 //iss.read((char *)&dim1, sizeof(dim1));
    8820           0 :                 TRYREAD(iss,dim1);
    8821             :                 
    8822           0 :                 unsigned int dim2 = 0;
    8823             :                 //iss.read((char *)&dim2, sizeof(dim2));
    8824           0 :                 TRYREAD(iss,dim2);
    8825             :                 
    8826           0 :                 unsigned int dim3 = 0;
    8827             :                 //iss.read((char *)&dim2, sizeof(dim3));
    8828           0 :                 TRYREAD(iss,dim3);
    8829             :                 
    8830           0 :                 attribute.reserve(dim1);
    8831             :                 
    8832             :                 Int_CPP v;
    8833           0 :                 vector <vector<int> > aux2;
    8834           0 :                 vector<int> aux3;         
    8835           0 :                 aux2.reserve(dim2);
    8836           0 :                 aux3.reserve(dim3);
    8837             :                 
    8838           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    8839           0 :                         aux2.clear();
    8840           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    8841           0 :                                 aux3.clear();
    8842           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
    8843             :                                         //iss.read((char*) &v, sizeof(v));
    8844           0 :                                         TRYREAD(iss,v);
    8845             :                 
    8846           0 :                                         aux3.push_back(v);
    8847             :                 
    8848             :                                 }
    8849           0 :                                 aux2.push_back(aux3);
    8850             :                         }
    8851           0 :                         attribute.push_back(aux2);      
    8852             :                 }
    8853           0 :                 return attribute;
    8854             :                 ;
    8855           0 :         }
    8856             :         
    8857             :         
    8858           0 :         vector <vector <vector <vector<int> > > >& Parser::get4DIntegerFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<int> > > >& attribute)
    8859             :         {
    8860           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    8861           0 :                 if (xmlField.length() == 0) {
    8862           0 :                         throw ConversionException("Error: Field \"" + 
    8863           0 :                                         name + "\": Invalid XML syntax", tableName);
    8864             :                 }
    8865             :                 
    8866           0 :                 string decodedString;
    8867           0 :                 Base64 b64;
    8868           0 :                 b64.decode(xmlField, decodedString);
    8869             :                 
    8870           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    8871           0 :                 iss.str(decodedString);
    8872             :                 
    8873           0 :                 attribute.clear();
    8874             :                 
    8875           0 :                 unsigned int ndim = 0;
    8876             :                 //iss.read((char *)&ndim, sizeof(ndim));
    8877           0 :                 TRYREAD(iss, ndim);     
    8878           0 :                 if (ndim != 4) {
    8879           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
    8880             :                 }
    8881             :                                 
    8882           0 :                 unsigned int dim1 = 0;
    8883             :                 //iss.read((char *)&dim1, sizeof(dim1));
    8884           0 :                 TRYREAD(iss,dim1);
    8885             :                 
    8886           0 :                 unsigned int dim2 = 0;
    8887             :                 //iss.read((char *)&dim2, sizeof(dim2));
    8888           0 :                 TRYREAD(iss,dim2);
    8889             :                 
    8890           0 :                 unsigned int dim3 = 0;
    8891             :                 //iss.read((char *)&dim2, sizeof(dim3));
    8892           0 :                 TRYREAD(iss,dim3);
    8893             :                 
    8894           0 :                 unsigned int dim4 = 0;
    8895             :                 //iss.read((char *)&dim2, sizeof(dim3));
    8896           0 :                 TRYREAD(iss,dim3);
    8897             :                 
    8898           0 :                 attribute.reserve(dim1);
    8899             :                 
    8900             :                 Int_CPP v;
    8901           0 :                 vector <vector <vector<int> > > aux2;
    8902           0 :                 vector <vector<int> > aux3;
    8903           0 :                 vector<int> aux4;         
    8904           0 :                 aux2.reserve(dim2);
    8905           0 :                 aux3.reserve(dim3);
    8906           0 :                 aux4.reserve(dim4);
    8907             :                 
    8908           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    8909           0 :                         aux2.clear();
    8910           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    8911           0 :                                 aux3.clear();
    8912           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
    8913           0 :                                         aux4.clear();
    8914           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
    8915             :                                         //iss.read((char*) &v, sizeof(v));
    8916           0 :                                                 TRYREAD(iss,v);
    8917             :                 
    8918           0 :                                                 aux4.push_back(v);
    8919             :                 
    8920             :                                         }
    8921           0 :                                         aux3.push_back(aux4);
    8922             :                                 }
    8923           0 :                                 aux2.push_back(aux3);
    8924             :                         }
    8925           0 :                         attribute.push_back(aux2);      
    8926             :                 }
    8927           0 :                 return attribute;
    8928             :                 ;
    8929           0 :         }
    8930             :         
    8931             :         
    8932             : 
    8933             :         
    8934             :         
    8935             :         
    8936             :         
    8937           0 :         void Parser::toXMLBase64(vector<short> data, const string &name, string &buf){
    8938           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    8939           0 :                 string encoded;
    8940             :                 
    8941           0 :                 buf.append("<" + name + "> ");
    8942           0 :                 int ndim = 1;
    8943           0 :                 int dim1 = data.size();
    8944             :  
    8945           0 :                 oss.write((char *)&ndim, sizeof(int));
    8946           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    8947             : 
    8948           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
    8949             :                 
    8950           0 :                 short v = data.at(i);
    8951             :                 
    8952           0 :                 oss.write((char *) &v, sizeof(v));
    8953             :         }
    8954             : 
    8955           0 :                 Base64 b64;
    8956           0 :             b64.encode(oss.str(), encoded, false);
    8957           0 :             buf.append(encoded);
    8958           0 :                 buf.append(" </" + name + "> ");      
    8959           0 :         }
    8960             :         
    8961             :         
    8962           0 :         void Parser::toXMLBase64(vector< vector<short> > data, const string &name, string &buf){
    8963           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    8964           0 :                 string encoded;
    8965             :                 
    8966           0 :                 buf.append("<" + name + "> ");
    8967           0 :                 int ndim = 2;
    8968           0 :                 int dim1 = data.size();
    8969           0 :                 int dim2 = data.at(0).size();
    8970             : 
    8971           0 :                 oss.write((char *)&ndim, sizeof(int));
    8972           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    8973           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    8974           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    8975           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
    8976             :                 
    8977           0 :                         short v = data.at(i).at(j);
    8978             :                 
    8979           0 :                         oss.write((char *) &v, sizeof(v));
    8980             :                 }
    8981             : 
    8982           0 :                 Base64 b64;
    8983           0 :             b64.encode(oss.str(), encoded, false);
    8984           0 :             buf.append(encoded);
    8985           0 :                 buf.append(" </" + name + "> ")
    8986             :                 ;
    8987           0 :         }
    8988             :         
    8989             :         
    8990           0 :         void Parser::toXMLBase64(vector< vector< vector<short> > > data, const string &name, string &buf){
    8991           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    8992           0 :                 string encoded;
    8993             :                 
    8994           0 :                 buf.append("<" + name + "> ");
    8995           0 :                 int ndim = 3;
    8996           0 :                 int dim1 = data.size();
    8997           0 :                 int dim2 = data.at(0).size();
    8998           0 :                 int dim3 = data.at(0).at(0).size();
    8999             : 
    9000           0 :                 oss.write((char *)&ndim, sizeof(int));
    9001           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9002           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    9003           0 :                 oss.write((char *)&dim3, sizeof(dim3));
    9004           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    9005           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
    9006           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
    9007             :                 
    9008           0 :                                 short v = data.at(i).at(j).at(k);
    9009             :                 
    9010           0 :                                 oss.write((char *) &v, sizeof(v));
    9011             :                         }
    9012             : 
    9013           0 :                 Base64 b64;
    9014           0 :             b64.encode(oss.str(), encoded, false);
    9015           0 :             buf.append(encoded);
    9016           0 :                 buf.append(" </" + name + "> ")
    9017             :                 ;
    9018           0 :         }
    9019             :         
    9020             :         
    9021           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<short> > > >data, const string &name, string &buf){
    9022           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    9023           0 :                 string encoded;
    9024             :                 
    9025           0 :                 buf.append("<" + name + "> ");
    9026           0 :                 int ndim = 3;
    9027           0 :                 int dim1 = data.size();
    9028           0 :                 int dim2 = data.at(0).size();
    9029           0 :                 int dim3 = data.at(0).at(0).size();
    9030           0 :                 int dim4 = data.at(0).at(0).at(0).size();
    9031             :                 
    9032           0 :                 oss.write((char *)&ndim, sizeof(int));
    9033           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9034           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    9035           0 :                 oss.write((char *)&dim3, sizeof(dim3));
    9036           0 :                 oss.write((char *)&dim4, sizeof(dim4));
    9037           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    9038           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
    9039           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
    9040           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
    9041             :                 
    9042           0 :                                         short v = data.at(i).at(j).at(k).at(l);
    9043             :                 
    9044           0 :                                 oss.write((char *) &v, sizeof(v));
    9045             :                                 }
    9046             : 
    9047           0 :                 Base64 b64;
    9048           0 :             b64.encode(oss.str(), encoded, false);
    9049           0 :             buf.append(encoded);
    9050           0 :                 buf.append(" </" + name + "> ")
    9051             :                 ;
    9052           0 :         }
    9053             :         
    9054             :         
    9055             : #ifndef Short_CPP
    9056             :                 
    9057             : #define Short_CPP short 
    9058             :                 
    9059             : #endif
    9060             :         
    9061             : 
    9062             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
    9063             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
    9064             :                 
    9065             :     
    9066           0 :         vector<short>& Parser::get1DShortFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<short>& attribute)
    9067             :         {
    9068           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9069           0 :                 if (xmlField.length() == 0) {
    9070           0 :                         throw ConversionException("Error: Field \"" + 
    9071           0 :                                         name + "\": Invalid XML syntax", tableName);
    9072             :                 }
    9073             :                 
    9074           0 :                 string decodedString;
    9075           0 :                 Base64 b64;
    9076           0 :                 b64.decode(xmlField, decodedString);
    9077             :                 
    9078           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9079           0 :                 iss.str(decodedString);
    9080             :                 
    9081           0 :                 attribute.clear();
    9082             :                 
    9083           0 :                 unsigned int ndim = 0;
    9084             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9085           0 :                 TRYREAD(iss,ndim);
    9086             :                 
    9087           0 :                 unsigned int dim1 = 0;
    9088             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9089           0 :                 TRYREAD(iss,dim1);
    9090           0 :                 if (ndim != 1) {
    9091           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
    9092             :                         }
    9093             :                 
    9094           0 :                 attribute.reserve(dim1);
    9095             :                 
    9096             :                 Short_CPP v;
    9097           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9098             :                         //iss.read((char*) &v, sizeof(v));
    9099           0 :                         TRYREAD(iss,v);
    9100             :                 
    9101           0 :                         attribute.push_back(v);
    9102             :                         
    9103             :                 }
    9104           0 :                 return attribute;
    9105           0 :         }
    9106             :         
    9107             :          
    9108           0 :         vector <vector<short> >& Parser::get2DShortFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<short> >& attribute)
    9109             :         {
    9110           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9111           0 :                 if (xmlField.length() == 0) {
    9112           0 :                         throw ConversionException("Error: Field \"" + 
    9113           0 :                                         name + "\": Invalid XML syntax", tableName);
    9114             :                 }
    9115             :                 
    9116           0 :                 string decodedString;
    9117           0 :                 Base64 b64;
    9118           0 :                 b64.decode(xmlField, decodedString);
    9119             :                 
    9120           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9121           0 :                 iss.str(decodedString);
    9122             :                 
    9123           0 :                 attribute.clear();
    9124             :                 
    9125           0 :                 unsigned int ndim = 0;
    9126             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9127           0 :                 TRYREAD(iss,ndim);
    9128             :                 
    9129           0 :                 if (ndim != 2) {
    9130           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
    9131             :                 }
    9132             :         
    9133           0 :                 unsigned int dim1 = 0;
    9134             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9135           0 :                 TRYREAD(iss,dim1);
    9136             :                 
    9137           0 :                 unsigned int dim2 = 0;
    9138             :                 //iss.read((char *)&dim2, sizeof(dim2));
    9139           0 :                 TRYREAD(iss,dim2);
    9140             :                 
    9141           0 :                 attribute.reserve(dim1);
    9142             :                 
    9143             :                 Short_CPP v;
    9144           0 :                 vector<short> aux2;
    9145           0 :                 aux2.reserve(dim2);
    9146           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9147           0 :                         aux2.clear();
    9148           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    9149             :                                 //iss.read((char*) &v, sizeof(v));
    9150           0 :                                 TRYREAD(iss,v);
    9151             :                 
    9152           0 :                                 aux2.push_back(v);
    9153             :                 
    9154             :                         }
    9155           0 :                         attribute.push_back(aux2);      
    9156             :                 }
    9157           0 :                 return attribute;
    9158           0 :         }
    9159             :                 
    9160             :         
    9161           0 :         vector <vector <vector<short> > >& Parser::get3DShortFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<short> > >& attribute)
    9162             :         {
    9163           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9164           0 :                 if (xmlField.length() == 0) {
    9165           0 :                         throw ConversionException("Error: Field \"" + 
    9166           0 :                                         name + "\": Invalid XML syntax", tableName);
    9167             :                 }
    9168             :                 
    9169           0 :                 string decodedString;
    9170           0 :                 Base64 b64;
    9171           0 :                 b64.decode(xmlField, decodedString);
    9172             :                 
    9173           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9174           0 :                 iss.str(decodedString);
    9175             :                 
    9176           0 :                 attribute.clear();
    9177             :                 
    9178           0 :                 unsigned int ndim = 0;
    9179             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9180           0 :                 TRYREAD(iss, ndim);     
    9181           0 :                 if (ndim != 3) {
    9182           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
    9183             :                 }
    9184             :                                 
    9185           0 :                 unsigned int dim1 = 0;
    9186             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9187           0 :                 TRYREAD(iss,dim1);
    9188             :                 
    9189           0 :                 unsigned int dim2 = 0;
    9190             :                 //iss.read((char *)&dim2, sizeof(dim2));
    9191           0 :                 TRYREAD(iss,dim2);
    9192             :                 
    9193           0 :                 unsigned int dim3 = 0;
    9194             :                 //iss.read((char *)&dim2, sizeof(dim3));
    9195           0 :                 TRYREAD(iss,dim3);
    9196             :                 
    9197           0 :                 attribute.reserve(dim1);
    9198             :                 
    9199             :                 Short_CPP v;
    9200           0 :                 vector <vector<short> > aux2;
    9201           0 :                 vector<short> aux3;               
    9202           0 :                 aux2.reserve(dim2);
    9203           0 :                 aux3.reserve(dim3);
    9204             :                 
    9205           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9206           0 :                         aux2.clear();
    9207           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    9208           0 :                                 aux3.clear();
    9209           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
    9210             :                                         //iss.read((char*) &v, sizeof(v));
    9211           0 :                                         TRYREAD(iss,v);
    9212             :                 
    9213           0 :                                         aux3.push_back(v);
    9214             :                 
    9215             :                                 }
    9216           0 :                                 aux2.push_back(aux3);
    9217             :                         }
    9218           0 :                         attribute.push_back(aux2);      
    9219             :                 }
    9220           0 :                 return attribute;
    9221             :                 ;
    9222           0 :         }
    9223             :         
    9224             :         
    9225           0 :         vector <vector <vector <vector<short> > > >& Parser::get4DShortFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<short> > > >& attribute)
    9226             :         {
    9227           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9228           0 :                 if (xmlField.length() == 0) {
    9229           0 :                         throw ConversionException("Error: Field \"" + 
    9230           0 :                                         name + "\": Invalid XML syntax", tableName);
    9231             :                 }
    9232             :                 
    9233           0 :                 string decodedString;
    9234           0 :                 Base64 b64;
    9235           0 :                 b64.decode(xmlField, decodedString);
    9236             :                 
    9237           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9238           0 :                 iss.str(decodedString);
    9239             :                 
    9240           0 :                 attribute.clear();
    9241             :                 
    9242           0 :                 unsigned int ndim = 0;
    9243             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9244           0 :                 TRYREAD(iss, ndim);     
    9245           0 :                 if (ndim != 4) {
    9246           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
    9247             :                 }
    9248             :                                 
    9249           0 :                 unsigned int dim1 = 0;
    9250             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9251           0 :                 TRYREAD(iss,dim1);
    9252             :                 
    9253           0 :                 unsigned int dim2 = 0;
    9254             :                 //iss.read((char *)&dim2, sizeof(dim2));
    9255           0 :                 TRYREAD(iss,dim2);
    9256             :                 
    9257           0 :                 unsigned int dim3 = 0;
    9258             :                 //iss.read((char *)&dim2, sizeof(dim3));
    9259           0 :                 TRYREAD(iss,dim3);
    9260             :                 
    9261           0 :                 unsigned int dim4 = 0;
    9262             :                 //iss.read((char *)&dim2, sizeof(dim3));
    9263           0 :                 TRYREAD(iss,dim3);
    9264             :                 
    9265           0 :                 attribute.reserve(dim1);
    9266             :                 
    9267             :                 Short_CPP v;
    9268           0 :                 vector <vector <vector<short> > > aux2;
    9269           0 :                 vector <vector<short> > aux3;
    9270           0 :                 vector<short> aux4;               
    9271           0 :                 aux2.reserve(dim2);
    9272           0 :                 aux3.reserve(dim3);
    9273           0 :                 aux4.reserve(dim4);
    9274             :                 
    9275           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9276           0 :                         aux2.clear();
    9277           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    9278           0 :                                 aux3.clear();
    9279           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
    9280           0 :                                         aux4.clear();
    9281           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
    9282             :                                         //iss.read((char*) &v, sizeof(v));
    9283           0 :                                                 TRYREAD(iss,v);
    9284             :                 
    9285           0 :                                                 aux4.push_back(v);
    9286             :                 
    9287             :                                         }
    9288           0 :                                         aux3.push_back(aux4);
    9289             :                                 }
    9290           0 :                                 aux2.push_back(aux3);
    9291             :                         }
    9292           0 :                         attribute.push_back(aux2);      
    9293             :                 }
    9294           0 :                 return attribute;
    9295             :                 ;
    9296           0 :         }
    9297             :         
    9298             :         
    9299             : 
    9300             :         
    9301             :         
    9302             :         
    9303             :         
    9304           0 :         void Parser::toXMLBase64(vector<int64_t> data, const string &name, string &buf){
    9305           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    9306           0 :                 string encoded;
    9307             :                 
    9308           0 :                 buf.append("<" + name + "> ");
    9309           0 :                 int ndim = 1;
    9310           0 :                 int dim1 = data.size();
    9311             :  
    9312           0 :                 oss.write((char *)&ndim, sizeof(int));
    9313           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9314             : 
    9315           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
    9316             :                 
    9317           0 :                 int64_t v = data.at(i);
    9318             :                 
    9319           0 :                 oss.write((char *) &v, sizeof(v));
    9320             :         }
    9321             : 
    9322           0 :                 Base64 b64;
    9323           0 :             b64.encode(oss.str(), encoded, false);
    9324           0 :             buf.append(encoded);
    9325           0 :                 buf.append(" </" + name + "> ");      
    9326           0 :         }
    9327             :         
    9328             :         
    9329           0 :         void Parser::toXMLBase64(vector< vector<int64_t> > data, const string &name, string &buf){
    9330           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    9331           0 :                 string encoded;
    9332             :                 
    9333           0 :                 buf.append("<" + name + "> ");
    9334           0 :                 int ndim = 2;
    9335           0 :                 int dim1 = data.size();
    9336           0 :                 int dim2 = data.at(0).size();
    9337             : 
    9338           0 :                 oss.write((char *)&ndim, sizeof(int));
    9339           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9340           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    9341           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    9342           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
    9343             :                 
    9344           0 :                         int64_t v = data.at(i).at(j);
    9345             :                 
    9346           0 :                         oss.write((char *) &v, sizeof(v));
    9347             :                 }
    9348             : 
    9349           0 :                 Base64 b64;
    9350           0 :             b64.encode(oss.str(), encoded, false);
    9351           0 :             buf.append(encoded);
    9352           0 :                 buf.append(" </" + name + "> ")
    9353             :                 ;
    9354           0 :         }
    9355             :         
    9356             :         
    9357           0 :         void Parser::toXMLBase64(vector< vector< vector<int64_t> > > data, const string &name, string &buf){
    9358           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    9359           0 :                 string encoded;
    9360             :                 
    9361           0 :                 buf.append("<" + name + "> ");
    9362           0 :                 int ndim = 3;
    9363           0 :                 int dim1 = data.size();
    9364           0 :                 int dim2 = data.at(0).size();
    9365           0 :                 int dim3 = data.at(0).at(0).size();
    9366             : 
    9367           0 :                 oss.write((char *)&ndim, sizeof(int));
    9368           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9369           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    9370           0 :                 oss.write((char *)&dim3, sizeof(dim3));
    9371           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    9372           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
    9373           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
    9374             :                 
    9375           0 :                                 int64_t v = data.at(i).at(j).at(k);
    9376             :                 
    9377           0 :                                 oss.write((char *) &v, sizeof(v));
    9378             :                         }
    9379             : 
    9380           0 :                 Base64 b64;
    9381           0 :             b64.encode(oss.str(), encoded, false);
    9382           0 :             buf.append(encoded);
    9383           0 :                 buf.append(" </" + name + "> ")
    9384             :                 ;
    9385           0 :         }
    9386             :         
    9387             :         
    9388           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<int64_t> > > >data, const string &name, string &buf){
    9389           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    9390           0 :                 string encoded;
    9391             :                 
    9392           0 :                 buf.append("<" + name + "> ");
    9393           0 :                 int ndim = 3;
    9394           0 :                 int dim1 = data.size();
    9395           0 :                 int dim2 = data.at(0).size();
    9396           0 :                 int dim3 = data.at(0).at(0).size();
    9397           0 :                 int dim4 = data.at(0).at(0).at(0).size();
    9398             :                 
    9399           0 :                 oss.write((char *)&ndim, sizeof(int));
    9400           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9401           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    9402           0 :                 oss.write((char *)&dim3, sizeof(dim3));
    9403           0 :                 oss.write((char *)&dim4, sizeof(dim4));
    9404           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    9405           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
    9406           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
    9407           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
    9408             :                 
    9409           0 :                                         int64_t v = data.at(i).at(j).at(k).at(l);
    9410             :                 
    9411           0 :                                 oss.write((char *) &v, sizeof(v));
    9412             :                                 }
    9413             : 
    9414           0 :                 Base64 b64;
    9415           0 :             b64.encode(oss.str(), encoded, false);
    9416           0 :             buf.append(encoded);
    9417           0 :                 buf.append(" </" + name + "> ")
    9418             :                 ;
    9419           0 :         }
    9420             :         
    9421             :         
    9422             : #ifndef Long_CPP
    9423             :                 
    9424             : #define Long_CPP int64_t
    9425             :                 
    9426             : #endif
    9427             :         
    9428             : 
    9429             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
    9430             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
    9431             :                 
    9432             :     
    9433           0 :         vector<int64_t>& Parser::get1DLongFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<int64_t>& attribute)
    9434             :         {
    9435           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9436           0 :                 if (xmlField.length() == 0) {
    9437           0 :                         throw ConversionException("Error: Field \"" + 
    9438           0 :                                         name + "\": Invalid XML syntax", tableName);
    9439             :                 }
    9440             :                 
    9441           0 :                 string decodedString;
    9442           0 :                 Base64 b64;
    9443           0 :                 b64.decode(xmlField, decodedString);
    9444             :                 
    9445           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9446           0 :                 iss.str(decodedString);
    9447             :                 
    9448           0 :                 attribute.clear();
    9449             :                 
    9450           0 :                 unsigned int ndim = 0;
    9451             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9452           0 :                 TRYREAD(iss,ndim);
    9453             :                 
    9454           0 :                 unsigned int dim1 = 0;
    9455             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9456           0 :                 TRYREAD(iss,dim1);
    9457           0 :                 if (ndim != 1) {
    9458           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
    9459             :                         }
    9460             :                 
    9461           0 :                 attribute.reserve(dim1);
    9462             :                 
    9463             :                 Long_CPP v;
    9464           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9465             :                         //iss.read((char*) &v, sizeof(v));
    9466           0 :                         TRYREAD(iss,v);
    9467             :                 
    9468           0 :                         attribute.push_back(v);
    9469             :                         
    9470             :                 }
    9471           0 :                 return attribute;
    9472           0 :         }
    9473             :         
    9474             :          
    9475           0 :         vector <vector<int64_t> >& Parser::get2DLongFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<int64_t> >& attribute)
    9476             :         {
    9477           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9478           0 :                 if (xmlField.length() == 0) {
    9479           0 :                         throw ConversionException("Error: Field \"" + 
    9480           0 :                                         name + "\": Invalid XML syntax", tableName);
    9481             :                 }
    9482             :                 
    9483           0 :                 string decodedString;
    9484           0 :                 Base64 b64;
    9485           0 :                 b64.decode(xmlField, decodedString);
    9486             :                 
    9487           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9488           0 :                 iss.str(decodedString);
    9489             :                 
    9490           0 :                 attribute.clear();
    9491             :                 
    9492           0 :                 unsigned int ndim = 0;
    9493             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9494           0 :                 TRYREAD(iss,ndim);
    9495             :                 
    9496           0 :                 if (ndim != 2) {
    9497           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
    9498             :                 }
    9499             :         
    9500           0 :                 unsigned int dim1 = 0;
    9501             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9502           0 :                 TRYREAD(iss,dim1);
    9503             :                 
    9504           0 :                 unsigned int dim2 = 0;
    9505             :                 //iss.read((char *)&dim2, sizeof(dim2));
    9506           0 :                 TRYREAD(iss,dim2);
    9507             :                 
    9508           0 :                 attribute.reserve(dim1);
    9509             :                 
    9510             :                 Long_CPP v;
    9511           0 :                 vector<int64_t> aux2;
    9512           0 :                 aux2.reserve(dim2);
    9513           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9514           0 :                         aux2.clear();
    9515           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    9516             :                                 //iss.read((char*) &v, sizeof(v));
    9517           0 :                                 TRYREAD(iss,v);
    9518             :                 
    9519           0 :                                 aux2.push_back(v);
    9520             :                 
    9521             :                         }
    9522           0 :                         attribute.push_back(aux2);      
    9523             :                 }
    9524           0 :                 return attribute;
    9525           0 :         }
    9526             :                 
    9527             :         
    9528           0 :         vector <vector <vector<int64_t> > >& Parser::get3DLongFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<int64_t> > >& attribute)
    9529             :         {
    9530           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9531           0 :                 if (xmlField.length() == 0) {
    9532           0 :                         throw ConversionException("Error: Field \"" + 
    9533           0 :                                         name + "\": Invalid XML syntax", tableName);
    9534             :                 }
    9535             :                 
    9536           0 :                 string decodedString;
    9537           0 :                 Base64 b64;
    9538           0 :                 b64.decode(xmlField, decodedString);
    9539             :                 
    9540           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9541           0 :                 iss.str(decodedString);
    9542             :                 
    9543           0 :                 attribute.clear();
    9544             :                 
    9545           0 :                 unsigned int ndim = 0;
    9546             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9547           0 :                 TRYREAD(iss, ndim);     
    9548           0 :                 if (ndim != 3) {
    9549           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
    9550             :                 }
    9551             :                                 
    9552           0 :                 unsigned int dim1 = 0;
    9553             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9554           0 :                 TRYREAD(iss,dim1);
    9555             :                 
    9556           0 :                 unsigned int dim2 = 0;
    9557             :                 //iss.read((char *)&dim2, sizeof(dim2));
    9558           0 :                 TRYREAD(iss,dim2);
    9559             :                 
    9560           0 :                 unsigned int dim3 = 0;
    9561             :                 //iss.read((char *)&dim2, sizeof(dim3));
    9562           0 :                 TRYREAD(iss,dim3);
    9563             :                 
    9564           0 :                 attribute.reserve(dim1);
    9565             :                 
    9566             :                 Long_CPP v;
    9567           0 :                 vector <vector<int64_t> > aux2;
    9568           0 :                 vector<int64_t> aux3;             
    9569           0 :                 aux2.reserve(dim2);
    9570           0 :                 aux3.reserve(dim3);
    9571             :                 
    9572           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9573           0 :                         aux2.clear();
    9574           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    9575           0 :                                 aux3.clear();
    9576           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
    9577             :                                         //iss.read((char*) &v, sizeof(v));
    9578           0 :                                         TRYREAD(iss,v);
    9579             :                 
    9580           0 :                                         aux3.push_back(v);
    9581             :                 
    9582             :                                 }
    9583           0 :                                 aux2.push_back(aux3);
    9584             :                         }
    9585           0 :                         attribute.push_back(aux2);      
    9586             :                 }
    9587           0 :                 return attribute;
    9588             :                 ;
    9589           0 :         }
    9590             :         
    9591             :         
    9592           0 :         vector <vector <vector <vector<int64_t> > > >& Parser::get4DLongFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<int64_t> > > >& attribute)
    9593             :         {
    9594           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9595           0 :                 if (xmlField.length() == 0) {
    9596           0 :                         throw ConversionException("Error: Field \"" + 
    9597           0 :                                         name + "\": Invalid XML syntax", tableName);
    9598             :                 }
    9599             :                 
    9600           0 :                 string decodedString;
    9601           0 :                 Base64 b64;
    9602           0 :                 b64.decode(xmlField, decodedString);
    9603             :                 
    9604           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9605           0 :                 iss.str(decodedString);
    9606             :                 
    9607           0 :                 attribute.clear();
    9608             :                 
    9609           0 :                 unsigned int ndim = 0;
    9610             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9611           0 :                 TRYREAD(iss, ndim);     
    9612           0 :                 if (ndim != 4) {
    9613           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
    9614             :                 }
    9615             :                                 
    9616           0 :                 unsigned int dim1 = 0;
    9617             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9618           0 :                 TRYREAD(iss,dim1);
    9619             :                 
    9620           0 :                 unsigned int dim2 = 0;
    9621             :                 //iss.read((char *)&dim2, sizeof(dim2));
    9622           0 :                 TRYREAD(iss,dim2);
    9623             :                 
    9624           0 :                 unsigned int dim3 = 0;
    9625             :                 //iss.read((char *)&dim2, sizeof(dim3));
    9626           0 :                 TRYREAD(iss,dim3);
    9627             :                 
    9628           0 :                 unsigned int dim4 = 0;
    9629             :                 //iss.read((char *)&dim2, sizeof(dim3));
    9630           0 :                 TRYREAD(iss,dim3);
    9631             :                 
    9632           0 :                 attribute.reserve(dim1);
    9633             :                 
    9634             :                 Long_CPP v;
    9635           0 :                 vector <vector <vector<int64_t> > > aux2;
    9636           0 :                 vector <vector<int64_t> > aux3;
    9637           0 :                 vector<int64_t> aux4;             
    9638           0 :                 aux2.reserve(dim2);
    9639           0 :                 aux3.reserve(dim3);
    9640           0 :                 aux4.reserve(dim4);
    9641             :                 
    9642           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9643           0 :                         aux2.clear();
    9644           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    9645           0 :                                 aux3.clear();
    9646           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
    9647           0 :                                         aux4.clear();
    9648           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
    9649             :                                         //iss.read((char*) &v, sizeof(v));
    9650           0 :                                                 TRYREAD(iss,v);
    9651             :                 
    9652           0 :                                                 aux4.push_back(v);
    9653             :                 
    9654             :                                         }
    9655           0 :                                         aux3.push_back(aux4);
    9656             :                                 }
    9657           0 :                                 aux2.push_back(aux3);
    9658             :                         }
    9659           0 :                         attribute.push_back(aux2);      
    9660             :                 }
    9661           0 :                 return attribute;
    9662             :                 ;
    9663           0 :         }
    9664             :         
    9665             :         
    9666             : 
    9667             :         
    9668             :         
    9669             :         
    9670             :         
    9671           0 :         void Parser::toXMLBase64(vector<char> data, const string &name, string &buf){
    9672           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    9673           0 :                 string encoded;
    9674             :                 
    9675           0 :                 buf.append("<" + name + "> ");
    9676           0 :                 int ndim = 1;
    9677           0 :                 int dim1 = data.size();
    9678             :  
    9679           0 :                 oss.write((char *)&ndim, sizeof(int));
    9680           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9681             : 
    9682           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
    9683             :                 
    9684           0 :                 char v = data.at(i);
    9685             :                 
    9686           0 :                 oss.write((char *) &v, sizeof(v));
    9687             :         }
    9688             : 
    9689           0 :                 Base64 b64;
    9690           0 :             b64.encode(oss.str(), encoded, false);
    9691           0 :             buf.append(encoded);
    9692           0 :                 buf.append(" </" + name + "> ");      
    9693           0 :         }
    9694             :         
    9695             :         
    9696           0 :         void Parser::toXMLBase64(vector< vector<char> > data, const string &name, string &buf){
    9697           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    9698           0 :                 string encoded;
    9699             :                 
    9700           0 :                 buf.append("<" + name + "> ");
    9701           0 :                 int ndim = 2;
    9702           0 :                 int dim1 = data.size();
    9703           0 :                 int dim2 = data.at(0).size();
    9704             : 
    9705           0 :                 oss.write((char *)&ndim, sizeof(int));
    9706           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9707           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    9708           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    9709           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
    9710             :                 
    9711           0 :                         char v = data.at(i).at(j);
    9712             :                 
    9713           0 :                         oss.write((char *) &v, sizeof(v));
    9714             :                 }
    9715             : 
    9716           0 :                 Base64 b64;
    9717           0 :             b64.encode(oss.str(), encoded, false);
    9718           0 :             buf.append(encoded);
    9719           0 :                 buf.append(" </" + name + "> ")
    9720             :                 ;
    9721           0 :         }
    9722             :         
    9723             :         
    9724           0 :         void Parser::toXMLBase64(vector< vector< vector<char> > > data, const string &name, string &buf){
    9725           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    9726           0 :                 string encoded;
    9727             :                 
    9728           0 :                 buf.append("<" + name + "> ");
    9729           0 :                 int ndim = 3;
    9730           0 :                 int dim1 = data.size();
    9731           0 :                 int dim2 = data.at(0).size();
    9732           0 :                 int dim3 = data.at(0).at(0).size();
    9733             : 
    9734           0 :                 oss.write((char *)&ndim, sizeof(int));
    9735           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9736           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    9737           0 :                 oss.write((char *)&dim3, sizeof(dim3));
    9738           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    9739           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
    9740           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
    9741             :                 
    9742           0 :                                 char v = data.at(i).at(j).at(k);
    9743             :                 
    9744           0 :                                 oss.write((char *) &v, sizeof(v));
    9745             :                         }
    9746             : 
    9747           0 :                 Base64 b64;
    9748           0 :             b64.encode(oss.str(), encoded, false);
    9749           0 :             buf.append(encoded);
    9750           0 :                 buf.append(" </" + name + "> ")
    9751             :                 ;
    9752           0 :         }
    9753             :         
    9754             :         
    9755           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<char> > > >data, const string &name, string &buf){
    9756           0 :                 stringstream oss(stringstream::out | stringstream::binary);
    9757           0 :                 string encoded;
    9758             :                 
    9759           0 :                 buf.append("<" + name + "> ");
    9760           0 :                 int ndim = 3;
    9761           0 :                 int dim1 = data.size();
    9762           0 :                 int dim2 = data.at(0).size();
    9763           0 :                 int dim3 = data.at(0).at(0).size();
    9764           0 :                 int dim4 = data.at(0).at(0).at(0).size();
    9765             :                 
    9766           0 :                 oss.write((char *)&ndim, sizeof(int));
    9767           0 :                 oss.write((char *)&dim1, sizeof(dim1));
    9768           0 :                 oss.write((char *)&dim2, sizeof(dim2));
    9769           0 :                 oss.write((char *)&dim3, sizeof(dim3));
    9770           0 :                 oss.write((char *)&dim4, sizeof(dim4));
    9771           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
    9772           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
    9773           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
    9774           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
    9775             :                 
    9776           0 :                                         char v = data.at(i).at(j).at(k).at(l);
    9777             :                 
    9778           0 :                                 oss.write((char *) &v, sizeof(v));
    9779             :                                 }
    9780             : 
    9781           0 :                 Base64 b64;
    9782           0 :             b64.encode(oss.str(), encoded, false);
    9783           0 :             buf.append(encoded);
    9784           0 :                 buf.append(" </" + name + "> ")
    9785             :                 ;
    9786           0 :         }
    9787             :         
    9788             :         
    9789             : #ifndef Byte_CPP
    9790             :                 
    9791             : #define Byte_CPP char
    9792             :                 
    9793             : #endif
    9794             :         
    9795             : 
    9796             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
    9797             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
    9798             :                 
    9799             :     
    9800           0 :         vector<char>& Parser::get1DByteFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<char>& attribute)
    9801             :         {
    9802           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9803           0 :                 if (xmlField.length() == 0) {
    9804           0 :                         throw ConversionException("Error: Field \"" + 
    9805           0 :                                         name + "\": Invalid XML syntax", tableName);
    9806             :                 }
    9807             :                 
    9808           0 :                 string decodedString;
    9809           0 :                 Base64 b64;
    9810           0 :                 b64.decode(xmlField, decodedString);
    9811             :                 
    9812           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9813           0 :                 iss.str(decodedString);
    9814             :                 
    9815           0 :                 attribute.clear();
    9816             :                 
    9817           0 :                 unsigned int ndim = 0;
    9818             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9819           0 :                 TRYREAD(iss,ndim);
    9820             :                 
    9821           0 :                 unsigned int dim1 = 0;
    9822             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9823           0 :                 TRYREAD(iss,dim1);
    9824           0 :                 if (ndim != 1) {
    9825           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
    9826             :                         }
    9827             :                 
    9828           0 :                 attribute.reserve(dim1);
    9829             :                 
    9830             :                 Byte_CPP v;
    9831           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9832             :                         //iss.read((char*) &v, sizeof(v));
    9833           0 :                         TRYREAD(iss,v);
    9834             :                 
    9835           0 :                         attribute.push_back(v);
    9836             :                         
    9837             :                 }
    9838           0 :                 return attribute;
    9839           0 :         }
    9840             :         
    9841             :          
    9842           0 :         vector <vector<char> >& Parser::get2DByteFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<char> >& attribute)
    9843             :         {
    9844           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9845           0 :                 if (xmlField.length() == 0) {
    9846           0 :                         throw ConversionException("Error: Field \"" + 
    9847           0 :                                         name + "\": Invalid XML syntax", tableName);
    9848             :                 }
    9849             :                 
    9850           0 :                 string decodedString;
    9851           0 :                 Base64 b64;
    9852           0 :                 b64.decode(xmlField, decodedString);
    9853             :                 
    9854           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9855           0 :                 iss.str(decodedString);
    9856             :                 
    9857           0 :                 attribute.clear();
    9858             :                 
    9859           0 :                 unsigned int ndim = 0;
    9860             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9861           0 :                 TRYREAD(iss,ndim);
    9862             :                 
    9863           0 :                 if (ndim != 2) {
    9864           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
    9865             :                 }
    9866             :         
    9867           0 :                 unsigned int dim1 = 0;
    9868             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9869           0 :                 TRYREAD(iss,dim1);
    9870             :                 
    9871           0 :                 unsigned int dim2 = 0;
    9872             :                 //iss.read((char *)&dim2, sizeof(dim2));
    9873           0 :                 TRYREAD(iss,dim2);
    9874             :                 
    9875           0 :                 attribute.reserve(dim1);
    9876             :                 
    9877             :                 Byte_CPP v;
    9878           0 :                 vector<char> aux2;
    9879           0 :                 aux2.reserve(dim2);
    9880           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9881           0 :                         aux2.clear();
    9882           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    9883             :                                 //iss.read((char*) &v, sizeof(v));
    9884           0 :                                 TRYREAD(iss,v);
    9885             :                 
    9886           0 :                                 aux2.push_back(v);
    9887             :                 
    9888             :                         }
    9889           0 :                         attribute.push_back(aux2);      
    9890             :                 }
    9891           0 :                 return attribute;
    9892           0 :         }
    9893             :                 
    9894             :         
    9895           0 :         vector <vector <vector<char> > >& Parser::get3DByteFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<char> > >& attribute)
    9896             :         {
    9897           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9898           0 :                 if (xmlField.length() == 0) {
    9899           0 :                         throw ConversionException("Error: Field \"" + 
    9900           0 :                                         name + "\": Invalid XML syntax", tableName);
    9901             :                 }
    9902             :                 
    9903           0 :                 string decodedString;
    9904           0 :                 Base64 b64;
    9905           0 :                 b64.decode(xmlField, decodedString);
    9906             :                 
    9907           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9908           0 :                 iss.str(decodedString);
    9909             :                 
    9910           0 :                 attribute.clear();
    9911             :                 
    9912           0 :                 unsigned int ndim = 0;
    9913             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9914           0 :                 TRYREAD(iss, ndim);     
    9915           0 :                 if (ndim != 3) {
    9916           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
    9917             :                 }
    9918             :                                 
    9919           0 :                 unsigned int dim1 = 0;
    9920             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9921           0 :                 TRYREAD(iss,dim1);
    9922             :                 
    9923           0 :                 unsigned int dim2 = 0;
    9924             :                 //iss.read((char *)&dim2, sizeof(dim2));
    9925           0 :                 TRYREAD(iss,dim2);
    9926             :                 
    9927           0 :                 unsigned int dim3 = 0;
    9928             :                 //iss.read((char *)&dim2, sizeof(dim3));
    9929           0 :                 TRYREAD(iss,dim3);
    9930             :                 
    9931           0 :                 attribute.reserve(dim1);
    9932             :                 
    9933             :                 Byte_CPP v;
    9934           0 :                 vector <vector<char> > aux2;
    9935           0 :                 vector<char> aux3;                
    9936           0 :                 aux2.reserve(dim2);
    9937           0 :                 aux3.reserve(dim3);
    9938             :                 
    9939           0 :                 for (unsigned int i = 0; i < dim1; i++) {
    9940           0 :                         aux2.clear();
    9941           0 :                         for (unsigned int j = 0; j < dim2; j++) {
    9942           0 :                                 aux3.clear();
    9943           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
    9944             :                                         //iss.read((char*) &v, sizeof(v));
    9945           0 :                                         TRYREAD(iss,v);
    9946             :                 
    9947           0 :                                         aux3.push_back(v);
    9948             :                 
    9949             :                                 }
    9950           0 :                                 aux2.push_back(aux3);
    9951             :                         }
    9952           0 :                         attribute.push_back(aux2);      
    9953             :                 }
    9954           0 :                 return attribute;
    9955             :                 ;
    9956           0 :         }
    9957             :         
    9958             :         
    9959           0 :         vector <vector <vector <vector<char> > > >& Parser::get4DByteFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<char> > > >& attribute)
    9960             :         {
    9961           0 :                 string xmlField = Parser::getField(xmlDoc,name);
    9962           0 :                 if (xmlField.length() == 0) {
    9963           0 :                         throw ConversionException("Error: Field \"" + 
    9964           0 :                                         name + "\": Invalid XML syntax", tableName);
    9965             :                 }
    9966             :                 
    9967           0 :                 string decodedString;
    9968           0 :                 Base64 b64;
    9969           0 :                 b64.decode(xmlField, decodedString);
    9970             :                 
    9971           0 :                 stringstream iss(stringstream::in | stringstream::binary);
    9972           0 :                 iss.str(decodedString);
    9973             :                 
    9974           0 :                 attribute.clear();
    9975             :                 
    9976           0 :                 unsigned int ndim = 0;
    9977             :                 //iss.read((char *)&ndim, sizeof(ndim));
    9978           0 :                 TRYREAD(iss, ndim);     
    9979           0 :                 if (ndim != 4) {
    9980           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
    9981             :                 }
    9982             :                                 
    9983           0 :                 unsigned int dim1 = 0;
    9984             :                 //iss.read((char *)&dim1, sizeof(dim1));
    9985           0 :                 TRYREAD(iss,dim1);
    9986             :                 
    9987           0 :                 unsigned int dim2 = 0;
    9988             :                 //iss.read((char *)&dim2, sizeof(dim2));
    9989           0 :                 TRYREAD(iss,dim2);
    9990             :                 
    9991           0 :                 unsigned int dim3 = 0;
    9992             :                 //iss.read((char *)&dim2, sizeof(dim3));
    9993           0 :                 TRYREAD(iss,dim3);
    9994             :                 
    9995           0 :                 unsigned int dim4 = 0;
    9996             :                 //iss.read((char *)&dim2, sizeof(dim3));
    9997           0 :                 TRYREAD(iss,dim3);
    9998             :                 
    9999           0 :                 attribute.reserve(dim1);
   10000             :                 
   10001             :                 Byte_CPP v;
   10002           0 :                 vector <vector <vector<char> > > aux2;
   10003           0 :                 vector <vector<char> > aux3;
   10004           0 :                 vector<char> aux4;                
   10005           0 :                 aux2.reserve(dim2);
   10006           0 :                 aux3.reserve(dim3);
   10007           0 :                 aux4.reserve(dim4);
   10008             :                 
   10009           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10010           0 :                         aux2.clear();
   10011           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   10012           0 :                                 aux3.clear();
   10013           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   10014           0 :                                         aux4.clear();
   10015           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   10016             :                                         //iss.read((char*) &v, sizeof(v));
   10017           0 :                                                 TRYREAD(iss,v);
   10018             :                 
   10019           0 :                                                 aux4.push_back(v);
   10020             :                 
   10021             :                                         }
   10022           0 :                                         aux3.push_back(aux4);
   10023             :                                 }
   10024           0 :                                 aux2.push_back(aux3);
   10025             :                         }
   10026           0 :                         attribute.push_back(aux2);      
   10027             :                 }
   10028           0 :                 return attribute;
   10029             :                 ;
   10030           0 :         }
   10031             :         
   10032             :         
   10033             : 
   10034             :         
   10035             :         
   10036             :         
   10037             :         
   10038           0 :         void Parser::toXMLBase64(vector<float> data, const string &name, string &buf){
   10039           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10040           0 :                 string encoded;
   10041             :                 
   10042           0 :                 buf.append("<" + name + "> ");
   10043           0 :                 int ndim = 1;
   10044           0 :                 int dim1 = data.size();
   10045             :  
   10046           0 :                 oss.write((char *)&ndim, sizeof(int));
   10047           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10048             : 
   10049           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   10050             :                 
   10051           0 :                 float v = data.at(i);
   10052             :                 
   10053           0 :                 oss.write((char *) &v, sizeof(v));
   10054             :         }
   10055             : 
   10056           0 :                 Base64 b64;
   10057           0 :             b64.encode(oss.str(), encoded, false);
   10058           0 :             buf.append(encoded);
   10059           0 :                 buf.append(" </" + name + "> ");      
   10060           0 :         }
   10061             :         
   10062             :         
   10063           0 :         void Parser::toXMLBase64(vector< vector<float> > data, const string &name, string &buf){
   10064           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10065           0 :                 string encoded;
   10066             :                 
   10067           0 :                 buf.append("<" + name + "> ");
   10068           0 :                 int ndim = 2;
   10069           0 :                 int dim1 = data.size();
   10070           0 :                 int dim2 = data.at(0).size();
   10071             : 
   10072           0 :                 oss.write((char *)&ndim, sizeof(int));
   10073           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10074           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   10075           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   10076           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   10077             :                 
   10078           0 :                         float v = data.at(i).at(j);
   10079             :                 
   10080           0 :                         oss.write((char *) &v, sizeof(v));
   10081             :                 }
   10082             : 
   10083           0 :                 Base64 b64;
   10084           0 :             b64.encode(oss.str(), encoded, false);
   10085           0 :             buf.append(encoded);
   10086           0 :                 buf.append(" </" + name + "> ")
   10087             :                 ;
   10088           0 :         }
   10089             :         
   10090             :         
   10091           0 :         void Parser::toXMLBase64(vector< vector< vector<float> > > data, const string &name, string &buf){
   10092           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10093           0 :                 string encoded;
   10094             :                 
   10095           0 :                 buf.append("<" + name + "> ");
   10096           0 :                 int ndim = 3;
   10097           0 :                 int dim1 = data.size();
   10098           0 :                 int dim2 = data.at(0).size();
   10099           0 :                 int dim3 = data.at(0).at(0).size();
   10100             : 
   10101           0 :                 oss.write((char *)&ndim, sizeof(int));
   10102           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10103           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   10104           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   10105           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   10106           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   10107           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   10108             :                 
   10109           0 :                                 float v = data.at(i).at(j).at(k);
   10110             :                 
   10111           0 :                                 oss.write((char *) &v, sizeof(v));
   10112             :                         }
   10113             : 
   10114           0 :                 Base64 b64;
   10115           0 :             b64.encode(oss.str(), encoded, false);
   10116           0 :             buf.append(encoded);
   10117           0 :                 buf.append(" </" + name + "> ")
   10118             :                 ;
   10119           0 :         }
   10120             :         
   10121             :         
   10122           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<float> > > >data, const string &name, string &buf){
   10123           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10124           0 :                 string encoded;
   10125             :                 
   10126           0 :                 buf.append("<" + name + "> ");
   10127           0 :                 int ndim = 3;
   10128           0 :                 int dim1 = data.size();
   10129           0 :                 int dim2 = data.at(0).size();
   10130           0 :                 int dim3 = data.at(0).at(0).size();
   10131           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   10132             :                 
   10133           0 :                 oss.write((char *)&ndim, sizeof(int));
   10134           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10135           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   10136           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   10137           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   10138           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   10139           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   10140           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   10141           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   10142             :                 
   10143           0 :                                         float v = data.at(i).at(j).at(k).at(l);
   10144             :                 
   10145           0 :                                 oss.write((char *) &v, sizeof(v));
   10146             :                                 }
   10147             : 
   10148           0 :                 Base64 b64;
   10149           0 :             b64.encode(oss.str(), encoded, false);
   10150           0 :             buf.append(encoded);
   10151           0 :                 buf.append(" </" + name + "> ")
   10152             :                 ;
   10153           0 :         }
   10154             :         
   10155             :         
   10156             : #ifndef Float_CPP
   10157             :                 
   10158             : #define Float_CPP float 
   10159             :                 
   10160             : #endif
   10161             :         
   10162             : 
   10163             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   10164             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   10165             :                 
   10166             :     
   10167           0 :         vector<float>& Parser::get1DFloatFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<float>& attribute)
   10168             :         {
   10169           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10170           0 :                 if (xmlField.length() == 0) {
   10171           0 :                         throw ConversionException("Error: Field \"" + 
   10172           0 :                                         name + "\": Invalid XML syntax", tableName);
   10173             :                 }
   10174             :                 
   10175           0 :                 string decodedString;
   10176           0 :                 Base64 b64;
   10177           0 :                 b64.decode(xmlField, decodedString);
   10178             :                 
   10179           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10180           0 :                 iss.str(decodedString);
   10181             :                 
   10182           0 :                 attribute.clear();
   10183             :                 
   10184           0 :                 unsigned int ndim = 0;
   10185             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10186           0 :                 TRYREAD(iss,ndim);
   10187             :                 
   10188           0 :                 unsigned int dim1 = 0;
   10189             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10190           0 :                 TRYREAD(iss,dim1);
   10191           0 :                 if (ndim != 1) {
   10192           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   10193             :                         }
   10194             :                 
   10195           0 :                 attribute.reserve(dim1);
   10196             :                 
   10197             :                 Float_CPP v;
   10198           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10199             :                         //iss.read((char*) &v, sizeof(v));
   10200           0 :                         TRYREAD(iss,v);
   10201             :                 
   10202           0 :                         attribute.push_back(v);
   10203             :                         
   10204             :                 }
   10205           0 :                 return attribute;
   10206           0 :         }
   10207             :         
   10208             :          
   10209           0 :         vector <vector<float> >& Parser::get2DFloatFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<float> >& attribute)
   10210             :         {
   10211           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10212           0 :                 if (xmlField.length() == 0) {
   10213           0 :                         throw ConversionException("Error: Field \"" + 
   10214           0 :                                         name + "\": Invalid XML syntax", tableName);
   10215             :                 }
   10216             :                 
   10217           0 :                 string decodedString;
   10218           0 :                 Base64 b64;
   10219           0 :                 b64.decode(xmlField, decodedString);
   10220             :                 
   10221           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10222           0 :                 iss.str(decodedString);
   10223             :                 
   10224           0 :                 attribute.clear();
   10225             :                 
   10226           0 :                 unsigned int ndim = 0;
   10227             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10228           0 :                 TRYREAD(iss,ndim);
   10229             :                 
   10230           0 :                 if (ndim != 2) {
   10231           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   10232             :                 }
   10233             :         
   10234           0 :                 unsigned int dim1 = 0;
   10235             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10236           0 :                 TRYREAD(iss,dim1);
   10237             :                 
   10238           0 :                 unsigned int dim2 = 0;
   10239             :                 //iss.read((char *)&dim2, sizeof(dim2));
   10240           0 :                 TRYREAD(iss,dim2);
   10241             :                 
   10242           0 :                 attribute.reserve(dim1);
   10243             :                 
   10244             :                 Float_CPP v;
   10245           0 :                 vector<float> aux2;
   10246           0 :                 aux2.reserve(dim2);
   10247           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10248           0 :                         aux2.clear();
   10249           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   10250             :                                 //iss.read((char*) &v, sizeof(v));
   10251           0 :                                 TRYREAD(iss,v);
   10252             :                 
   10253           0 :                                 aux2.push_back(v);
   10254             :                 
   10255             :                         }
   10256           0 :                         attribute.push_back(aux2);      
   10257             :                 }
   10258           0 :                 return attribute;
   10259           0 :         }
   10260             :                 
   10261             :         
   10262           0 :         vector <vector <vector<float> > >& Parser::get3DFloatFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<float> > >& attribute)
   10263             :         {
   10264           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10265           0 :                 if (xmlField.length() == 0) {
   10266           0 :                         throw ConversionException("Error: Field \"" + 
   10267           0 :                                         name + "\": Invalid XML syntax", tableName);
   10268             :                 }
   10269             :                 
   10270           0 :                 string decodedString;
   10271           0 :                 Base64 b64;
   10272           0 :                 b64.decode(xmlField, decodedString);
   10273             :                 
   10274           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10275           0 :                 iss.str(decodedString);
   10276             :                 
   10277           0 :                 attribute.clear();
   10278             :                 
   10279           0 :                 unsigned int ndim = 0;
   10280             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10281           0 :                 TRYREAD(iss, ndim);     
   10282           0 :                 if (ndim != 3) {
   10283           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   10284             :                 }
   10285             :                                 
   10286           0 :                 unsigned int dim1 = 0;
   10287             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10288           0 :                 TRYREAD(iss,dim1);
   10289             :                 
   10290           0 :                 unsigned int dim2 = 0;
   10291             :                 //iss.read((char *)&dim2, sizeof(dim2));
   10292           0 :                 TRYREAD(iss,dim2);
   10293             :                 
   10294           0 :                 unsigned int dim3 = 0;
   10295             :                 //iss.read((char *)&dim2, sizeof(dim3));
   10296           0 :                 TRYREAD(iss,dim3);
   10297             :                 
   10298           0 :                 attribute.reserve(dim1);
   10299             :                 
   10300             :                 Float_CPP v;
   10301           0 :                 vector <vector<float> > aux2;
   10302           0 :                 vector<float> aux3;               
   10303           0 :                 aux2.reserve(dim2);
   10304           0 :                 aux3.reserve(dim3);
   10305             :                 
   10306           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10307           0 :                         aux2.clear();
   10308           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   10309           0 :                                 aux3.clear();
   10310           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   10311             :                                         //iss.read((char*) &v, sizeof(v));
   10312           0 :                                         TRYREAD(iss,v);
   10313             :                 
   10314           0 :                                         aux3.push_back(v);
   10315             :                 
   10316             :                                 }
   10317           0 :                                 aux2.push_back(aux3);
   10318             :                         }
   10319           0 :                         attribute.push_back(aux2);      
   10320             :                 }
   10321           0 :                 return attribute;
   10322             :                 ;
   10323           0 :         }
   10324             :         
   10325             :         
   10326           0 :         vector <vector <vector <vector<float> > > >& Parser::get4DFloatFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<float> > > >& attribute)
   10327             :         {
   10328           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10329           0 :                 if (xmlField.length() == 0) {
   10330           0 :                         throw ConversionException("Error: Field \"" + 
   10331           0 :                                         name + "\": Invalid XML syntax", tableName);
   10332             :                 }
   10333             :                 
   10334           0 :                 string decodedString;
   10335           0 :                 Base64 b64;
   10336           0 :                 b64.decode(xmlField, decodedString);
   10337             :                 
   10338           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10339           0 :                 iss.str(decodedString);
   10340             :                 
   10341           0 :                 attribute.clear();
   10342             :                 
   10343           0 :                 unsigned int ndim = 0;
   10344             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10345           0 :                 TRYREAD(iss, ndim);     
   10346           0 :                 if (ndim != 4) {
   10347           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   10348             :                 }
   10349             :                                 
   10350           0 :                 unsigned int dim1 = 0;
   10351             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10352           0 :                 TRYREAD(iss,dim1);
   10353             :                 
   10354           0 :                 unsigned int dim2 = 0;
   10355             :                 //iss.read((char *)&dim2, sizeof(dim2));
   10356           0 :                 TRYREAD(iss,dim2);
   10357             :                 
   10358           0 :                 unsigned int dim3 = 0;
   10359             :                 //iss.read((char *)&dim2, sizeof(dim3));
   10360           0 :                 TRYREAD(iss,dim3);
   10361             :                 
   10362           0 :                 unsigned int dim4 = 0;
   10363             :                 //iss.read((char *)&dim2, sizeof(dim3));
   10364           0 :                 TRYREAD(iss,dim3);
   10365             :                 
   10366           0 :                 attribute.reserve(dim1);
   10367             :                 
   10368             :                 Float_CPP v;
   10369           0 :                 vector <vector <vector<float> > > aux2;
   10370           0 :                 vector <vector<float> > aux3;
   10371           0 :                 vector<float> aux4;               
   10372           0 :                 aux2.reserve(dim2);
   10373           0 :                 aux3.reserve(dim3);
   10374           0 :                 aux4.reserve(dim4);
   10375             :                 
   10376           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10377           0 :                         aux2.clear();
   10378           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   10379           0 :                                 aux3.clear();
   10380           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   10381           0 :                                         aux4.clear();
   10382           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   10383             :                                         //iss.read((char*) &v, sizeof(v));
   10384           0 :                                                 TRYREAD(iss,v);
   10385             :                 
   10386           0 :                                                 aux4.push_back(v);
   10387             :                 
   10388             :                                         }
   10389           0 :                                         aux3.push_back(aux4);
   10390             :                                 }
   10391           0 :                                 aux2.push_back(aux3);
   10392             :                         }
   10393           0 :                         attribute.push_back(aux2);      
   10394             :                 }
   10395           0 :                 return attribute;
   10396             :                 ;
   10397           0 :         }
   10398             :         
   10399             :         
   10400             : 
   10401             :         
   10402             :         
   10403             :         
   10404             :         
   10405           0 :         void Parser::toXMLBase64(vector<double> data, const string &name, string &buf){
   10406           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10407           0 :                 string encoded;
   10408             :                 
   10409           0 :                 buf.append("<" + name + "> ");
   10410           0 :                 int ndim = 1;
   10411           0 :                 int dim1 = data.size();
   10412             :  
   10413           0 :                 oss.write((char *)&ndim, sizeof(int));
   10414           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10415             : 
   10416           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   10417             :                 
   10418           0 :                 double v = data.at(i);
   10419             :                 
   10420           0 :                 oss.write((char *) &v, sizeof(v));
   10421             :         }
   10422             : 
   10423           0 :                 Base64 b64;
   10424           0 :             b64.encode(oss.str(), encoded, false);
   10425           0 :             buf.append(encoded);
   10426           0 :                 buf.append(" </" + name + "> ");      
   10427           0 :         }
   10428             :         
   10429             :         
   10430           0 :         void Parser::toXMLBase64(vector< vector<double> > data, const string &name, string &buf){
   10431           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10432           0 :                 string encoded;
   10433             :                 
   10434           0 :                 buf.append("<" + name + "> ");
   10435           0 :                 int ndim = 2;
   10436           0 :                 int dim1 = data.size();
   10437           0 :                 int dim2 = data.at(0).size();
   10438             : 
   10439           0 :                 oss.write((char *)&ndim, sizeof(int));
   10440           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10441           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   10442           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   10443           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   10444             :                 
   10445           0 :                         double v = data.at(i).at(j);
   10446             :                 
   10447           0 :                         oss.write((char *) &v, sizeof(v));
   10448             :                 }
   10449             : 
   10450           0 :                 Base64 b64;
   10451           0 :             b64.encode(oss.str(), encoded, false);
   10452           0 :             buf.append(encoded);
   10453           0 :                 buf.append(" </" + name + "> ")
   10454             :                 ;
   10455           0 :         }
   10456             :         
   10457             :         
   10458           0 :         void Parser::toXMLBase64(vector< vector< vector<double> > > data, const string &name, string &buf){
   10459           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10460           0 :                 string encoded;
   10461             :                 
   10462           0 :                 buf.append("<" + name + "> ");
   10463           0 :                 int ndim = 3;
   10464           0 :                 int dim1 = data.size();
   10465           0 :                 int dim2 = data.at(0).size();
   10466           0 :                 int dim3 = data.at(0).at(0).size();
   10467             : 
   10468           0 :                 oss.write((char *)&ndim, sizeof(int));
   10469           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10470           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   10471           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   10472           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   10473           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   10474           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   10475             :                 
   10476           0 :                                 double v = data.at(i).at(j).at(k);
   10477             :                 
   10478           0 :                                 oss.write((char *) &v, sizeof(v));
   10479             :                         }
   10480             : 
   10481           0 :                 Base64 b64;
   10482           0 :             b64.encode(oss.str(), encoded, false);
   10483           0 :             buf.append(encoded);
   10484           0 :                 buf.append(" </" + name + "> ")
   10485             :                 ;
   10486           0 :         }
   10487             :         
   10488             :         
   10489           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<double> > > >data, const string &name, string &buf){
   10490           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10491           0 :                 string encoded;
   10492             :                 
   10493           0 :                 buf.append("<" + name + "> ");
   10494           0 :                 int ndim = 3;
   10495           0 :                 int dim1 = data.size();
   10496           0 :                 int dim2 = data.at(0).size();
   10497           0 :                 int dim3 = data.at(0).at(0).size();
   10498           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   10499             :                 
   10500           0 :                 oss.write((char *)&ndim, sizeof(int));
   10501           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10502           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   10503           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   10504           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   10505           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   10506           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   10507           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   10508           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   10509             :                 
   10510           0 :                                         double v = data.at(i).at(j).at(k).at(l);
   10511             :                 
   10512           0 :                                 oss.write((char *) &v, sizeof(v));
   10513             :                                 }
   10514             : 
   10515           0 :                 Base64 b64;
   10516           0 :             b64.encode(oss.str(), encoded, false);
   10517           0 :             buf.append(encoded);
   10518           0 :                 buf.append(" </" + name + "> ")
   10519             :                 ;
   10520           0 :         }
   10521             :         
   10522             :         
   10523             : #ifndef Double_CPP
   10524             :                 
   10525             : #define Double_CPP double       
   10526             :                 
   10527             : #endif
   10528             :         
   10529             : 
   10530             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   10531             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   10532             :                 
   10533             :     
   10534           0 :         vector<double>& Parser::get1DDoubleFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<double>& attribute)
   10535             :         {
   10536           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10537           0 :                 if (xmlField.length() == 0) {
   10538           0 :                         throw ConversionException("Error: Field \"" + 
   10539           0 :                                         name + "\": Invalid XML syntax", tableName);
   10540             :                 }
   10541             :                 
   10542           0 :                 string decodedString;
   10543           0 :                 Base64 b64;
   10544           0 :                 b64.decode(xmlField, decodedString);
   10545             :                 
   10546           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10547           0 :                 iss.str(decodedString);
   10548             :                 
   10549           0 :                 attribute.clear();
   10550             :                 
   10551           0 :                 unsigned int ndim = 0;
   10552             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10553           0 :                 TRYREAD(iss,ndim);
   10554             :                 
   10555           0 :                 unsigned int dim1 = 0;
   10556             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10557           0 :                 TRYREAD(iss,dim1);
   10558           0 :                 if (ndim != 1) {
   10559           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   10560             :                         }
   10561             :                 
   10562           0 :                 attribute.reserve(dim1);
   10563             :                 
   10564             :                 Double_CPP v;
   10565           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10566             :                         //iss.read((char*) &v, sizeof(v));
   10567           0 :                         TRYREAD(iss,v);
   10568             :                 
   10569           0 :                         attribute.push_back(v);
   10570             :                         
   10571             :                 }
   10572           0 :                 return attribute;
   10573           0 :         }
   10574             :         
   10575             :          
   10576           0 :         vector <vector<double> >& Parser::get2DDoubleFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<double> >& attribute)
   10577             :         {
   10578           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10579           0 :                 if (xmlField.length() == 0) {
   10580           0 :                         throw ConversionException("Error: Field \"" + 
   10581           0 :                                         name + "\": Invalid XML syntax", tableName);
   10582             :                 }
   10583             :                 
   10584           0 :                 string decodedString;
   10585           0 :                 Base64 b64;
   10586           0 :                 b64.decode(xmlField, decodedString);
   10587             :                 
   10588           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10589           0 :                 iss.str(decodedString);
   10590             :                 
   10591           0 :                 attribute.clear();
   10592             :                 
   10593           0 :                 unsigned int ndim = 0;
   10594             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10595           0 :                 TRYREAD(iss,ndim);
   10596             :                 
   10597           0 :                 if (ndim != 2) {
   10598           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   10599             :                 }
   10600             :         
   10601           0 :                 unsigned int dim1 = 0;
   10602             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10603           0 :                 TRYREAD(iss,dim1);
   10604             :                 
   10605           0 :                 unsigned int dim2 = 0;
   10606             :                 //iss.read((char *)&dim2, sizeof(dim2));
   10607           0 :                 TRYREAD(iss,dim2);
   10608             :                 
   10609           0 :                 attribute.reserve(dim1);
   10610             :                 
   10611             :                 Double_CPP v;
   10612           0 :                 vector<double> aux2;
   10613           0 :                 aux2.reserve(dim2);
   10614           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10615           0 :                         aux2.clear();
   10616           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   10617             :                                 //iss.read((char*) &v, sizeof(v));
   10618           0 :                                 TRYREAD(iss,v);
   10619             :                 
   10620           0 :                                 aux2.push_back(v);
   10621             :                 
   10622             :                         }
   10623           0 :                         attribute.push_back(aux2);      
   10624             :                 }
   10625           0 :                 return attribute;
   10626           0 :         }
   10627             :                 
   10628             :         
   10629           0 :         vector <vector <vector<double> > >& Parser::get3DDoubleFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<double> > >& attribute)
   10630             :         {
   10631           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10632           0 :                 if (xmlField.length() == 0) {
   10633           0 :                         throw ConversionException("Error: Field \"" + 
   10634           0 :                                         name + "\": Invalid XML syntax", tableName);
   10635             :                 }
   10636             :                 
   10637           0 :                 string decodedString;
   10638           0 :                 Base64 b64;
   10639           0 :                 b64.decode(xmlField, decodedString);
   10640             :                 
   10641           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10642           0 :                 iss.str(decodedString);
   10643             :                 
   10644           0 :                 attribute.clear();
   10645             :                 
   10646           0 :                 unsigned int ndim = 0;
   10647             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10648           0 :                 TRYREAD(iss, ndim);     
   10649           0 :                 if (ndim != 3) {
   10650           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   10651             :                 }
   10652             :                                 
   10653           0 :                 unsigned int dim1 = 0;
   10654             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10655           0 :                 TRYREAD(iss,dim1);
   10656             :                 
   10657           0 :                 unsigned int dim2 = 0;
   10658             :                 //iss.read((char *)&dim2, sizeof(dim2));
   10659           0 :                 TRYREAD(iss,dim2);
   10660             :                 
   10661           0 :                 unsigned int dim3 = 0;
   10662             :                 //iss.read((char *)&dim2, sizeof(dim3));
   10663           0 :                 TRYREAD(iss,dim3);
   10664             :                 
   10665           0 :                 attribute.reserve(dim1);
   10666             :                 
   10667             :                 Double_CPP v;
   10668           0 :                 vector <vector<double> > aux2;
   10669           0 :                 vector<double> aux3;              
   10670           0 :                 aux2.reserve(dim2);
   10671           0 :                 aux3.reserve(dim3);
   10672             :                 
   10673           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10674           0 :                         aux2.clear();
   10675           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   10676           0 :                                 aux3.clear();
   10677           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   10678             :                                         //iss.read((char*) &v, sizeof(v));
   10679           0 :                                         TRYREAD(iss,v);
   10680             :                 
   10681           0 :                                         aux3.push_back(v);
   10682             :                 
   10683             :                                 }
   10684           0 :                                 aux2.push_back(aux3);
   10685             :                         }
   10686           0 :                         attribute.push_back(aux2);      
   10687             :                 }
   10688           0 :                 return attribute;
   10689             :                 ;
   10690           0 :         }
   10691             :         
   10692             :         
   10693           0 :         vector <vector <vector <vector<double> > > >& Parser::get4DDoubleFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<double> > > >& attribute)
   10694             :         {
   10695           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10696           0 :                 if (xmlField.length() == 0) {
   10697           0 :                         throw ConversionException("Error: Field \"" + 
   10698           0 :                                         name + "\": Invalid XML syntax", tableName);
   10699             :                 }
   10700             :                 
   10701           0 :                 string decodedString;
   10702           0 :                 Base64 b64;
   10703           0 :                 b64.decode(xmlField, decodedString);
   10704             :                 
   10705           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10706           0 :                 iss.str(decodedString);
   10707             :                 
   10708           0 :                 attribute.clear();
   10709             :                 
   10710           0 :                 unsigned int ndim = 0;
   10711             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10712           0 :                 TRYREAD(iss, ndim);     
   10713           0 :                 if (ndim != 4) {
   10714           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   10715             :                 }
   10716             :                                 
   10717           0 :                 unsigned int dim1 = 0;
   10718             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10719           0 :                 TRYREAD(iss,dim1);
   10720             :                 
   10721           0 :                 unsigned int dim2 = 0;
   10722             :                 //iss.read((char *)&dim2, sizeof(dim2));
   10723           0 :                 TRYREAD(iss,dim2);
   10724             :                 
   10725           0 :                 unsigned int dim3 = 0;
   10726             :                 //iss.read((char *)&dim2, sizeof(dim3));
   10727           0 :                 TRYREAD(iss,dim3);
   10728             :                 
   10729           0 :                 unsigned int dim4 = 0;
   10730             :                 //iss.read((char *)&dim2, sizeof(dim3));
   10731           0 :                 TRYREAD(iss,dim3);
   10732             :                 
   10733           0 :                 attribute.reserve(dim1);
   10734             :                 
   10735             :                 Double_CPP v;
   10736           0 :                 vector <vector <vector<double> > > aux2;
   10737           0 :                 vector <vector<double> > aux3;
   10738           0 :                 vector<double> aux4;              
   10739           0 :                 aux2.reserve(dim2);
   10740           0 :                 aux3.reserve(dim3);
   10741           0 :                 aux4.reserve(dim4);
   10742             :                 
   10743           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10744           0 :                         aux2.clear();
   10745           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   10746           0 :                                 aux3.clear();
   10747           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   10748           0 :                                         aux4.clear();
   10749           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   10750             :                                         //iss.read((char*) &v, sizeof(v));
   10751           0 :                                                 TRYREAD(iss,v);
   10752             :                 
   10753           0 :                                                 aux4.push_back(v);
   10754             :                 
   10755             :                                         }
   10756           0 :                                         aux3.push_back(aux4);
   10757             :                                 }
   10758           0 :                                 aux2.push_back(aux3);
   10759             :                         }
   10760           0 :                         attribute.push_back(aux2);      
   10761             :                 }
   10762           0 :                 return attribute;
   10763             :                 ;
   10764           0 :         }
   10765             :         
   10766             :         
   10767             : 
   10768             :         
   10769             :         
   10770             :         
   10771             :         
   10772           0 :         void Parser::toXMLBase64(vector<unsigned char> data, const string &name, string &buf){
   10773           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10774           0 :                 string encoded;
   10775             :                 
   10776           0 :                 buf.append("<" + name + "> ");
   10777           0 :                 int ndim = 1;
   10778           0 :                 int dim1 = data.size();
   10779             :  
   10780           0 :                 oss.write((char *)&ndim, sizeof(int));
   10781           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10782             : 
   10783           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   10784             :                 
   10785           0 :                 unsigned char v = data.at(i);
   10786             :                 
   10787           0 :                 oss.write((char *) &v, sizeof(v));
   10788             :         }
   10789             : 
   10790           0 :                 Base64 b64;
   10791           0 :             b64.encode(oss.str(), encoded, false);
   10792           0 :             buf.append(encoded);
   10793           0 :                 buf.append(" </" + name + "> ");      
   10794           0 :         }
   10795             :         
   10796             :         
   10797           0 :         void Parser::toXMLBase64(vector< vector<unsigned char> > data, const string &name, string &buf){
   10798           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10799           0 :                 string encoded;
   10800             :                 
   10801           0 :                 buf.append("<" + name + "> ");
   10802           0 :                 int ndim = 2;
   10803           0 :                 int dim1 = data.size();
   10804           0 :                 int dim2 = data.at(0).size();
   10805             : 
   10806           0 :                 oss.write((char *)&ndim, sizeof(int));
   10807           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10808           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   10809           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   10810           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   10811             :                 
   10812           0 :                         unsigned char v = data.at(i).at(j);
   10813             :                 
   10814           0 :                         oss.write((char *) &v, sizeof(v));
   10815             :                 }
   10816             : 
   10817           0 :                 Base64 b64;
   10818           0 :             b64.encode(oss.str(), encoded, false);
   10819           0 :             buf.append(encoded);
   10820           0 :                 buf.append(" </" + name + "> ")
   10821             :                 ;
   10822           0 :         }
   10823             :         
   10824             :         
   10825           0 :         void Parser::toXMLBase64(vector< vector< vector<unsigned char> > > data, const string &name, string &buf){
   10826           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10827           0 :                 string encoded;
   10828             :                 
   10829           0 :                 buf.append("<" + name + "> ");
   10830           0 :                 int ndim = 3;
   10831           0 :                 int dim1 = data.size();
   10832           0 :                 int dim2 = data.at(0).size();
   10833           0 :                 int dim3 = data.at(0).at(0).size();
   10834             : 
   10835           0 :                 oss.write((char *)&ndim, sizeof(int));
   10836           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10837           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   10838           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   10839           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   10840           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   10841           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   10842             :                 
   10843           0 :                                 unsigned char v = data.at(i).at(j).at(k);
   10844             :                 
   10845           0 :                                 oss.write((char *) &v, sizeof(v));
   10846             :                         }
   10847             : 
   10848           0 :                 Base64 b64;
   10849           0 :             b64.encode(oss.str(), encoded, false);
   10850           0 :             buf.append(encoded);
   10851           0 :                 buf.append(" </" + name + "> ")
   10852             :                 ;
   10853           0 :         }
   10854             :         
   10855             :         
   10856           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<unsigned char> > > >data, const string &name, string &buf){
   10857           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   10858           0 :                 string encoded;
   10859             :                 
   10860           0 :                 buf.append("<" + name + "> ");
   10861           0 :                 int ndim = 3;
   10862           0 :                 int dim1 = data.size();
   10863           0 :                 int dim2 = data.at(0).size();
   10864           0 :                 int dim3 = data.at(0).at(0).size();
   10865           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   10866             :                 
   10867           0 :                 oss.write((char *)&ndim, sizeof(int));
   10868           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   10869           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   10870           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   10871           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   10872           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   10873           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   10874           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   10875           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   10876             :                 
   10877           0 :                                         unsigned char v = data.at(i).at(j).at(k).at(l);
   10878             :                 
   10879           0 :                                 oss.write((char *) &v, sizeof(v));
   10880             :                                 }
   10881             : 
   10882           0 :                 Base64 b64;
   10883           0 :             b64.encode(oss.str(), encoded, false);
   10884           0 :             buf.append(encoded);
   10885           0 :                 buf.append(" </" + name + "> ")
   10886             :                 ;
   10887           0 :         }
   10888             :         
   10889             :         
   10890             : #ifndef Char_CPP
   10891             :                 
   10892             : #define Char_CPP char   
   10893             :                 
   10894             : #endif
   10895             :         
   10896             : 
   10897             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   10898             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   10899             :                 
   10900             :     
   10901           0 :         vector<unsigned char>& Parser::get1DCharacterFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<unsigned char>& attribute)
   10902             :         {
   10903           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10904           0 :                 if (xmlField.length() == 0) {
   10905           0 :                         throw ConversionException("Error: Field \"" + 
   10906           0 :                                         name + "\": Invalid XML syntax", tableName);
   10907             :                 }
   10908             :                 
   10909           0 :                 string decodedString;
   10910           0 :                 Base64 b64;
   10911           0 :                 b64.decode(xmlField, decodedString);
   10912             :                 
   10913           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10914           0 :                 iss.str(decodedString);
   10915             :                 
   10916           0 :                 attribute.clear();
   10917             :                 
   10918           0 :                 unsigned int ndim = 0;
   10919             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10920           0 :                 TRYREAD(iss,ndim);
   10921             :                 
   10922           0 :                 unsigned int dim1 = 0;
   10923             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10924           0 :                 TRYREAD(iss,dim1);
   10925           0 :                 if (ndim != 1) {
   10926           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   10927             :                         }
   10928             :                 
   10929           0 :                 attribute.reserve(dim1);
   10930             :                 
   10931             :                 Char_CPP v;
   10932           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10933             :                         //iss.read((char*) &v, sizeof(v));
   10934           0 :                         TRYREAD(iss,v);
   10935             :                 
   10936           0 :                         attribute.push_back(v);
   10937             :                         
   10938             :                 }
   10939           0 :                 return attribute;
   10940           0 :         }
   10941             :         
   10942             :          
   10943           0 :         vector <vector<unsigned char> >& Parser::get2DCharacterFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<unsigned char> >& attribute)
   10944             :         {
   10945           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10946           0 :                 if (xmlField.length() == 0) {
   10947           0 :                         throw ConversionException("Error: Field \"" + 
   10948           0 :                                         name + "\": Invalid XML syntax", tableName);
   10949             :                 }
   10950             :                 
   10951           0 :                 string decodedString;
   10952           0 :                 Base64 b64;
   10953           0 :                 b64.decode(xmlField, decodedString);
   10954             :                 
   10955           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   10956           0 :                 iss.str(decodedString);
   10957             :                 
   10958           0 :                 attribute.clear();
   10959             :                 
   10960           0 :                 unsigned int ndim = 0;
   10961             :                 //iss.read((char *)&ndim, sizeof(ndim));
   10962           0 :                 TRYREAD(iss,ndim);
   10963             :                 
   10964           0 :                 if (ndim != 2) {
   10965           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   10966             :                 }
   10967             :         
   10968           0 :                 unsigned int dim1 = 0;
   10969             :                 //iss.read((char *)&dim1, sizeof(dim1));
   10970           0 :                 TRYREAD(iss,dim1);
   10971             :                 
   10972           0 :                 unsigned int dim2 = 0;
   10973             :                 //iss.read((char *)&dim2, sizeof(dim2));
   10974           0 :                 TRYREAD(iss,dim2);
   10975             :                 
   10976           0 :                 attribute.reserve(dim1);
   10977             :                 
   10978             :                 Char_CPP v;
   10979           0 :                 vector<unsigned char> aux2;
   10980           0 :                 aux2.reserve(dim2);
   10981           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   10982           0 :                         aux2.clear();
   10983           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   10984             :                                 //iss.read((char*) &v, sizeof(v));
   10985           0 :                                 TRYREAD(iss,v);
   10986             :                 
   10987           0 :                                 aux2.push_back(v);
   10988             :                 
   10989             :                         }
   10990           0 :                         attribute.push_back(aux2);      
   10991             :                 }
   10992           0 :                 return attribute;
   10993           0 :         }
   10994             :                 
   10995             :         
   10996           0 :         vector <vector <vector<unsigned char> > >& Parser::get3DCharacterFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<unsigned char> > >& attribute)
   10997             :         {
   10998           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   10999           0 :                 if (xmlField.length() == 0) {
   11000           0 :                         throw ConversionException("Error: Field \"" + 
   11001           0 :                                         name + "\": Invalid XML syntax", tableName);
   11002             :                 }
   11003             :                 
   11004           0 :                 string decodedString;
   11005           0 :                 Base64 b64;
   11006           0 :                 b64.decode(xmlField, decodedString);
   11007             :                 
   11008           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11009           0 :                 iss.str(decodedString);
   11010             :                 
   11011           0 :                 attribute.clear();
   11012             :                 
   11013           0 :                 unsigned int ndim = 0;
   11014             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11015           0 :                 TRYREAD(iss, ndim);     
   11016           0 :                 if (ndim != 3) {
   11017           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   11018             :                 }
   11019             :                                 
   11020           0 :                 unsigned int dim1 = 0;
   11021             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11022           0 :                 TRYREAD(iss,dim1);
   11023             :                 
   11024           0 :                 unsigned int dim2 = 0;
   11025             :                 //iss.read((char *)&dim2, sizeof(dim2));
   11026           0 :                 TRYREAD(iss,dim2);
   11027             :                 
   11028           0 :                 unsigned int dim3 = 0;
   11029             :                 //iss.read((char *)&dim2, sizeof(dim3));
   11030           0 :                 TRYREAD(iss,dim3);
   11031             :                 
   11032           0 :                 attribute.reserve(dim1);
   11033             :                 
   11034             :                 Char_CPP v;
   11035           0 :                 vector <vector<unsigned char> > aux2;
   11036           0 :                 vector<unsigned char> aux3;               
   11037           0 :                 aux2.reserve(dim2);
   11038           0 :                 aux3.reserve(dim3);
   11039             :                 
   11040           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11041           0 :                         aux2.clear();
   11042           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   11043           0 :                                 aux3.clear();
   11044           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   11045             :                                         //iss.read((char*) &v, sizeof(v));
   11046           0 :                                         TRYREAD(iss,v);
   11047             :                 
   11048           0 :                                         aux3.push_back(v);
   11049             :                 
   11050             :                                 }
   11051           0 :                                 aux2.push_back(aux3);
   11052             :                         }
   11053           0 :                         attribute.push_back(aux2);      
   11054             :                 }
   11055           0 :                 return attribute;
   11056             :                 ;
   11057           0 :         }
   11058             :         
   11059             :         
   11060           0 :         vector <vector <vector <vector<unsigned char> > > >& Parser::get4DCharacterFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<unsigned char> > > >& attribute)
   11061             :         {
   11062           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   11063           0 :                 if (xmlField.length() == 0) {
   11064           0 :                         throw ConversionException("Error: Field \"" + 
   11065           0 :                                         name + "\": Invalid XML syntax", tableName);
   11066             :                 }
   11067             :                 
   11068           0 :                 string decodedString;
   11069           0 :                 Base64 b64;
   11070           0 :                 b64.decode(xmlField, decodedString);
   11071             :                 
   11072           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11073           0 :                 iss.str(decodedString);
   11074             :                 
   11075           0 :                 attribute.clear();
   11076             :                 
   11077           0 :                 unsigned int ndim = 0;
   11078             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11079           0 :                 TRYREAD(iss, ndim);     
   11080           0 :                 if (ndim != 4) {
   11081           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   11082             :                 }
   11083             :                                 
   11084           0 :                 unsigned int dim1 = 0;
   11085             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11086           0 :                 TRYREAD(iss,dim1);
   11087             :                 
   11088           0 :                 unsigned int dim2 = 0;
   11089             :                 //iss.read((char *)&dim2, sizeof(dim2));
   11090           0 :                 TRYREAD(iss,dim2);
   11091             :                 
   11092           0 :                 unsigned int dim3 = 0;
   11093             :                 //iss.read((char *)&dim2, sizeof(dim3));
   11094           0 :                 TRYREAD(iss,dim3);
   11095             :                 
   11096           0 :                 unsigned int dim4 = 0;
   11097             :                 //iss.read((char *)&dim2, sizeof(dim3));
   11098           0 :                 TRYREAD(iss,dim3);
   11099             :                 
   11100           0 :                 attribute.reserve(dim1);
   11101             :                 
   11102             :                 Char_CPP v;
   11103           0 :                 vector <vector <vector<unsigned char> > > aux2;
   11104           0 :                 vector <vector<unsigned char> > aux3;
   11105           0 :                 vector<unsigned char> aux4;               
   11106           0 :                 aux2.reserve(dim2);
   11107           0 :                 aux3.reserve(dim3);
   11108           0 :                 aux4.reserve(dim4);
   11109             :                 
   11110           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11111           0 :                         aux2.clear();
   11112           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   11113           0 :                                 aux3.clear();
   11114           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   11115           0 :                                         aux4.clear();
   11116           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   11117             :                                         //iss.read((char*) &v, sizeof(v));
   11118           0 :                                                 TRYREAD(iss,v);
   11119             :                 
   11120           0 :                                                 aux4.push_back(v);
   11121             :                 
   11122             :                                         }
   11123           0 :                                         aux3.push_back(aux4);
   11124             :                                 }
   11125           0 :                                 aux2.push_back(aux3);
   11126             :                         }
   11127           0 :                         attribute.push_back(aux2);      
   11128             :                 }
   11129           0 :                 return attribute;
   11130             :                 ;
   11131           0 :         }
   11132             :         
   11133             :         
   11134             : 
   11135             :         
   11136             :         
   11137             :         
   11138             :         
   11139           0 :         void Parser::toXMLBase64(vector<bool> data, const string &name, string &buf){
   11140           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11141           0 :                 string encoded;
   11142             :                 
   11143           0 :                 buf.append("<" + name + "> ");
   11144           0 :                 int ndim = 1;
   11145           0 :                 int dim1 = data.size();
   11146             :  
   11147           0 :                 oss.write((char *)&ndim, sizeof(int));
   11148           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11149             : 
   11150           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   11151             :                 
   11152           0 :                 bool v = data.at(i);
   11153             :                 
   11154           0 :                 oss.write((char *) &v, sizeof(v));
   11155             :         }
   11156             : 
   11157           0 :                 Base64 b64;
   11158           0 :             b64.encode(oss.str(), encoded, false);
   11159           0 :             buf.append(encoded);
   11160           0 :                 buf.append(" </" + name + "> ");      
   11161           0 :         }
   11162             :         
   11163             :         
   11164           0 :         void Parser::toXMLBase64(vector< vector<bool> > data, const string &name, string &buf){
   11165           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11166           0 :                 string encoded;
   11167             :                 
   11168           0 :                 buf.append("<" + name + "> ");
   11169           0 :                 int ndim = 2;
   11170           0 :                 int dim1 = data.size();
   11171           0 :                 int dim2 = data.at(0).size();
   11172             : 
   11173           0 :                 oss.write((char *)&ndim, sizeof(int));
   11174           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11175           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   11176           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   11177           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   11178             :                 
   11179           0 :                         bool v = data.at(i).at(j);
   11180             :                 
   11181           0 :                         oss.write((char *) &v, sizeof(v));
   11182             :                 }
   11183             : 
   11184           0 :                 Base64 b64;
   11185           0 :             b64.encode(oss.str(), encoded, false);
   11186           0 :             buf.append(encoded);
   11187           0 :                 buf.append(" </" + name + "> ")
   11188             :                 ;
   11189           0 :         }
   11190             :         
   11191             :         
   11192           0 :         void Parser::toXMLBase64(vector< vector< vector<bool> > > data, const string &name, string &buf){
   11193           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11194           0 :                 string encoded;
   11195             :                 
   11196           0 :                 buf.append("<" + name + "> ");
   11197           0 :                 int ndim = 3;
   11198           0 :                 int dim1 = data.size();
   11199           0 :                 int dim2 = data.at(0).size();
   11200           0 :                 int dim3 = data.at(0).at(0).size();
   11201             : 
   11202           0 :                 oss.write((char *)&ndim, sizeof(int));
   11203           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11204           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   11205           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   11206           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   11207           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   11208           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   11209             :                 
   11210           0 :                                 bool v = data.at(i).at(j).at(k);
   11211             :                 
   11212           0 :                                 oss.write((char *) &v, sizeof(v));
   11213             :                         }
   11214             : 
   11215           0 :                 Base64 b64;
   11216           0 :             b64.encode(oss.str(), encoded, false);
   11217           0 :             buf.append(encoded);
   11218           0 :                 buf.append(" </" + name + "> ")
   11219             :                 ;
   11220           0 :         }
   11221             :         
   11222             :         
   11223           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<bool> > > >data, const string &name, string &buf){
   11224           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11225           0 :                 string encoded;
   11226             :                 
   11227           0 :                 buf.append("<" + name + "> ");
   11228           0 :                 int ndim = 3;
   11229           0 :                 int dim1 = data.size();
   11230           0 :                 int dim2 = data.at(0).size();
   11231           0 :                 int dim3 = data.at(0).at(0).size();
   11232           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   11233             :                 
   11234           0 :                 oss.write((char *)&ndim, sizeof(int));
   11235           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11236           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   11237           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   11238           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   11239           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   11240           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   11241           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   11242           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   11243             :                 
   11244           0 :                                         bool v = data.at(i).at(j).at(k).at(l);
   11245             :                 
   11246           0 :                                 oss.write((char *) &v, sizeof(v));
   11247             :                                 }
   11248             : 
   11249           0 :                 Base64 b64;
   11250           0 :             b64.encode(oss.str(), encoded, false);
   11251           0 :             buf.append(encoded);
   11252           0 :                 buf.append(" </" + name + "> ")
   11253             :                 ;
   11254           0 :         }
   11255             :         
   11256             :         
   11257             : #ifndef Boolean_CPP
   11258             :                 
   11259             : #define Boolean_CPP bool
   11260             :                 
   11261             : #endif
   11262             :         
   11263             : 
   11264             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   11265             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   11266             :                 
   11267             :     
   11268           0 :         vector<bool>& Parser::get1DBooleanFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<bool>& attribute)
   11269             :         {
   11270           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   11271           0 :                 if (xmlField.length() == 0) {
   11272           0 :                         throw ConversionException("Error: Field \"" + 
   11273           0 :                                         name + "\": Invalid XML syntax", tableName);
   11274             :                 }
   11275             :                 
   11276           0 :                 string decodedString;
   11277           0 :                 Base64 b64;
   11278           0 :                 b64.decode(xmlField, decodedString);
   11279             :                 
   11280           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11281           0 :                 iss.str(decodedString);
   11282             :                 
   11283           0 :                 attribute.clear();
   11284             :                 
   11285           0 :                 unsigned int ndim = 0;
   11286             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11287           0 :                 TRYREAD(iss,ndim);
   11288             :                 
   11289           0 :                 unsigned int dim1 = 0;
   11290             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11291           0 :                 TRYREAD(iss,dim1);
   11292           0 :                 if (ndim != 1) {
   11293           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   11294             :                         }
   11295             :                 
   11296           0 :                 attribute.reserve(dim1);
   11297             :                 
   11298             :                 Boolean_CPP v;
   11299           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11300             :                         //iss.read((char*) &v, sizeof(v));
   11301           0 :                         TRYREAD(iss,v);
   11302             :                 
   11303           0 :                         attribute.push_back(v);
   11304             :                         
   11305             :                 }
   11306           0 :                 return attribute;
   11307           0 :         }
   11308             :         
   11309             :          
   11310           0 :         vector <vector<bool> >& Parser::get2DBooleanFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<bool> >& attribute)
   11311             :         {
   11312           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   11313           0 :                 if (xmlField.length() == 0) {
   11314           0 :                         throw ConversionException("Error: Field \"" + 
   11315           0 :                                         name + "\": Invalid XML syntax", tableName);
   11316             :                 }
   11317             :                 
   11318           0 :                 string decodedString;
   11319           0 :                 Base64 b64;
   11320           0 :                 b64.decode(xmlField, decodedString);
   11321             :                 
   11322           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11323           0 :                 iss.str(decodedString);
   11324             :                 
   11325           0 :                 attribute.clear();
   11326             :                 
   11327           0 :                 unsigned int ndim = 0;
   11328             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11329           0 :                 TRYREAD(iss,ndim);
   11330             :                 
   11331           0 :                 if (ndim != 2) {
   11332           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   11333             :                 }
   11334             :         
   11335           0 :                 unsigned int dim1 = 0;
   11336             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11337           0 :                 TRYREAD(iss,dim1);
   11338             :                 
   11339           0 :                 unsigned int dim2 = 0;
   11340             :                 //iss.read((char *)&dim2, sizeof(dim2));
   11341           0 :                 TRYREAD(iss,dim2);
   11342             :                 
   11343           0 :                 attribute.reserve(dim1);
   11344             :                 
   11345             :                 Boolean_CPP v;
   11346           0 :                 vector<bool> aux2;
   11347           0 :                 aux2.reserve(dim2);
   11348           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11349           0 :                         aux2.clear();
   11350           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   11351             :                                 //iss.read((char*) &v, sizeof(v));
   11352           0 :                                 TRYREAD(iss,v);
   11353             :                 
   11354           0 :                                 aux2.push_back(v);
   11355             :                 
   11356             :                         }
   11357           0 :                         attribute.push_back(aux2);      
   11358             :                 }
   11359           0 :                 return attribute;
   11360           0 :         }
   11361             :                 
   11362             :         
   11363           0 :         vector <vector <vector<bool> > >& Parser::get3DBooleanFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<bool> > >& attribute)
   11364             :         {
   11365           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   11366           0 :                 if (xmlField.length() == 0) {
   11367           0 :                         throw ConversionException("Error: Field \"" + 
   11368           0 :                                         name + "\": Invalid XML syntax", tableName);
   11369             :                 }
   11370             :                 
   11371           0 :                 string decodedString;
   11372           0 :                 Base64 b64;
   11373           0 :                 b64.decode(xmlField, decodedString);
   11374             :                 
   11375           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11376           0 :                 iss.str(decodedString);
   11377             :                 
   11378           0 :                 attribute.clear();
   11379             :                 
   11380           0 :                 unsigned int ndim = 0;
   11381             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11382           0 :                 TRYREAD(iss, ndim);     
   11383           0 :                 if (ndim != 3) {
   11384           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   11385             :                 }
   11386             :                                 
   11387           0 :                 unsigned int dim1 = 0;
   11388             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11389           0 :                 TRYREAD(iss,dim1);
   11390             :                 
   11391           0 :                 unsigned int dim2 = 0;
   11392             :                 //iss.read((char *)&dim2, sizeof(dim2));
   11393           0 :                 TRYREAD(iss,dim2);
   11394             :                 
   11395           0 :                 unsigned int dim3 = 0;
   11396             :                 //iss.read((char *)&dim2, sizeof(dim3));
   11397           0 :                 TRYREAD(iss,dim3);
   11398             :                 
   11399           0 :                 attribute.reserve(dim1);
   11400             :                 
   11401             :                 Boolean_CPP v;
   11402           0 :                 vector <vector<bool> > aux2;
   11403           0 :                 vector<bool> aux3;                
   11404           0 :                 aux2.reserve(dim2);
   11405           0 :                 aux3.reserve(dim3);
   11406             :                 
   11407           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11408           0 :                         aux2.clear();
   11409           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   11410           0 :                                 aux3.clear();
   11411           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   11412             :                                         //iss.read((char*) &v, sizeof(v));
   11413           0 :                                         TRYREAD(iss,v);
   11414             :                 
   11415           0 :                                         aux3.push_back(v);
   11416             :                 
   11417             :                                 }
   11418           0 :                                 aux2.push_back(aux3);
   11419             :                         }
   11420           0 :                         attribute.push_back(aux2);      
   11421             :                 }
   11422           0 :                 return attribute;
   11423             :                 ;
   11424           0 :         }
   11425             :         
   11426             :         
   11427           0 :         vector <vector <vector <vector<bool> > > >& Parser::get4DBooleanFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<bool> > > >& attribute)
   11428             :         {
   11429           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   11430           0 :                 if (xmlField.length() == 0) {
   11431           0 :                         throw ConversionException("Error: Field \"" + 
   11432           0 :                                         name + "\": Invalid XML syntax", tableName);
   11433             :                 }
   11434             :                 
   11435           0 :                 string decodedString;
   11436           0 :                 Base64 b64;
   11437           0 :                 b64.decode(xmlField, decodedString);
   11438             :                 
   11439           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11440           0 :                 iss.str(decodedString);
   11441             :                 
   11442           0 :                 attribute.clear();
   11443             :                 
   11444           0 :                 unsigned int ndim = 0;
   11445             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11446           0 :                 TRYREAD(iss, ndim);     
   11447           0 :                 if (ndim != 4) {
   11448           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   11449             :                 }
   11450             :                                 
   11451           0 :                 unsigned int dim1 = 0;
   11452             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11453           0 :                 TRYREAD(iss,dim1);
   11454             :                 
   11455           0 :                 unsigned int dim2 = 0;
   11456             :                 //iss.read((char *)&dim2, sizeof(dim2));
   11457           0 :                 TRYREAD(iss,dim2);
   11458             :                 
   11459           0 :                 unsigned int dim3 = 0;
   11460             :                 //iss.read((char *)&dim2, sizeof(dim3));
   11461           0 :                 TRYREAD(iss,dim3);
   11462             :                 
   11463           0 :                 unsigned int dim4 = 0;
   11464             :                 //iss.read((char *)&dim2, sizeof(dim3));
   11465           0 :                 TRYREAD(iss,dim3);
   11466             :                 
   11467           0 :                 attribute.reserve(dim1);
   11468             :                 
   11469             :                 Boolean_CPP v;
   11470           0 :                 vector <vector <vector<bool> > > aux2;
   11471           0 :                 vector <vector<bool> > aux3;
   11472           0 :                 vector<bool> aux4;                
   11473           0 :                 aux2.reserve(dim2);
   11474           0 :                 aux3.reserve(dim3);
   11475           0 :                 aux4.reserve(dim4);
   11476             :                 
   11477           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11478           0 :                         aux2.clear();
   11479           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   11480           0 :                                 aux3.clear();
   11481           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   11482           0 :                                         aux4.clear();
   11483           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   11484             :                                         //iss.read((char*) &v, sizeof(v));
   11485           0 :                                                 TRYREAD(iss,v);
   11486             :                 
   11487           0 :                                                 aux4.push_back(v);
   11488             :                 
   11489             :                                         }
   11490           0 :                                         aux3.push_back(aux4);
   11491             :                                 }
   11492           0 :                                 aux2.push_back(aux3);
   11493             :                         }
   11494           0 :                         attribute.push_back(aux2);      
   11495             :                 }
   11496           0 :                 return attribute;
   11497             :                 ;
   11498           0 :         }
   11499             :         
   11500             :         
   11501             : 
   11502             :         
   11503             :         
   11504             : 
   11505             :         
   11506             :         
   11507             :         
   11508             :         
   11509           0 :         void Parser::toXMLBase64(vector<Angle> data, const string &name, string &buf){
   11510           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11511           0 :                 string encoded;
   11512             :                 
   11513           0 :                 buf.append("<" + name + "> ");
   11514           0 :                 int ndim = 1;
   11515           0 :                 int dim1 = data.size();
   11516             :  
   11517           0 :                 oss.write((char *)&ndim, sizeof(int));
   11518           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11519             : 
   11520           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   11521             :                 
   11522           0 :                  double v = data.at(i).get();
   11523             :                 
   11524           0 :                 oss.write((char *) &v, sizeof(v));
   11525             :         }
   11526             : 
   11527           0 :                 Base64 b64;
   11528           0 :             b64.encode(oss.str(), encoded, false);
   11529           0 :             buf.append(encoded);
   11530           0 :                 buf.append(" </" + name + "> ");      
   11531           0 :         }
   11532             :         
   11533             :         
   11534           0 :         void Parser::toXMLBase64(vector< vector<Angle> > data, const string &name, string &buf){
   11535           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11536           0 :                 string encoded;
   11537             :                 
   11538           0 :                 buf.append("<" + name + "> ");
   11539           0 :                 int ndim = 2;
   11540           0 :                 int dim1 = data.size();
   11541           0 :                 int dim2 = data.at(0).size();
   11542             : 
   11543           0 :                 oss.write((char *)&ndim, sizeof(int));
   11544           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11545           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   11546           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   11547           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   11548             :                 
   11549           0 :                         double v = data.at(i).at(j).get();
   11550             :                 
   11551           0 :                         oss.write((char *) &v, sizeof(v));
   11552             :                 }
   11553             : 
   11554           0 :                 Base64 b64;
   11555           0 :             b64.encode(oss.str(), encoded, false);
   11556           0 :             buf.append(encoded);
   11557           0 :                 buf.append(" </" + name + "> ")
   11558             :                 ;
   11559           0 :         }
   11560             :         
   11561             :         
   11562           0 :         void Parser::toXMLBase64(vector< vector< vector<Angle> > > data, const string &name, string &buf){
   11563           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11564           0 :                 string encoded;
   11565             :                 
   11566           0 :                 buf.append("<" + name + "> ");
   11567           0 :                 int ndim = 3;
   11568           0 :                 int dim1 = data.size();
   11569           0 :                 int dim2 = data.at(0).size();
   11570           0 :                 int dim3 = data.at(0).at(0).size();
   11571             : 
   11572           0 :                 oss.write((char *)&ndim, sizeof(int));
   11573           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11574           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   11575           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   11576           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   11577           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   11578           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   11579             :                 
   11580           0 :                                 double v = data.at(i).at(j).at(k).get();
   11581             :                 
   11582           0 :                                 oss.write((char *) &v, sizeof(v));
   11583             :                         }
   11584             : 
   11585           0 :                 Base64 b64;
   11586           0 :             b64.encode(oss.str(), encoded, false);
   11587           0 :             buf.append(encoded);
   11588           0 :                 buf.append(" </" + name + "> ")
   11589             :                 ;
   11590           0 :         }
   11591             :         
   11592             :         
   11593           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<Angle> > > >data, const string &name, string &buf){
   11594           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11595           0 :                 string encoded;
   11596             :                 
   11597           0 :                 buf.append("<" + name + "> ");
   11598           0 :                 int ndim = 3;
   11599           0 :                 int dim1 = data.size();
   11600           0 :                 int dim2 = data.at(0).size();
   11601           0 :                 int dim3 = data.at(0).at(0).size();
   11602           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   11603             :                 
   11604           0 :                 oss.write((char *)&ndim, sizeof(int));
   11605           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11606           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   11607           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   11608           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   11609           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   11610           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   11611           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   11612           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   11613             :                 
   11614           0 :                                         double v = data.at(i).at(j).at(k).at(l).get();
   11615             :                 
   11616           0 :                                 oss.write((char *) &v, sizeof(v));
   11617             :                                 }
   11618             : 
   11619           0 :                 Base64 b64;
   11620           0 :             b64.encode(oss.str(), encoded, false);
   11621           0 :             buf.append(encoded);
   11622           0 :                 buf.append(" </" + name + "> ")
   11623             :                 ;
   11624           0 :         }
   11625             :         
   11626             :         
   11627             : #ifndef Double_CPP
   11628             :                 
   11629             : #define Double_CPP double       
   11630             :                 
   11631             : #endif
   11632             :         
   11633             : 
   11634             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   11635             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   11636             :                 
   11637             :     
   11638           0 :         vector<Angle>& Parser::get1DAngleFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<Angle>& attribute)
   11639             :         {
   11640           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   11641           0 :                 if (xmlField.length() == 0) {
   11642           0 :                         throw ConversionException("Error: Field \"" + 
   11643           0 :                                         name + "\": Invalid XML syntax", tableName);
   11644             :                 }
   11645             :                 
   11646           0 :                 string decodedString;
   11647           0 :                 Base64 b64;
   11648           0 :                 b64.decode(xmlField, decodedString);
   11649             :                 
   11650           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11651           0 :                 iss.str(decodedString);
   11652             :                 
   11653           0 :                 attribute.clear();
   11654             :                 
   11655           0 :                 unsigned int ndim = 0;
   11656             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11657           0 :                 TRYREAD(iss,ndim);
   11658             :                 
   11659           0 :                 unsigned int dim1 = 0;
   11660             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11661           0 :                 TRYREAD(iss,dim1);
   11662           0 :                 if (ndim != 1) {
   11663           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   11664             :                         }
   11665             :                 
   11666           0 :                 attribute.reserve(dim1);
   11667             :                 
   11668             :                 Double_CPP v;
   11669           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11670             :                         //iss.read((char*) &v, sizeof(v));
   11671           0 :                         TRYREAD(iss,v);
   11672             :                 
   11673           0 :                         attribute.push_back(Angle(v));
   11674             :                         
   11675             :                 }
   11676           0 :                 return attribute;
   11677           0 :         }
   11678             :         
   11679             :          
   11680           0 :         vector <vector<Angle> >& Parser::get2DAngleFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<Angle> >& attribute)
   11681             :         {
   11682           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   11683           0 :                 if (xmlField.length() == 0) {
   11684           0 :                         throw ConversionException("Error: Field \"" + 
   11685           0 :                                         name + "\": Invalid XML syntax", tableName);
   11686             :                 }
   11687             :                 
   11688           0 :                 string decodedString;
   11689           0 :                 Base64 b64;
   11690           0 :                 b64.decode(xmlField, decodedString);
   11691             :                 
   11692           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11693           0 :                 iss.str(decodedString);
   11694             :                 
   11695           0 :                 attribute.clear();
   11696             :                 
   11697           0 :                 unsigned int ndim = 0;
   11698             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11699           0 :                 TRYREAD(iss,ndim);
   11700             :                 
   11701           0 :                 if (ndim != 2) {
   11702           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   11703             :                 }
   11704             :         
   11705           0 :                 unsigned int dim1 = 0;
   11706             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11707           0 :                 TRYREAD(iss,dim1);
   11708             :                 
   11709           0 :                 unsigned int dim2 = 0;
   11710             :                 //iss.read((char *)&dim2, sizeof(dim2));
   11711           0 :                 TRYREAD(iss,dim2);
   11712             :                 
   11713           0 :                 attribute.reserve(dim1);
   11714             :                 
   11715             :                 Double_CPP v;
   11716           0 :                 vector<Angle> aux2;
   11717           0 :                 aux2.reserve(dim2);
   11718           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11719           0 :                         aux2.clear();
   11720           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   11721             :                                 //iss.read((char*) &v, sizeof(v));
   11722           0 :                                 TRYREAD(iss,v);
   11723             :                 
   11724           0 :                                 aux2.push_back(Angle(v));
   11725             :                 
   11726             :                         }
   11727           0 :                         attribute.push_back(aux2);      
   11728             :                 }
   11729           0 :                 return attribute;
   11730           0 :         }
   11731             :                 
   11732             :         
   11733           0 :         vector <vector <vector<Angle> > >& Parser::get3DAngleFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<Angle> > >& attribute)
   11734             :         {
   11735           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   11736           0 :                 if (xmlField.length() == 0) {
   11737           0 :                         throw ConversionException("Error: Field \"" + 
   11738           0 :                                         name + "\": Invalid XML syntax", tableName);
   11739             :                 }
   11740             :                 
   11741           0 :                 string decodedString;
   11742           0 :                 Base64 b64;
   11743           0 :                 b64.decode(xmlField, decodedString);
   11744             :                 
   11745           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11746           0 :                 iss.str(decodedString);
   11747             :                 
   11748           0 :                 attribute.clear();
   11749             :                 
   11750           0 :                 unsigned int ndim = 0;
   11751             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11752           0 :                 TRYREAD(iss, ndim);     
   11753           0 :                 if (ndim != 3) {
   11754           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   11755             :                 }
   11756             :                                 
   11757           0 :                 unsigned int dim1 = 0;
   11758             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11759           0 :                 TRYREAD(iss,dim1);
   11760             :                 
   11761           0 :                 unsigned int dim2 = 0;
   11762             :                 //iss.read((char *)&dim2, sizeof(dim2));
   11763           0 :                 TRYREAD(iss,dim2);
   11764             :                 
   11765           0 :                 unsigned int dim3 = 0;
   11766             :                 //iss.read((char *)&dim2, sizeof(dim3));
   11767           0 :                 TRYREAD(iss,dim3);
   11768             :                 
   11769           0 :                 attribute.reserve(dim1);
   11770             :                 
   11771             :                 Double_CPP v;
   11772           0 :                 vector <vector<Angle> > aux2;
   11773           0 :                 vector<Angle> aux3;               
   11774           0 :                 aux2.reserve(dim2);
   11775           0 :                 aux3.reserve(dim3);
   11776             :                 
   11777           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11778           0 :                         aux2.clear();
   11779           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   11780           0 :                                 aux3.clear();
   11781           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   11782             :                                         //iss.read((char*) &v, sizeof(v));
   11783           0 :                                         TRYREAD(iss,v);
   11784             :                 
   11785           0 :                                         aux3.push_back(Angle(v));
   11786             :                 
   11787             :                                 }
   11788           0 :                                 aux2.push_back(aux3);
   11789             :                         }
   11790           0 :                         attribute.push_back(aux2);      
   11791             :                 }
   11792           0 :                 return attribute;
   11793             :                 ;
   11794           0 :         }
   11795             :         
   11796             :         
   11797           0 :         vector <vector <vector <vector<Angle> > > >& Parser::get4DAngleFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<Angle> > > >& attribute)
   11798             :         {
   11799           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   11800           0 :                 if (xmlField.length() == 0) {
   11801           0 :                         throw ConversionException("Error: Field \"" + 
   11802           0 :                                         name + "\": Invalid XML syntax", tableName);
   11803             :                 }
   11804             :                 
   11805           0 :                 string decodedString;
   11806           0 :                 Base64 b64;
   11807           0 :                 b64.decode(xmlField, decodedString);
   11808             :                 
   11809           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   11810           0 :                 iss.str(decodedString);
   11811             :                 
   11812           0 :                 attribute.clear();
   11813             :                 
   11814           0 :                 unsigned int ndim = 0;
   11815             :                 //iss.read((char *)&ndim, sizeof(ndim));
   11816           0 :                 TRYREAD(iss, ndim);     
   11817           0 :                 if (ndim != 4) {
   11818           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   11819             :                 }
   11820             :                                 
   11821           0 :                 unsigned int dim1 = 0;
   11822             :                 //iss.read((char *)&dim1, sizeof(dim1));
   11823           0 :                 TRYREAD(iss,dim1);
   11824             :                 
   11825           0 :                 unsigned int dim2 = 0;
   11826             :                 //iss.read((char *)&dim2, sizeof(dim2));
   11827           0 :                 TRYREAD(iss,dim2);
   11828             :                 
   11829           0 :                 unsigned int dim3 = 0;
   11830             :                 //iss.read((char *)&dim2, sizeof(dim3));
   11831           0 :                 TRYREAD(iss,dim3);
   11832             :                 
   11833           0 :                 unsigned int dim4 = 0;
   11834             :                 //iss.read((char *)&dim2, sizeof(dim3));
   11835           0 :                 TRYREAD(iss,dim3);
   11836             :                 
   11837           0 :                 attribute.reserve(dim1);
   11838             :                 
   11839             :                 Double_CPP v;
   11840           0 :                 vector <vector <vector<Angle> > > aux2;
   11841           0 :                 vector <vector<Angle> > aux3;
   11842           0 :                 vector<Angle> aux4;               
   11843           0 :                 aux2.reserve(dim2);
   11844           0 :                 aux3.reserve(dim3);
   11845           0 :                 aux4.reserve(dim4);
   11846             :                 
   11847           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   11848           0 :                         aux2.clear();
   11849           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   11850           0 :                                 aux3.clear();
   11851           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   11852           0 :                                         aux4.clear();
   11853           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   11854             :                                         //iss.read((char*) &v, sizeof(v));
   11855           0 :                                                 TRYREAD(iss,v);
   11856             :                 
   11857           0 :                                                 aux4.push_back(Angle(v));
   11858             :                 
   11859             :                                         }
   11860           0 :                                         aux3.push_back(aux4);
   11861             :                                 }
   11862           0 :                                 aux2.push_back(aux3);
   11863             :                         }
   11864           0 :                         attribute.push_back(aux2);      
   11865             :                 }
   11866           0 :                 return attribute;
   11867             :                 ;
   11868           0 :         }
   11869             :         
   11870             :         
   11871             : 
   11872             :         
   11873             :         
   11874             :         
   11875             :         
   11876           0 :         void Parser::toXMLBase64(vector<AngularRate> data, const string &name, string &buf){
   11877           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11878           0 :                 string encoded;
   11879             :                 
   11880           0 :                 buf.append("<" + name + "> ");
   11881           0 :                 int ndim = 1;
   11882           0 :                 int dim1 = data.size();
   11883             :  
   11884           0 :                 oss.write((char *)&ndim, sizeof(int));
   11885           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11886             : 
   11887           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   11888             :                 
   11889           0 :                  double v = data.at(i).get();
   11890             :                 
   11891           0 :                 oss.write((char *) &v, sizeof(v));
   11892             :         }
   11893             : 
   11894           0 :                 Base64 b64;
   11895           0 :             b64.encode(oss.str(), encoded, false);
   11896           0 :             buf.append(encoded);
   11897           0 :                 buf.append(" </" + name + "> ");      
   11898           0 :         }
   11899             :         
   11900             :         
   11901           0 :         void Parser::toXMLBase64(vector< vector<AngularRate> > data, const string &name, string &buf){
   11902           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11903           0 :                 string encoded;
   11904             :                 
   11905           0 :                 buf.append("<" + name + "> ");
   11906           0 :                 int ndim = 2;
   11907           0 :                 int dim1 = data.size();
   11908           0 :                 int dim2 = data.at(0).size();
   11909             : 
   11910           0 :                 oss.write((char *)&ndim, sizeof(int));
   11911           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11912           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   11913           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   11914           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   11915             :                 
   11916           0 :                         double v = data.at(i).at(j).get();
   11917             :                 
   11918           0 :                         oss.write((char *) &v, sizeof(v));
   11919             :                 }
   11920             : 
   11921           0 :                 Base64 b64;
   11922           0 :             b64.encode(oss.str(), encoded, false);
   11923           0 :             buf.append(encoded);
   11924           0 :                 buf.append(" </" + name + "> ")
   11925             :                 ;
   11926           0 :         }
   11927             :         
   11928             :         
   11929           0 :         void Parser::toXMLBase64(vector< vector< vector<AngularRate> > > data, const string &name, string &buf){
   11930           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11931           0 :                 string encoded;
   11932             :                 
   11933           0 :                 buf.append("<" + name + "> ");
   11934           0 :                 int ndim = 3;
   11935           0 :                 int dim1 = data.size();
   11936           0 :                 int dim2 = data.at(0).size();
   11937           0 :                 int dim3 = data.at(0).at(0).size();
   11938             : 
   11939           0 :                 oss.write((char *)&ndim, sizeof(int));
   11940           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11941           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   11942           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   11943           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   11944           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   11945           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   11946             :                 
   11947           0 :                                 double v = data.at(i).at(j).at(k).get();
   11948             :                 
   11949           0 :                                 oss.write((char *) &v, sizeof(v));
   11950             :                         }
   11951             : 
   11952           0 :                 Base64 b64;
   11953           0 :             b64.encode(oss.str(), encoded, false);
   11954           0 :             buf.append(encoded);
   11955           0 :                 buf.append(" </" + name + "> ")
   11956             :                 ;
   11957           0 :         }
   11958             :         
   11959             :         
   11960           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<AngularRate> > > >data, const string &name, string &buf){
   11961           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   11962           0 :                 string encoded;
   11963             :                 
   11964           0 :                 buf.append("<" + name + "> ");
   11965           0 :                 int ndim = 3;
   11966           0 :                 int dim1 = data.size();
   11967           0 :                 int dim2 = data.at(0).size();
   11968           0 :                 int dim3 = data.at(0).at(0).size();
   11969           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   11970             :                 
   11971           0 :                 oss.write((char *)&ndim, sizeof(int));
   11972           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   11973           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   11974           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   11975           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   11976           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   11977           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   11978           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   11979           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   11980             :                 
   11981           0 :                                         double v = data.at(i).at(j).at(k).at(l).get();
   11982             :                 
   11983           0 :                                 oss.write((char *) &v, sizeof(v));
   11984             :                                 }
   11985             : 
   11986           0 :                 Base64 b64;
   11987           0 :             b64.encode(oss.str(), encoded, false);
   11988           0 :             buf.append(encoded);
   11989           0 :                 buf.append(" </" + name + "> ")
   11990             :                 ;
   11991           0 :         }
   11992             :         
   11993             :         
   11994             : #ifndef Double_CPP
   11995             :                 
   11996             : #define Double_CPP double       
   11997             :                 
   11998             : #endif
   11999             :         
   12000             : 
   12001             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   12002             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   12003             :                 
   12004             :     
   12005           0 :         vector<AngularRate>& Parser::get1DAngularRateFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<AngularRate>& attribute)
   12006             :         {
   12007           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12008           0 :                 if (xmlField.length() == 0) {
   12009           0 :                         throw ConversionException("Error: Field \"" + 
   12010           0 :                                         name + "\": Invalid XML syntax", tableName);
   12011             :                 }
   12012             :                 
   12013           0 :                 string decodedString;
   12014           0 :                 Base64 b64;
   12015           0 :                 b64.decode(xmlField, decodedString);
   12016             :                 
   12017           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12018           0 :                 iss.str(decodedString);
   12019             :                 
   12020           0 :                 attribute.clear();
   12021             :                 
   12022           0 :                 unsigned int ndim = 0;
   12023             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12024           0 :                 TRYREAD(iss,ndim);
   12025             :                 
   12026           0 :                 unsigned int dim1 = 0;
   12027             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12028           0 :                 TRYREAD(iss,dim1);
   12029           0 :                 if (ndim != 1) {
   12030           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   12031             :                         }
   12032             :                 
   12033           0 :                 attribute.reserve(dim1);
   12034             :                 
   12035             :                 Double_CPP v;
   12036           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12037             :                         //iss.read((char*) &v, sizeof(v));
   12038           0 :                         TRYREAD(iss,v);
   12039             :                 
   12040           0 :                         attribute.push_back(AngularRate(v));
   12041             :                         
   12042             :                 }
   12043           0 :                 return attribute;
   12044           0 :         }
   12045             :         
   12046             :          
   12047           0 :         vector <vector<AngularRate> >& Parser::get2DAngularRateFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<AngularRate> >& attribute)
   12048             :         {
   12049           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12050           0 :                 if (xmlField.length() == 0) {
   12051           0 :                         throw ConversionException("Error: Field \"" + 
   12052           0 :                                         name + "\": Invalid XML syntax", tableName);
   12053             :                 }
   12054             :                 
   12055           0 :                 string decodedString;
   12056           0 :                 Base64 b64;
   12057           0 :                 b64.decode(xmlField, decodedString);
   12058             :                 
   12059           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12060           0 :                 iss.str(decodedString);
   12061             :                 
   12062           0 :                 attribute.clear();
   12063             :                 
   12064           0 :                 unsigned int ndim = 0;
   12065             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12066           0 :                 TRYREAD(iss,ndim);
   12067             :                 
   12068           0 :                 if (ndim != 2) {
   12069           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   12070             :                 }
   12071             :         
   12072           0 :                 unsigned int dim1 = 0;
   12073             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12074           0 :                 TRYREAD(iss,dim1);
   12075             :                 
   12076           0 :                 unsigned int dim2 = 0;
   12077             :                 //iss.read((char *)&dim2, sizeof(dim2));
   12078           0 :                 TRYREAD(iss,dim2);
   12079             :                 
   12080           0 :                 attribute.reserve(dim1);
   12081             :                 
   12082             :                 Double_CPP v;
   12083           0 :                 vector<AngularRate> aux2;
   12084           0 :                 aux2.reserve(dim2);
   12085           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12086           0 :                         aux2.clear();
   12087           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   12088             :                                 //iss.read((char*) &v, sizeof(v));
   12089           0 :                                 TRYREAD(iss,v);
   12090             :                 
   12091           0 :                                 aux2.push_back(AngularRate(v));
   12092             :                 
   12093             :                         }
   12094           0 :                         attribute.push_back(aux2);      
   12095             :                 }
   12096           0 :                 return attribute;
   12097           0 :         }
   12098             :                 
   12099             :         
   12100           0 :         vector <vector <vector<AngularRate> > >& Parser::get3DAngularRateFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<AngularRate> > >& attribute)
   12101             :         {
   12102           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12103           0 :                 if (xmlField.length() == 0) {
   12104           0 :                         throw ConversionException("Error: Field \"" + 
   12105           0 :                                         name + "\": Invalid XML syntax", tableName);
   12106             :                 }
   12107             :                 
   12108           0 :                 string decodedString;
   12109           0 :                 Base64 b64;
   12110           0 :                 b64.decode(xmlField, decodedString);
   12111             :                 
   12112           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12113           0 :                 iss.str(decodedString);
   12114             :                 
   12115           0 :                 attribute.clear();
   12116             :                 
   12117           0 :                 unsigned int ndim = 0;
   12118             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12119           0 :                 TRYREAD(iss, ndim);     
   12120           0 :                 if (ndim != 3) {
   12121           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   12122             :                 }
   12123             :                                 
   12124           0 :                 unsigned int dim1 = 0;
   12125             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12126           0 :                 TRYREAD(iss,dim1);
   12127             :                 
   12128           0 :                 unsigned int dim2 = 0;
   12129             :                 //iss.read((char *)&dim2, sizeof(dim2));
   12130           0 :                 TRYREAD(iss,dim2);
   12131             :                 
   12132           0 :                 unsigned int dim3 = 0;
   12133             :                 //iss.read((char *)&dim2, sizeof(dim3));
   12134           0 :                 TRYREAD(iss,dim3);
   12135             :                 
   12136           0 :                 attribute.reserve(dim1);
   12137             :                 
   12138             :                 Double_CPP v;
   12139           0 :                 vector <vector<AngularRate> > aux2;
   12140           0 :                 vector<AngularRate> aux3;         
   12141           0 :                 aux2.reserve(dim2);
   12142           0 :                 aux3.reserve(dim3);
   12143             :                 
   12144           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12145           0 :                         aux2.clear();
   12146           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   12147           0 :                                 aux3.clear();
   12148           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   12149             :                                         //iss.read((char*) &v, sizeof(v));
   12150           0 :                                         TRYREAD(iss,v);
   12151             :                 
   12152           0 :                                         aux3.push_back(AngularRate(v));
   12153             :                 
   12154             :                                 }
   12155           0 :                                 aux2.push_back(aux3);
   12156             :                         }
   12157           0 :                         attribute.push_back(aux2);      
   12158             :                 }
   12159           0 :                 return attribute;
   12160             :                 ;
   12161           0 :         }
   12162             :         
   12163             :         
   12164           0 :         vector <vector <vector <vector<AngularRate> > > >& Parser::get4DAngularRateFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<AngularRate> > > >& attribute)
   12165             :         {
   12166           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12167           0 :                 if (xmlField.length() == 0) {
   12168           0 :                         throw ConversionException("Error: Field \"" + 
   12169           0 :                                         name + "\": Invalid XML syntax", tableName);
   12170             :                 }
   12171             :                 
   12172           0 :                 string decodedString;
   12173           0 :                 Base64 b64;
   12174           0 :                 b64.decode(xmlField, decodedString);
   12175             :                 
   12176           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12177           0 :                 iss.str(decodedString);
   12178             :                 
   12179           0 :                 attribute.clear();
   12180             :                 
   12181           0 :                 unsigned int ndim = 0;
   12182             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12183           0 :                 TRYREAD(iss, ndim);     
   12184           0 :                 if (ndim != 4) {
   12185           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   12186             :                 }
   12187             :                                 
   12188           0 :                 unsigned int dim1 = 0;
   12189             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12190           0 :                 TRYREAD(iss,dim1);
   12191             :                 
   12192           0 :                 unsigned int dim2 = 0;
   12193             :                 //iss.read((char *)&dim2, sizeof(dim2));
   12194           0 :                 TRYREAD(iss,dim2);
   12195             :                 
   12196           0 :                 unsigned int dim3 = 0;
   12197             :                 //iss.read((char *)&dim2, sizeof(dim3));
   12198           0 :                 TRYREAD(iss,dim3);
   12199             :                 
   12200           0 :                 unsigned int dim4 = 0;
   12201             :                 //iss.read((char *)&dim2, sizeof(dim3));
   12202           0 :                 TRYREAD(iss,dim3);
   12203             :                 
   12204           0 :                 attribute.reserve(dim1);
   12205             :                 
   12206             :                 Double_CPP v;
   12207           0 :                 vector <vector <vector<AngularRate> > > aux2;
   12208           0 :                 vector <vector<AngularRate> > aux3;
   12209           0 :                 vector<AngularRate> aux4;         
   12210           0 :                 aux2.reserve(dim2);
   12211           0 :                 aux3.reserve(dim3);
   12212           0 :                 aux4.reserve(dim4);
   12213             :                 
   12214           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12215           0 :                         aux2.clear();
   12216           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   12217           0 :                                 aux3.clear();
   12218           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   12219           0 :                                         aux4.clear();
   12220           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   12221             :                                         //iss.read((char*) &v, sizeof(v));
   12222           0 :                                                 TRYREAD(iss,v);
   12223             :                 
   12224           0 :                                                 aux4.push_back(AngularRate(v));
   12225             :                 
   12226             :                                         }
   12227           0 :                                         aux3.push_back(aux4);
   12228             :                                 }
   12229           0 :                                 aux2.push_back(aux3);
   12230             :                         }
   12231           0 :                         attribute.push_back(aux2);      
   12232             :                 }
   12233           0 :                 return attribute;
   12234             :                 ;
   12235           0 :         }
   12236             :         
   12237             :         
   12238             : 
   12239             :         
   12240             :         
   12241             :         
   12242             :         
   12243           0 :         void Parser::toXMLBase64(vector<ArrayTime> data, const string &name, string &buf){
   12244           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   12245           0 :                 string encoded;
   12246             :                 
   12247           0 :                 buf.append("<" + name + "> ");
   12248           0 :                 int ndim = 1;
   12249           0 :                 int dim1 = data.size();
   12250             :  
   12251           0 :                 oss.write((char *)&ndim, sizeof(int));
   12252           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   12253             : 
   12254           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   12255             :                 
   12256           0 :                  long v = data.at(i).get();
   12257             :                 
   12258           0 :                 oss.write((char *) &v, sizeof(v));
   12259             :         }
   12260             : 
   12261           0 :                 Base64 b64;
   12262           0 :             b64.encode(oss.str(), encoded, false);
   12263           0 :             buf.append(encoded);
   12264           0 :                 buf.append(" </" + name + "> ");      
   12265           0 :         }
   12266             :         
   12267             :         
   12268           0 :         void Parser::toXMLBase64(vector< vector<ArrayTime> > data, const string &name, string &buf){
   12269           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   12270           0 :                 string encoded;
   12271             :                 
   12272           0 :                 buf.append("<" + name + "> ");
   12273           0 :                 int ndim = 2;
   12274           0 :                 int dim1 = data.size();
   12275           0 :                 int dim2 = data.at(0).size();
   12276             : 
   12277           0 :                 oss.write((char *)&ndim, sizeof(int));
   12278           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   12279           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   12280           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   12281           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   12282             :                 
   12283           0 :                         long v = data.at(i).at(j).get();
   12284             :                 
   12285           0 :                         oss.write((char *) &v, sizeof(v));
   12286             :                 }
   12287             : 
   12288           0 :                 Base64 b64;
   12289           0 :             b64.encode(oss.str(), encoded, false);
   12290           0 :             buf.append(encoded);
   12291           0 :                 buf.append(" </" + name + "> ")
   12292             :                 ;
   12293           0 :         }
   12294             :         
   12295             :         
   12296           0 :         void Parser::toXMLBase64(vector< vector< vector<ArrayTime> > > data, const string &name, string &buf){
   12297           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   12298           0 :                 string encoded;
   12299             :                 
   12300           0 :                 buf.append("<" + name + "> ");
   12301           0 :                 int ndim = 3;
   12302           0 :                 int dim1 = data.size();
   12303           0 :                 int dim2 = data.at(0).size();
   12304           0 :                 int dim3 = data.at(0).at(0).size();
   12305             : 
   12306           0 :                 oss.write((char *)&ndim, sizeof(int));
   12307           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   12308           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   12309           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   12310           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   12311           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   12312           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   12313             :                 
   12314           0 :                                 long v = data.at(i).at(j).at(k).get();
   12315             :                 
   12316           0 :                                 oss.write((char *) &v, sizeof(v));
   12317             :                         }
   12318             : 
   12319           0 :                 Base64 b64;
   12320           0 :             b64.encode(oss.str(), encoded, false);
   12321           0 :             buf.append(encoded);
   12322           0 :                 buf.append(" </" + name + "> ")
   12323             :                 ;
   12324           0 :         }
   12325             :         
   12326             :         
   12327           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<ArrayTime> > > >data, const string &name, string &buf){
   12328           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   12329           0 :                 string encoded;
   12330             :                 
   12331           0 :                 buf.append("<" + name + "> ");
   12332           0 :                 int ndim = 3;
   12333           0 :                 int dim1 = data.size();
   12334           0 :                 int dim2 = data.at(0).size();
   12335           0 :                 int dim3 = data.at(0).at(0).size();
   12336           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   12337             :                 
   12338           0 :                 oss.write((char *)&ndim, sizeof(int));
   12339           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   12340           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   12341           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   12342           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   12343           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   12344           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   12345           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   12346           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   12347             :                 
   12348           0 :                                         long v = data.at(i).at(j).at(k).at(l).get();
   12349             :                 
   12350           0 :                                 oss.write((char *) &v, sizeof(v));
   12351             :                                 }
   12352             : 
   12353           0 :                 Base64 b64;
   12354           0 :             b64.encode(oss.str(), encoded, false);
   12355           0 :             buf.append(encoded);
   12356           0 :                 buf.append(" </" + name + "> ")
   12357             :                 ;
   12358           0 :         }
   12359             :         
   12360             :         
   12361             : #ifndef Long_CPP
   12362             :                 
   12363             : #define Long_CPP int64_t
   12364             :                 
   12365             : #endif
   12366             :         
   12367             : 
   12368             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   12369             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   12370             :                 
   12371             :     
   12372           0 :         vector<ArrayTime>& Parser::get1DArrayTimeFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<ArrayTime>& attribute)
   12373             :         {
   12374           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12375           0 :                 if (xmlField.length() == 0) {
   12376           0 :                         throw ConversionException("Error: Field \"" + 
   12377           0 :                                         name + "\": Invalid XML syntax", tableName);
   12378             :                 }
   12379             :                 
   12380           0 :                 string decodedString;
   12381           0 :                 Base64 b64;
   12382           0 :                 b64.decode(xmlField, decodedString);
   12383             :                 
   12384           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12385           0 :                 iss.str(decodedString);
   12386             :                 
   12387           0 :                 attribute.clear();
   12388             :                 
   12389           0 :                 unsigned int ndim = 0;
   12390             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12391           0 :                 TRYREAD(iss,ndim);
   12392             :                 
   12393           0 :                 unsigned int dim1 = 0;
   12394             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12395           0 :                 TRYREAD(iss,dim1);
   12396           0 :                 if (ndim != 1) {
   12397           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   12398             :                         }
   12399             :                 
   12400           0 :                 attribute.reserve(dim1);
   12401             :                 
   12402             :                 Long_CPP v;
   12403           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12404             :                         //iss.read((char*) &v, sizeof(v));
   12405           0 :                         TRYREAD(iss,v);
   12406             :                 
   12407           0 :                         attribute.push_back(ArrayTime(v));
   12408             :                         
   12409             :                 }
   12410           0 :                 return attribute;
   12411           0 :         }
   12412             :         
   12413             :          
   12414           0 :         vector <vector<ArrayTime> >& Parser::get2DArrayTimeFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<ArrayTime> >& attribute)
   12415             :         {
   12416           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12417           0 :                 if (xmlField.length() == 0) {
   12418           0 :                         throw ConversionException("Error: Field \"" + 
   12419           0 :                                         name + "\": Invalid XML syntax", tableName);
   12420             :                 }
   12421             :                 
   12422           0 :                 string decodedString;
   12423           0 :                 Base64 b64;
   12424           0 :                 b64.decode(xmlField, decodedString);
   12425             :                 
   12426           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12427           0 :                 iss.str(decodedString);
   12428             :                 
   12429           0 :                 attribute.clear();
   12430             :                 
   12431           0 :                 unsigned int ndim = 0;
   12432             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12433           0 :                 TRYREAD(iss,ndim);
   12434             :                 
   12435           0 :                 if (ndim != 2) {
   12436           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   12437             :                 }
   12438             :         
   12439           0 :                 unsigned int dim1 = 0;
   12440             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12441           0 :                 TRYREAD(iss,dim1);
   12442             :                 
   12443           0 :                 unsigned int dim2 = 0;
   12444             :                 //iss.read((char *)&dim2, sizeof(dim2));
   12445           0 :                 TRYREAD(iss,dim2);
   12446             :                 
   12447           0 :                 attribute.reserve(dim1);
   12448             :                 
   12449             :                 Long_CPP v;
   12450           0 :                 vector<ArrayTime> aux2;
   12451           0 :                 aux2.reserve(dim2);
   12452           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12453           0 :                         aux2.clear();
   12454           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   12455             :                                 //iss.read((char*) &v, sizeof(v));
   12456           0 :                                 TRYREAD(iss,v);
   12457             :                 
   12458           0 :                                 aux2.push_back(ArrayTime(v));
   12459             :                 
   12460             :                         }
   12461           0 :                         attribute.push_back(aux2);      
   12462             :                 }
   12463           0 :                 return attribute;
   12464           0 :         }
   12465             :                 
   12466             :         
   12467           0 :         vector <vector <vector<ArrayTime> > >& Parser::get3DArrayTimeFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<ArrayTime> > >& attribute)
   12468             :         {
   12469           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12470           0 :                 if (xmlField.length() == 0) {
   12471           0 :                         throw ConversionException("Error: Field \"" + 
   12472           0 :                                         name + "\": Invalid XML syntax", tableName);
   12473             :                 }
   12474             :                 
   12475           0 :                 string decodedString;
   12476           0 :                 Base64 b64;
   12477           0 :                 b64.decode(xmlField, decodedString);
   12478             :                 
   12479           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12480           0 :                 iss.str(decodedString);
   12481             :                 
   12482           0 :                 attribute.clear();
   12483             :                 
   12484           0 :                 unsigned int ndim = 0;
   12485             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12486           0 :                 TRYREAD(iss, ndim);     
   12487           0 :                 if (ndim != 3) {
   12488           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   12489             :                 }
   12490             :                                 
   12491           0 :                 unsigned int dim1 = 0;
   12492             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12493           0 :                 TRYREAD(iss,dim1);
   12494             :                 
   12495           0 :                 unsigned int dim2 = 0;
   12496             :                 //iss.read((char *)&dim2, sizeof(dim2));
   12497           0 :                 TRYREAD(iss,dim2);
   12498             :                 
   12499           0 :                 unsigned int dim3 = 0;
   12500             :                 //iss.read((char *)&dim2, sizeof(dim3));
   12501           0 :                 TRYREAD(iss,dim3);
   12502             :                 
   12503           0 :                 attribute.reserve(dim1);
   12504             :                 
   12505             :                 Long_CPP v;
   12506           0 :                 vector <vector<ArrayTime> > aux2;
   12507           0 :                 vector<ArrayTime> aux3;           
   12508           0 :                 aux2.reserve(dim2);
   12509           0 :                 aux3.reserve(dim3);
   12510             :                 
   12511           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12512           0 :                         aux2.clear();
   12513           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   12514           0 :                                 aux3.clear();
   12515           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   12516             :                                         //iss.read((char*) &v, sizeof(v));
   12517           0 :                                         TRYREAD(iss,v);
   12518             :                 
   12519           0 :                                         aux3.push_back(ArrayTime(v));
   12520             :                 
   12521             :                                 }
   12522           0 :                                 aux2.push_back(aux3);
   12523             :                         }
   12524           0 :                         attribute.push_back(aux2);      
   12525             :                 }
   12526           0 :                 return attribute;
   12527             :                 ;
   12528           0 :         }
   12529             :         
   12530             :         
   12531           0 :         vector <vector <vector <vector<ArrayTime> > > >& Parser::get4DArrayTimeFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<ArrayTime> > > >& attribute)
   12532             :         {
   12533           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12534           0 :                 if (xmlField.length() == 0) {
   12535           0 :                         throw ConversionException("Error: Field \"" + 
   12536           0 :                                         name + "\": Invalid XML syntax", tableName);
   12537             :                 }
   12538             :                 
   12539           0 :                 string decodedString;
   12540           0 :                 Base64 b64;
   12541           0 :                 b64.decode(xmlField, decodedString);
   12542             :                 
   12543           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12544           0 :                 iss.str(decodedString);
   12545             :                 
   12546           0 :                 attribute.clear();
   12547             :                 
   12548           0 :                 unsigned int ndim = 0;
   12549             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12550           0 :                 TRYREAD(iss, ndim);     
   12551           0 :                 if (ndim != 4) {
   12552           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   12553             :                 }
   12554             :                                 
   12555           0 :                 unsigned int dim1 = 0;
   12556             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12557           0 :                 TRYREAD(iss,dim1);
   12558             :                 
   12559           0 :                 unsigned int dim2 = 0;
   12560             :                 //iss.read((char *)&dim2, sizeof(dim2));
   12561           0 :                 TRYREAD(iss,dim2);
   12562             :                 
   12563           0 :                 unsigned int dim3 = 0;
   12564             :                 //iss.read((char *)&dim2, sizeof(dim3));
   12565           0 :                 TRYREAD(iss,dim3);
   12566             :                 
   12567           0 :                 unsigned int dim4 = 0;
   12568             :                 //iss.read((char *)&dim2, sizeof(dim3));
   12569           0 :                 TRYREAD(iss,dim3);
   12570             :                 
   12571           0 :                 attribute.reserve(dim1);
   12572             :                 
   12573             :                 Long_CPP v;
   12574           0 :                 vector <vector <vector<ArrayTime> > > aux2;
   12575           0 :                 vector <vector<ArrayTime> > aux3;
   12576           0 :                 vector<ArrayTime> aux4;           
   12577           0 :                 aux2.reserve(dim2);
   12578           0 :                 aux3.reserve(dim3);
   12579           0 :                 aux4.reserve(dim4);
   12580             :                 
   12581           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12582           0 :                         aux2.clear();
   12583           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   12584           0 :                                 aux3.clear();
   12585           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   12586           0 :                                         aux4.clear();
   12587           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   12588             :                                         //iss.read((char*) &v, sizeof(v));
   12589           0 :                                                 TRYREAD(iss,v);
   12590             :                 
   12591           0 :                                                 aux4.push_back(ArrayTime(v));
   12592             :                 
   12593             :                                         }
   12594           0 :                                         aux3.push_back(aux4);
   12595             :                                 }
   12596           0 :                                 aux2.push_back(aux3);
   12597             :                         }
   12598           0 :                         attribute.push_back(aux2);      
   12599             :                 }
   12600           0 :                 return attribute;
   12601             :                 ;
   12602           0 :         }
   12603             :         
   12604             :         
   12605             : 
   12606             :         
   12607             :         
   12608             : 
   12609             :         
   12610             :         
   12611             : 
   12612             :         
   12613             :         
   12614             : 
   12615             :         
   12616             :         
   12617             : 
   12618             :         
   12619             :         
   12620             : 
   12621             :         
   12622             :         
   12623             :         
   12624             :         
   12625           0 :         void Parser::toXMLBase64(vector<Flux> data, const string &name, string &buf){
   12626           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   12627           0 :                 string encoded;
   12628             :                 
   12629           0 :                 buf.append("<" + name + "> ");
   12630           0 :                 int ndim = 1;
   12631           0 :                 int dim1 = data.size();
   12632             :  
   12633           0 :                 oss.write((char *)&ndim, sizeof(int));
   12634           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   12635             : 
   12636           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   12637             :                 
   12638           0 :                  double v = data.at(i).get();
   12639             :                 
   12640           0 :                 oss.write((char *) &v, sizeof(v));
   12641             :         }
   12642             : 
   12643           0 :                 Base64 b64;
   12644           0 :             b64.encode(oss.str(), encoded, false);
   12645           0 :             buf.append(encoded);
   12646           0 :                 buf.append(" </" + name + "> ");      
   12647           0 :         }
   12648             :         
   12649             :         
   12650           0 :         void Parser::toXMLBase64(vector< vector<Flux> > data, const string &name, string &buf){
   12651           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   12652           0 :                 string encoded;
   12653             :                 
   12654           0 :                 buf.append("<" + name + "> ");
   12655           0 :                 int ndim = 2;
   12656           0 :                 int dim1 = data.size();
   12657           0 :                 int dim2 = data.at(0).size();
   12658             : 
   12659           0 :                 oss.write((char *)&ndim, sizeof(int));
   12660           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   12661           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   12662           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   12663           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   12664             :                 
   12665           0 :                         double v = data.at(i).at(j).get();
   12666             :                 
   12667           0 :                         oss.write((char *) &v, sizeof(v));
   12668             :                 }
   12669             : 
   12670           0 :                 Base64 b64;
   12671           0 :             b64.encode(oss.str(), encoded, false);
   12672           0 :             buf.append(encoded);
   12673           0 :                 buf.append(" </" + name + "> ")
   12674             :                 ;
   12675           0 :         }
   12676             :         
   12677             :         
   12678           0 :         void Parser::toXMLBase64(vector< vector< vector<Flux> > > data, const string &name, string &buf){
   12679           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   12680           0 :                 string encoded;
   12681             :                 
   12682           0 :                 buf.append("<" + name + "> ");
   12683           0 :                 int ndim = 3;
   12684           0 :                 int dim1 = data.size();
   12685           0 :                 int dim2 = data.at(0).size();
   12686           0 :                 int dim3 = data.at(0).at(0).size();
   12687             : 
   12688           0 :                 oss.write((char *)&ndim, sizeof(int));
   12689           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   12690           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   12691           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   12692           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   12693           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   12694           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   12695             :                 
   12696           0 :                                 double v = data.at(i).at(j).at(k).get();
   12697             :                 
   12698           0 :                                 oss.write((char *) &v, sizeof(v));
   12699             :                         }
   12700             : 
   12701           0 :                 Base64 b64;
   12702           0 :             b64.encode(oss.str(), encoded, false);
   12703           0 :             buf.append(encoded);
   12704           0 :                 buf.append(" </" + name + "> ")
   12705             :                 ;
   12706           0 :         }
   12707             :         
   12708             :         
   12709           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<Flux> > > >data, const string &name, string &buf){
   12710           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   12711           0 :                 string encoded;
   12712             :                 
   12713           0 :                 buf.append("<" + name + "> ");
   12714           0 :                 int ndim = 3;
   12715           0 :                 int dim1 = data.size();
   12716           0 :                 int dim2 = data.at(0).size();
   12717           0 :                 int dim3 = data.at(0).at(0).size();
   12718           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   12719             :                 
   12720           0 :                 oss.write((char *)&ndim, sizeof(int));
   12721           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   12722           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   12723           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   12724           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   12725           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   12726           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   12727           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   12728           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   12729             :                 
   12730           0 :                                         double v = data.at(i).at(j).at(k).at(l).get();
   12731             :                 
   12732           0 :                                 oss.write((char *) &v, sizeof(v));
   12733             :                                 }
   12734             : 
   12735           0 :                 Base64 b64;
   12736           0 :             b64.encode(oss.str(), encoded, false);
   12737           0 :             buf.append(encoded);
   12738           0 :                 buf.append(" </" + name + "> ")
   12739             :                 ;
   12740           0 :         }
   12741             :         
   12742             :         
   12743             : #ifndef Double_CPP
   12744             :                 
   12745             : #define Double_CPP double       
   12746             :                 
   12747             : #endif
   12748             :         
   12749             : 
   12750             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   12751             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   12752             :                 
   12753             :     
   12754           0 :         vector<Flux>& Parser::get1DFluxFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<Flux>& attribute)
   12755             :         {
   12756           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12757           0 :                 if (xmlField.length() == 0) {
   12758           0 :                         throw ConversionException("Error: Field \"" + 
   12759           0 :                                         name + "\": Invalid XML syntax", tableName);
   12760             :                 }
   12761             :                 
   12762           0 :                 string decodedString;
   12763           0 :                 Base64 b64;
   12764           0 :                 b64.decode(xmlField, decodedString);
   12765             :                 
   12766           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12767           0 :                 iss.str(decodedString);
   12768             :                 
   12769           0 :                 attribute.clear();
   12770             :                 
   12771           0 :                 unsigned int ndim = 0;
   12772             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12773           0 :                 TRYREAD(iss,ndim);
   12774             :                 
   12775           0 :                 unsigned int dim1 = 0;
   12776             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12777           0 :                 TRYREAD(iss,dim1);
   12778           0 :                 if (ndim != 1) {
   12779           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   12780             :                         }
   12781             :                 
   12782           0 :                 attribute.reserve(dim1);
   12783             :                 
   12784             :                 Double_CPP v;
   12785           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12786             :                         //iss.read((char*) &v, sizeof(v));
   12787           0 :                         TRYREAD(iss,v);
   12788             :                 
   12789           0 :                         attribute.push_back(Flux(v));
   12790             :                         
   12791             :                 }
   12792           0 :                 return attribute;
   12793           0 :         }
   12794             :         
   12795             :          
   12796           0 :         vector <vector<Flux> >& Parser::get2DFluxFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<Flux> >& attribute)
   12797             :         {
   12798           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12799           0 :                 if (xmlField.length() == 0) {
   12800           0 :                         throw ConversionException("Error: Field \"" + 
   12801           0 :                                         name + "\": Invalid XML syntax", tableName);
   12802             :                 }
   12803             :                 
   12804           0 :                 string decodedString;
   12805           0 :                 Base64 b64;
   12806           0 :                 b64.decode(xmlField, decodedString);
   12807             :                 
   12808           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12809           0 :                 iss.str(decodedString);
   12810             :                 
   12811           0 :                 attribute.clear();
   12812             :                 
   12813           0 :                 unsigned int ndim = 0;
   12814             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12815           0 :                 TRYREAD(iss,ndim);
   12816             :                 
   12817           0 :                 if (ndim != 2) {
   12818           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   12819             :                 }
   12820             :         
   12821           0 :                 unsigned int dim1 = 0;
   12822             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12823           0 :                 TRYREAD(iss,dim1);
   12824             :                 
   12825           0 :                 unsigned int dim2 = 0;
   12826             :                 //iss.read((char *)&dim2, sizeof(dim2));
   12827           0 :                 TRYREAD(iss,dim2);
   12828             :                 
   12829           0 :                 attribute.reserve(dim1);
   12830             :                 
   12831             :                 Double_CPP v;
   12832           0 :                 vector<Flux> aux2;
   12833           0 :                 aux2.reserve(dim2);
   12834           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12835           0 :                         aux2.clear();
   12836           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   12837             :                                 //iss.read((char*) &v, sizeof(v));
   12838           0 :                                 TRYREAD(iss,v);
   12839             :                 
   12840           0 :                                 aux2.push_back(Flux(v));
   12841             :                 
   12842             :                         }
   12843           0 :                         attribute.push_back(aux2);      
   12844             :                 }
   12845           0 :                 return attribute;
   12846           0 :         }
   12847             :                 
   12848             :         
   12849           0 :         vector <vector <vector<Flux> > >& Parser::get3DFluxFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<Flux> > >& attribute)
   12850             :         {
   12851           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12852           0 :                 if (xmlField.length() == 0) {
   12853           0 :                         throw ConversionException("Error: Field \"" + 
   12854           0 :                                         name + "\": Invalid XML syntax", tableName);
   12855             :                 }
   12856             :                 
   12857           0 :                 string decodedString;
   12858           0 :                 Base64 b64;
   12859           0 :                 b64.decode(xmlField, decodedString);
   12860             :                 
   12861           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12862           0 :                 iss.str(decodedString);
   12863             :                 
   12864           0 :                 attribute.clear();
   12865             :                 
   12866           0 :                 unsigned int ndim = 0;
   12867             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12868           0 :                 TRYREAD(iss, ndim);     
   12869           0 :                 if (ndim != 3) {
   12870           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   12871             :                 }
   12872             :                                 
   12873           0 :                 unsigned int dim1 = 0;
   12874             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12875           0 :                 TRYREAD(iss,dim1);
   12876             :                 
   12877           0 :                 unsigned int dim2 = 0;
   12878             :                 //iss.read((char *)&dim2, sizeof(dim2));
   12879           0 :                 TRYREAD(iss,dim2);
   12880             :                 
   12881           0 :                 unsigned int dim3 = 0;
   12882             :                 //iss.read((char *)&dim2, sizeof(dim3));
   12883           0 :                 TRYREAD(iss,dim3);
   12884             :                 
   12885           0 :                 attribute.reserve(dim1);
   12886             :                 
   12887             :                 Double_CPP v;
   12888           0 :                 vector <vector<Flux> > aux2;
   12889           0 :                 vector<Flux> aux3;                
   12890           0 :                 aux2.reserve(dim2);
   12891           0 :                 aux3.reserve(dim3);
   12892             :                 
   12893           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12894           0 :                         aux2.clear();
   12895           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   12896           0 :                                 aux3.clear();
   12897           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   12898             :                                         //iss.read((char*) &v, sizeof(v));
   12899           0 :                                         TRYREAD(iss,v);
   12900             :                 
   12901           0 :                                         aux3.push_back(Flux(v));
   12902             :                 
   12903             :                                 }
   12904           0 :                                 aux2.push_back(aux3);
   12905             :                         }
   12906           0 :                         attribute.push_back(aux2);      
   12907             :                 }
   12908           0 :                 return attribute;
   12909             :                 ;
   12910           0 :         }
   12911             :         
   12912             :         
   12913           0 :         vector <vector <vector <vector<Flux> > > >& Parser::get4DFluxFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<Flux> > > >& attribute)
   12914             :         {
   12915           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   12916           0 :                 if (xmlField.length() == 0) {
   12917           0 :                         throw ConversionException("Error: Field \"" + 
   12918           0 :                                         name + "\": Invalid XML syntax", tableName);
   12919             :                 }
   12920             :                 
   12921           0 :                 string decodedString;
   12922           0 :                 Base64 b64;
   12923           0 :                 b64.decode(xmlField, decodedString);
   12924             :                 
   12925           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   12926           0 :                 iss.str(decodedString);
   12927             :                 
   12928           0 :                 attribute.clear();
   12929             :                 
   12930           0 :                 unsigned int ndim = 0;
   12931             :                 //iss.read((char *)&ndim, sizeof(ndim));
   12932           0 :                 TRYREAD(iss, ndim);     
   12933           0 :                 if (ndim != 4) {
   12934           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   12935             :                 }
   12936             :                                 
   12937           0 :                 unsigned int dim1 = 0;
   12938             :                 //iss.read((char *)&dim1, sizeof(dim1));
   12939           0 :                 TRYREAD(iss,dim1);
   12940             :                 
   12941           0 :                 unsigned int dim2 = 0;
   12942             :                 //iss.read((char *)&dim2, sizeof(dim2));
   12943           0 :                 TRYREAD(iss,dim2);
   12944             :                 
   12945           0 :                 unsigned int dim3 = 0;
   12946             :                 //iss.read((char *)&dim2, sizeof(dim3));
   12947           0 :                 TRYREAD(iss,dim3);
   12948             :                 
   12949           0 :                 unsigned int dim4 = 0;
   12950             :                 //iss.read((char *)&dim2, sizeof(dim3));
   12951           0 :                 TRYREAD(iss,dim3);
   12952             :                 
   12953           0 :                 attribute.reserve(dim1);
   12954             :                 
   12955             :                 Double_CPP v;
   12956           0 :                 vector <vector <vector<Flux> > > aux2;
   12957           0 :                 vector <vector<Flux> > aux3;
   12958           0 :                 vector<Flux> aux4;                
   12959           0 :                 aux2.reserve(dim2);
   12960           0 :                 aux3.reserve(dim3);
   12961           0 :                 aux4.reserve(dim4);
   12962             :                 
   12963           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   12964           0 :                         aux2.clear();
   12965           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   12966           0 :                                 aux3.clear();
   12967           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   12968           0 :                                         aux4.clear();
   12969           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   12970             :                                         //iss.read((char*) &v, sizeof(v));
   12971           0 :                                                 TRYREAD(iss,v);
   12972             :                 
   12973           0 :                                                 aux4.push_back(Flux(v));
   12974             :                 
   12975             :                                         }
   12976           0 :                                         aux3.push_back(aux4);
   12977             :                                 }
   12978           0 :                                 aux2.push_back(aux3);
   12979             :                         }
   12980           0 :                         attribute.push_back(aux2);      
   12981             :                 }
   12982           0 :                 return attribute;
   12983             :                 ;
   12984           0 :         }
   12985             :         
   12986             :         
   12987             : 
   12988             :         
   12989             :         
   12990             :         
   12991             :         
   12992           0 :         void Parser::toXMLBase64(vector<Frequency> data, const string &name, string &buf){
   12993           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   12994           0 :                 string encoded;
   12995             :                 
   12996           0 :                 buf.append("<" + name + "> ");
   12997           0 :                 int ndim = 1;
   12998           0 :                 int dim1 = data.size();
   12999             :  
   13000           0 :                 oss.write((char *)&ndim, sizeof(int));
   13001           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13002             : 
   13003           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   13004             :                 
   13005           0 :                  double v = data.at(i).get();
   13006             :                 
   13007           0 :                 oss.write((char *) &v, sizeof(v));
   13008             :         }
   13009             : 
   13010           0 :                 Base64 b64;
   13011           0 :             b64.encode(oss.str(), encoded, false);
   13012           0 :             buf.append(encoded);
   13013           0 :                 buf.append(" </" + name + "> ");      
   13014           0 :         }
   13015             :         
   13016             :         
   13017           0 :         void Parser::toXMLBase64(vector< vector<Frequency> > data, const string &name, string &buf){
   13018           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13019           0 :                 string encoded;
   13020             :                 
   13021           0 :                 buf.append("<" + name + "> ");
   13022           0 :                 int ndim = 2;
   13023           0 :                 int dim1 = data.size();
   13024           0 :                 int dim2 = data.at(0).size();
   13025             : 
   13026           0 :                 oss.write((char *)&ndim, sizeof(int));
   13027           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13028           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   13029           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   13030           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   13031             :                 
   13032           0 :                         double v = data.at(i).at(j).get();
   13033             :                 
   13034           0 :                         oss.write((char *) &v, sizeof(v));
   13035             :                 }
   13036             : 
   13037           0 :                 Base64 b64;
   13038           0 :             b64.encode(oss.str(), encoded, false);
   13039           0 :             buf.append(encoded);
   13040           0 :                 buf.append(" </" + name + "> ")
   13041             :                 ;
   13042           0 :         }
   13043             :         
   13044             :         
   13045           0 :         void Parser::toXMLBase64(vector< vector< vector<Frequency> > > data, const string &name, string &buf){
   13046           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13047           0 :                 string encoded;
   13048             :                 
   13049           0 :                 buf.append("<" + name + "> ");
   13050           0 :                 int ndim = 3;
   13051           0 :                 int dim1 = data.size();
   13052           0 :                 int dim2 = data.at(0).size();
   13053           0 :                 int dim3 = data.at(0).at(0).size();
   13054             : 
   13055           0 :                 oss.write((char *)&ndim, sizeof(int));
   13056           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13057           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   13058           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   13059           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   13060           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   13061           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   13062             :                 
   13063           0 :                                 double v = data.at(i).at(j).at(k).get();
   13064             :                 
   13065           0 :                                 oss.write((char *) &v, sizeof(v));
   13066             :                         }
   13067             : 
   13068           0 :                 Base64 b64;
   13069           0 :             b64.encode(oss.str(), encoded, false);
   13070           0 :             buf.append(encoded);
   13071           0 :                 buf.append(" </" + name + "> ")
   13072             :                 ;
   13073           0 :         }
   13074             :         
   13075             :         
   13076           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<Frequency> > > >data, const string &name, string &buf){
   13077           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13078           0 :                 string encoded;
   13079             :                 
   13080           0 :                 buf.append("<" + name + "> ");
   13081           0 :                 int ndim = 3;
   13082           0 :                 int dim1 = data.size();
   13083           0 :                 int dim2 = data.at(0).size();
   13084           0 :                 int dim3 = data.at(0).at(0).size();
   13085           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   13086             :                 
   13087           0 :                 oss.write((char *)&ndim, sizeof(int));
   13088           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13089           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   13090           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   13091           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   13092           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   13093           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   13094           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   13095           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   13096             :                 
   13097           0 :                                         double v = data.at(i).at(j).at(k).at(l).get();
   13098             :                 
   13099           0 :                                 oss.write((char *) &v, sizeof(v));
   13100             :                                 }
   13101             : 
   13102           0 :                 Base64 b64;
   13103           0 :             b64.encode(oss.str(), encoded, false);
   13104           0 :             buf.append(encoded);
   13105           0 :                 buf.append(" </" + name + "> ")
   13106             :                 ;
   13107           0 :         }
   13108             :         
   13109             :         
   13110             : #ifndef Double_CPP
   13111             :                 
   13112             : #define Double_CPP double       
   13113             :                 
   13114             : #endif
   13115             :         
   13116             : 
   13117             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   13118             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   13119             :                 
   13120             :     
   13121           0 :         vector<Frequency>& Parser::get1DFrequencyFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<Frequency>& attribute)
   13122             :         {
   13123           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13124           0 :                 if (xmlField.length() == 0) {
   13125           0 :                         throw ConversionException("Error: Field \"" + 
   13126           0 :                                         name + "\": Invalid XML syntax", tableName);
   13127             :                 }
   13128             :                 
   13129           0 :                 string decodedString;
   13130           0 :                 Base64 b64;
   13131           0 :                 b64.decode(xmlField, decodedString);
   13132             :                 
   13133           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13134           0 :                 iss.str(decodedString);
   13135             :                 
   13136           0 :                 attribute.clear();
   13137             :                 
   13138           0 :                 unsigned int ndim = 0;
   13139             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13140           0 :                 TRYREAD(iss,ndim);
   13141             :                 
   13142           0 :                 unsigned int dim1 = 0;
   13143             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13144           0 :                 TRYREAD(iss,dim1);
   13145           0 :                 if (ndim != 1) {
   13146           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   13147             :                         }
   13148             :                 
   13149           0 :                 attribute.reserve(dim1);
   13150             :                 
   13151             :                 Double_CPP v;
   13152           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13153             :                         //iss.read((char*) &v, sizeof(v));
   13154           0 :                         TRYREAD(iss,v);
   13155             :                 
   13156           0 :                         attribute.push_back(Frequency(v));
   13157             :                         
   13158             :                 }
   13159           0 :                 return attribute;
   13160           0 :         }
   13161             :         
   13162             :          
   13163           0 :         vector <vector<Frequency> >& Parser::get2DFrequencyFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<Frequency> >& attribute)
   13164             :         {
   13165           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13166           0 :                 if (xmlField.length() == 0) {
   13167           0 :                         throw ConversionException("Error: Field \"" + 
   13168           0 :                                         name + "\": Invalid XML syntax", tableName);
   13169             :                 }
   13170             :                 
   13171           0 :                 string decodedString;
   13172           0 :                 Base64 b64;
   13173           0 :                 b64.decode(xmlField, decodedString);
   13174             :                 
   13175           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13176           0 :                 iss.str(decodedString);
   13177             :                 
   13178           0 :                 attribute.clear();
   13179             :                 
   13180           0 :                 unsigned int ndim = 0;
   13181             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13182           0 :                 TRYREAD(iss,ndim);
   13183             :                 
   13184           0 :                 if (ndim != 2) {
   13185           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   13186             :                 }
   13187             :         
   13188           0 :                 unsigned int dim1 = 0;
   13189             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13190           0 :                 TRYREAD(iss,dim1);
   13191             :                 
   13192           0 :                 unsigned int dim2 = 0;
   13193             :                 //iss.read((char *)&dim2, sizeof(dim2));
   13194           0 :                 TRYREAD(iss,dim2);
   13195             :                 
   13196           0 :                 attribute.reserve(dim1);
   13197             :                 
   13198             :                 Double_CPP v;
   13199           0 :                 vector<Frequency> aux2;
   13200           0 :                 aux2.reserve(dim2);
   13201           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13202           0 :                         aux2.clear();
   13203           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   13204             :                                 //iss.read((char*) &v, sizeof(v));
   13205           0 :                                 TRYREAD(iss,v);
   13206             :                 
   13207           0 :                                 aux2.push_back(Frequency(v));
   13208             :                 
   13209             :                         }
   13210           0 :                         attribute.push_back(aux2);      
   13211             :                 }
   13212           0 :                 return attribute;
   13213           0 :         }
   13214             :                 
   13215             :         
   13216           0 :         vector <vector <vector<Frequency> > >& Parser::get3DFrequencyFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<Frequency> > >& attribute)
   13217             :         {
   13218           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13219           0 :                 if (xmlField.length() == 0) {
   13220           0 :                         throw ConversionException("Error: Field \"" + 
   13221           0 :                                         name + "\": Invalid XML syntax", tableName);
   13222             :                 }
   13223             :                 
   13224           0 :                 string decodedString;
   13225           0 :                 Base64 b64;
   13226           0 :                 b64.decode(xmlField, decodedString);
   13227             :                 
   13228           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13229           0 :                 iss.str(decodedString);
   13230             :                 
   13231           0 :                 attribute.clear();
   13232             :                 
   13233           0 :                 unsigned int ndim = 0;
   13234             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13235           0 :                 TRYREAD(iss, ndim);     
   13236           0 :                 if (ndim != 3) {
   13237           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   13238             :                 }
   13239             :                                 
   13240           0 :                 unsigned int dim1 = 0;
   13241             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13242           0 :                 TRYREAD(iss,dim1);
   13243             :                 
   13244           0 :                 unsigned int dim2 = 0;
   13245             :                 //iss.read((char *)&dim2, sizeof(dim2));
   13246           0 :                 TRYREAD(iss,dim2);
   13247             :                 
   13248           0 :                 unsigned int dim3 = 0;
   13249             :                 //iss.read((char *)&dim2, sizeof(dim3));
   13250           0 :                 TRYREAD(iss,dim3);
   13251             :                 
   13252           0 :                 attribute.reserve(dim1);
   13253             :                 
   13254             :                 Double_CPP v;
   13255           0 :                 vector <vector<Frequency> > aux2;
   13256           0 :                 vector<Frequency> aux3;           
   13257           0 :                 aux2.reserve(dim2);
   13258           0 :                 aux3.reserve(dim3);
   13259             :                 
   13260           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13261           0 :                         aux2.clear();
   13262           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   13263           0 :                                 aux3.clear();
   13264           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   13265             :                                         //iss.read((char*) &v, sizeof(v));
   13266           0 :                                         TRYREAD(iss,v);
   13267             :                 
   13268           0 :                                         aux3.push_back(Frequency(v));
   13269             :                 
   13270             :                                 }
   13271           0 :                                 aux2.push_back(aux3);
   13272             :                         }
   13273           0 :                         attribute.push_back(aux2);      
   13274             :                 }
   13275           0 :                 return attribute;
   13276             :                 ;
   13277           0 :         }
   13278             :         
   13279             :         
   13280           0 :         vector <vector <vector <vector<Frequency> > > >& Parser::get4DFrequencyFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<Frequency> > > >& attribute)
   13281             :         {
   13282           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13283           0 :                 if (xmlField.length() == 0) {
   13284           0 :                         throw ConversionException("Error: Field \"" + 
   13285           0 :                                         name + "\": Invalid XML syntax", tableName);
   13286             :                 }
   13287             :                 
   13288           0 :                 string decodedString;
   13289           0 :                 Base64 b64;
   13290           0 :                 b64.decode(xmlField, decodedString);
   13291             :                 
   13292           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13293           0 :                 iss.str(decodedString);
   13294             :                 
   13295           0 :                 attribute.clear();
   13296             :                 
   13297           0 :                 unsigned int ndim = 0;
   13298             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13299           0 :                 TRYREAD(iss, ndim);     
   13300           0 :                 if (ndim != 4) {
   13301           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   13302             :                 }
   13303             :                                 
   13304           0 :                 unsigned int dim1 = 0;
   13305             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13306           0 :                 TRYREAD(iss,dim1);
   13307             :                 
   13308           0 :                 unsigned int dim2 = 0;
   13309             :                 //iss.read((char *)&dim2, sizeof(dim2));
   13310           0 :                 TRYREAD(iss,dim2);
   13311             :                 
   13312           0 :                 unsigned int dim3 = 0;
   13313             :                 //iss.read((char *)&dim2, sizeof(dim3));
   13314           0 :                 TRYREAD(iss,dim3);
   13315             :                 
   13316           0 :                 unsigned int dim4 = 0;
   13317             :                 //iss.read((char *)&dim2, sizeof(dim3));
   13318           0 :                 TRYREAD(iss,dim3);
   13319             :                 
   13320           0 :                 attribute.reserve(dim1);
   13321             :                 
   13322             :                 Double_CPP v;
   13323           0 :                 vector <vector <vector<Frequency> > > aux2;
   13324           0 :                 vector <vector<Frequency> > aux3;
   13325           0 :                 vector<Frequency> aux4;           
   13326           0 :                 aux2.reserve(dim2);
   13327           0 :                 aux3.reserve(dim3);
   13328           0 :                 aux4.reserve(dim4);
   13329             :                 
   13330           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13331           0 :                         aux2.clear();
   13332           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   13333           0 :                                 aux3.clear();
   13334           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   13335           0 :                                         aux4.clear();
   13336           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   13337             :                                         //iss.read((char*) &v, sizeof(v));
   13338           0 :                                                 TRYREAD(iss,v);
   13339             :                 
   13340           0 :                                                 aux4.push_back(Frequency(v));
   13341             :                 
   13342             :                                         }
   13343           0 :                                         aux3.push_back(aux4);
   13344             :                                 }
   13345           0 :                                 aux2.push_back(aux3);
   13346             :                         }
   13347           0 :                         attribute.push_back(aux2);      
   13348             :                 }
   13349           0 :                 return attribute;
   13350             :                 ;
   13351           0 :         }
   13352             :         
   13353             :         
   13354             : 
   13355             :         
   13356             :         
   13357             :         
   13358             :         
   13359           0 :         void Parser::toXMLBase64(vector<Humidity> data, const string &name, string &buf){
   13360           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13361           0 :                 string encoded;
   13362             :                 
   13363           0 :                 buf.append("<" + name + "> ");
   13364           0 :                 int ndim = 1;
   13365           0 :                 int dim1 = data.size();
   13366             :  
   13367           0 :                 oss.write((char *)&ndim, sizeof(int));
   13368           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13369             : 
   13370           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   13371             :                 
   13372           0 :                  double v = data.at(i).get();
   13373             :                 
   13374           0 :                 oss.write((char *) &v, sizeof(v));
   13375             :         }
   13376             : 
   13377           0 :                 Base64 b64;
   13378           0 :             b64.encode(oss.str(), encoded, false);
   13379           0 :             buf.append(encoded);
   13380           0 :                 buf.append(" </" + name + "> ");      
   13381           0 :         }
   13382             :         
   13383             :         
   13384           0 :         void Parser::toXMLBase64(vector< vector<Humidity> > data, const string &name, string &buf){
   13385           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13386           0 :                 string encoded;
   13387             :                 
   13388           0 :                 buf.append("<" + name + "> ");
   13389           0 :                 int ndim = 2;
   13390           0 :                 int dim1 = data.size();
   13391           0 :                 int dim2 = data.at(0).size();
   13392             : 
   13393           0 :                 oss.write((char *)&ndim, sizeof(int));
   13394           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13395           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   13396           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   13397           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   13398             :                 
   13399           0 :                         double v = data.at(i).at(j).get();
   13400             :                 
   13401           0 :                         oss.write((char *) &v, sizeof(v));
   13402             :                 }
   13403             : 
   13404           0 :                 Base64 b64;
   13405           0 :             b64.encode(oss.str(), encoded, false);
   13406           0 :             buf.append(encoded);
   13407           0 :                 buf.append(" </" + name + "> ")
   13408             :                 ;
   13409           0 :         }
   13410             :         
   13411             :         
   13412           0 :         void Parser::toXMLBase64(vector< vector< vector<Humidity> > > data, const string &name, string &buf){
   13413           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13414           0 :                 string encoded;
   13415             :                 
   13416           0 :                 buf.append("<" + name + "> ");
   13417           0 :                 int ndim = 3;
   13418           0 :                 int dim1 = data.size();
   13419           0 :                 int dim2 = data.at(0).size();
   13420           0 :                 int dim3 = data.at(0).at(0).size();
   13421             : 
   13422           0 :                 oss.write((char *)&ndim, sizeof(int));
   13423           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13424           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   13425           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   13426           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   13427           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   13428           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   13429             :                 
   13430           0 :                                 double v = data.at(i).at(j).at(k).get();
   13431             :                 
   13432           0 :                                 oss.write((char *) &v, sizeof(v));
   13433             :                         }
   13434             : 
   13435           0 :                 Base64 b64;
   13436           0 :             b64.encode(oss.str(), encoded, false);
   13437           0 :             buf.append(encoded);
   13438           0 :                 buf.append(" </" + name + "> ")
   13439             :                 ;
   13440           0 :         }
   13441             :         
   13442             :         
   13443           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<Humidity> > > >data, const string &name, string &buf){
   13444           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13445           0 :                 string encoded;
   13446             :                 
   13447           0 :                 buf.append("<" + name + "> ");
   13448           0 :                 int ndim = 3;
   13449           0 :                 int dim1 = data.size();
   13450           0 :                 int dim2 = data.at(0).size();
   13451           0 :                 int dim3 = data.at(0).at(0).size();
   13452           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   13453             :                 
   13454           0 :                 oss.write((char *)&ndim, sizeof(int));
   13455           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13456           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   13457           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   13458           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   13459           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   13460           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   13461           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   13462           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   13463             :                 
   13464           0 :                                         double v = data.at(i).at(j).at(k).at(l).get();
   13465             :                 
   13466           0 :                                 oss.write((char *) &v, sizeof(v));
   13467             :                                 }
   13468             : 
   13469           0 :                 Base64 b64;
   13470           0 :             b64.encode(oss.str(), encoded, false);
   13471           0 :             buf.append(encoded);
   13472           0 :                 buf.append(" </" + name + "> ")
   13473             :                 ;
   13474           0 :         }
   13475             :         
   13476             :         
   13477             : #ifndef Double_CPP
   13478             :                 
   13479             : #define Double_CPP double       
   13480             :                 
   13481             : #endif
   13482             :         
   13483             : 
   13484             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   13485             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   13486             :                 
   13487             :     
   13488           0 :         vector<Humidity>& Parser::get1DHumidityFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<Humidity>& attribute)
   13489             :         {
   13490           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13491           0 :                 if (xmlField.length() == 0) {
   13492           0 :                         throw ConversionException("Error: Field \"" + 
   13493           0 :                                         name + "\": Invalid XML syntax", tableName);
   13494             :                 }
   13495             :                 
   13496           0 :                 string decodedString;
   13497           0 :                 Base64 b64;
   13498           0 :                 b64.decode(xmlField, decodedString);
   13499             :                 
   13500           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13501           0 :                 iss.str(decodedString);
   13502             :                 
   13503           0 :                 attribute.clear();
   13504             :                 
   13505           0 :                 unsigned int ndim = 0;
   13506             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13507           0 :                 TRYREAD(iss,ndim);
   13508             :                 
   13509           0 :                 unsigned int dim1 = 0;
   13510             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13511           0 :                 TRYREAD(iss,dim1);
   13512           0 :                 if (ndim != 1) {
   13513           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   13514             :                         }
   13515             :                 
   13516           0 :                 attribute.reserve(dim1);
   13517             :                 
   13518             :                 Double_CPP v;
   13519           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13520             :                         //iss.read((char*) &v, sizeof(v));
   13521           0 :                         TRYREAD(iss,v);
   13522             :                 
   13523           0 :                         attribute.push_back(Humidity(v));
   13524             :                         
   13525             :                 }
   13526           0 :                 return attribute;
   13527           0 :         }
   13528             :         
   13529             :          
   13530           0 :         vector <vector<Humidity> >& Parser::get2DHumidityFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<Humidity> >& attribute)
   13531             :         {
   13532           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13533           0 :                 if (xmlField.length() == 0) {
   13534           0 :                         throw ConversionException("Error: Field \"" + 
   13535           0 :                                         name + "\": Invalid XML syntax", tableName);
   13536             :                 }
   13537             :                 
   13538           0 :                 string decodedString;
   13539           0 :                 Base64 b64;
   13540           0 :                 b64.decode(xmlField, decodedString);
   13541             :                 
   13542           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13543           0 :                 iss.str(decodedString);
   13544             :                 
   13545           0 :                 attribute.clear();
   13546             :                 
   13547           0 :                 unsigned int ndim = 0;
   13548             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13549           0 :                 TRYREAD(iss,ndim);
   13550             :                 
   13551           0 :                 if (ndim != 2) {
   13552           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   13553             :                 }
   13554             :         
   13555           0 :                 unsigned int dim1 = 0;
   13556             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13557           0 :                 TRYREAD(iss,dim1);
   13558             :                 
   13559           0 :                 unsigned int dim2 = 0;
   13560             :                 //iss.read((char *)&dim2, sizeof(dim2));
   13561           0 :                 TRYREAD(iss,dim2);
   13562             :                 
   13563           0 :                 attribute.reserve(dim1);
   13564             :                 
   13565             :                 Double_CPP v;
   13566           0 :                 vector<Humidity> aux2;
   13567           0 :                 aux2.reserve(dim2);
   13568           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13569           0 :                         aux2.clear();
   13570           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   13571             :                                 //iss.read((char*) &v, sizeof(v));
   13572           0 :                                 TRYREAD(iss,v);
   13573             :                 
   13574           0 :                                 aux2.push_back(Humidity(v));
   13575             :                 
   13576             :                         }
   13577           0 :                         attribute.push_back(aux2);      
   13578             :                 }
   13579           0 :                 return attribute;
   13580           0 :         }
   13581             :                 
   13582             :         
   13583           0 :         vector <vector <vector<Humidity> > >& Parser::get3DHumidityFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<Humidity> > >& attribute)
   13584             :         {
   13585           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13586           0 :                 if (xmlField.length() == 0) {
   13587           0 :                         throw ConversionException("Error: Field \"" + 
   13588           0 :                                         name + "\": Invalid XML syntax", tableName);
   13589             :                 }
   13590             :                 
   13591           0 :                 string decodedString;
   13592           0 :                 Base64 b64;
   13593           0 :                 b64.decode(xmlField, decodedString);
   13594             :                 
   13595           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13596           0 :                 iss.str(decodedString);
   13597             :                 
   13598           0 :                 attribute.clear();
   13599             :                 
   13600           0 :                 unsigned int ndim = 0;
   13601             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13602           0 :                 TRYREAD(iss, ndim);     
   13603           0 :                 if (ndim != 3) {
   13604           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   13605             :                 }
   13606             :                                 
   13607           0 :                 unsigned int dim1 = 0;
   13608             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13609           0 :                 TRYREAD(iss,dim1);
   13610             :                 
   13611           0 :                 unsigned int dim2 = 0;
   13612             :                 //iss.read((char *)&dim2, sizeof(dim2));
   13613           0 :                 TRYREAD(iss,dim2);
   13614             :                 
   13615           0 :                 unsigned int dim3 = 0;
   13616             :                 //iss.read((char *)&dim2, sizeof(dim3));
   13617           0 :                 TRYREAD(iss,dim3);
   13618             :                 
   13619           0 :                 attribute.reserve(dim1);
   13620             :                 
   13621             :                 Double_CPP v;
   13622           0 :                 vector <vector<Humidity> > aux2;
   13623           0 :                 vector<Humidity> aux3;            
   13624           0 :                 aux2.reserve(dim2);
   13625           0 :                 aux3.reserve(dim3);
   13626             :                 
   13627           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13628           0 :                         aux2.clear();
   13629           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   13630           0 :                                 aux3.clear();
   13631           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   13632             :                                         //iss.read((char*) &v, sizeof(v));
   13633           0 :                                         TRYREAD(iss,v);
   13634             :                 
   13635           0 :                                         aux3.push_back(Humidity(v));
   13636             :                 
   13637             :                                 }
   13638           0 :                                 aux2.push_back(aux3);
   13639             :                         }
   13640           0 :                         attribute.push_back(aux2);      
   13641             :                 }
   13642           0 :                 return attribute;
   13643             :                 ;
   13644           0 :         }
   13645             :         
   13646             :         
   13647           0 :         vector <vector <vector <vector<Humidity> > > >& Parser::get4DHumidityFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<Humidity> > > >& attribute)
   13648             :         {
   13649           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13650           0 :                 if (xmlField.length() == 0) {
   13651           0 :                         throw ConversionException("Error: Field \"" + 
   13652           0 :                                         name + "\": Invalid XML syntax", tableName);
   13653             :                 }
   13654             :                 
   13655           0 :                 string decodedString;
   13656           0 :                 Base64 b64;
   13657           0 :                 b64.decode(xmlField, decodedString);
   13658             :                 
   13659           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13660           0 :                 iss.str(decodedString);
   13661             :                 
   13662           0 :                 attribute.clear();
   13663             :                 
   13664           0 :                 unsigned int ndim = 0;
   13665             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13666           0 :                 TRYREAD(iss, ndim);     
   13667           0 :                 if (ndim != 4) {
   13668           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   13669             :                 }
   13670             :                                 
   13671           0 :                 unsigned int dim1 = 0;
   13672             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13673           0 :                 TRYREAD(iss,dim1);
   13674             :                 
   13675           0 :                 unsigned int dim2 = 0;
   13676             :                 //iss.read((char *)&dim2, sizeof(dim2));
   13677           0 :                 TRYREAD(iss,dim2);
   13678             :                 
   13679           0 :                 unsigned int dim3 = 0;
   13680             :                 //iss.read((char *)&dim2, sizeof(dim3));
   13681           0 :                 TRYREAD(iss,dim3);
   13682             :                 
   13683           0 :                 unsigned int dim4 = 0;
   13684             :                 //iss.read((char *)&dim2, sizeof(dim3));
   13685           0 :                 TRYREAD(iss,dim3);
   13686             :                 
   13687           0 :                 attribute.reserve(dim1);
   13688             :                 
   13689             :                 Double_CPP v;
   13690           0 :                 vector <vector <vector<Humidity> > > aux2;
   13691           0 :                 vector <vector<Humidity> > aux3;
   13692           0 :                 vector<Humidity> aux4;            
   13693           0 :                 aux2.reserve(dim2);
   13694           0 :                 aux3.reserve(dim3);
   13695           0 :                 aux4.reserve(dim4);
   13696             :                 
   13697           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13698           0 :                         aux2.clear();
   13699           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   13700           0 :                                 aux3.clear();
   13701           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   13702           0 :                                         aux4.clear();
   13703           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   13704             :                                         //iss.read((char*) &v, sizeof(v));
   13705           0 :                                                 TRYREAD(iss,v);
   13706             :                 
   13707           0 :                                                 aux4.push_back(Humidity(v));
   13708             :                 
   13709             :                                         }
   13710           0 :                                         aux3.push_back(aux4);
   13711             :                                 }
   13712           0 :                                 aux2.push_back(aux3);
   13713             :                         }
   13714           0 :                         attribute.push_back(aux2);      
   13715             :                 }
   13716           0 :                 return attribute;
   13717             :                 ;
   13718           0 :         }
   13719             :         
   13720             :         
   13721             : 
   13722             :         
   13723             :         
   13724             :         
   13725             :         
   13726           0 :         void Parser::toXMLBase64(vector<Interval> data, const string &name, string &buf){
   13727           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13728           0 :                 string encoded;
   13729             :                 
   13730           0 :                 buf.append("<" + name + "> ");
   13731           0 :                 int ndim = 1;
   13732           0 :                 int dim1 = data.size();
   13733             :  
   13734           0 :                 oss.write((char *)&ndim, sizeof(int));
   13735           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13736             : 
   13737           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   13738             :                 
   13739           0 :                  long v = data.at(i).get();
   13740             :                 
   13741           0 :                 oss.write((char *) &v, sizeof(v));
   13742             :         }
   13743             : 
   13744           0 :                 Base64 b64;
   13745           0 :             b64.encode(oss.str(), encoded, false);
   13746           0 :             buf.append(encoded);
   13747           0 :                 buf.append(" </" + name + "> ");      
   13748           0 :         }
   13749             :         
   13750             :         
   13751           0 :         void Parser::toXMLBase64(vector< vector<Interval> > data, const string &name, string &buf){
   13752           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13753           0 :                 string encoded;
   13754             :                 
   13755           0 :                 buf.append("<" + name + "> ");
   13756           0 :                 int ndim = 2;
   13757           0 :                 int dim1 = data.size();
   13758           0 :                 int dim2 = data.at(0).size();
   13759             : 
   13760           0 :                 oss.write((char *)&ndim, sizeof(int));
   13761           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13762           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   13763           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   13764           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   13765             :                 
   13766           0 :                         long v = data.at(i).at(j).get();
   13767             :                 
   13768           0 :                         oss.write((char *) &v, sizeof(v));
   13769             :                 }
   13770             : 
   13771           0 :                 Base64 b64;
   13772           0 :             b64.encode(oss.str(), encoded, false);
   13773           0 :             buf.append(encoded);
   13774           0 :                 buf.append(" </" + name + "> ")
   13775             :                 ;
   13776           0 :         }
   13777             :         
   13778             :         
   13779           0 :         void Parser::toXMLBase64(vector< vector< vector<Interval> > > data, const string &name, string &buf){
   13780           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13781           0 :                 string encoded;
   13782             :                 
   13783           0 :                 buf.append("<" + name + "> ");
   13784           0 :                 int ndim = 3;
   13785           0 :                 int dim1 = data.size();
   13786           0 :                 int dim2 = data.at(0).size();
   13787           0 :                 int dim3 = data.at(0).at(0).size();
   13788             : 
   13789           0 :                 oss.write((char *)&ndim, sizeof(int));
   13790           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13791           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   13792           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   13793           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   13794           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   13795           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   13796             :                 
   13797           0 :                                 long v = data.at(i).at(j).at(k).get();
   13798             :                 
   13799           0 :                                 oss.write((char *) &v, sizeof(v));
   13800             :                         }
   13801             : 
   13802           0 :                 Base64 b64;
   13803           0 :             b64.encode(oss.str(), encoded, false);
   13804           0 :             buf.append(encoded);
   13805           0 :                 buf.append(" </" + name + "> ")
   13806             :                 ;
   13807           0 :         }
   13808             :         
   13809             :         
   13810           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<Interval> > > >data, const string &name, string &buf){
   13811           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   13812           0 :                 string encoded;
   13813             :                 
   13814           0 :                 buf.append("<" + name + "> ");
   13815           0 :                 int ndim = 3;
   13816           0 :                 int dim1 = data.size();
   13817           0 :                 int dim2 = data.at(0).size();
   13818           0 :                 int dim3 = data.at(0).at(0).size();
   13819           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   13820             :                 
   13821           0 :                 oss.write((char *)&ndim, sizeof(int));
   13822           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   13823           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   13824           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   13825           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   13826           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   13827           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   13828           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   13829           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   13830             :                 
   13831           0 :                                         long v = data.at(i).at(j).at(k).at(l).get();
   13832             :                 
   13833           0 :                                 oss.write((char *) &v, sizeof(v));
   13834             :                                 }
   13835             : 
   13836           0 :                 Base64 b64;
   13837           0 :             b64.encode(oss.str(), encoded, false);
   13838           0 :             buf.append(encoded);
   13839           0 :                 buf.append(" </" + name + "> ")
   13840             :                 ;
   13841           0 :         }
   13842             :         
   13843             :         
   13844             : #ifndef Long_CPP
   13845             :                 
   13846             : #define Long_CPP int64_t
   13847             :                 
   13848             : #endif
   13849             :         
   13850             : 
   13851             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   13852             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   13853             :                 
   13854             :     
   13855           0 :         vector<Interval>& Parser::get1DIntervalFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<Interval>& attribute)
   13856             :         {
   13857           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13858           0 :                 if (xmlField.length() == 0) {
   13859           0 :                         throw ConversionException("Error: Field \"" + 
   13860           0 :                                         name + "\": Invalid XML syntax", tableName);
   13861             :                 }
   13862             :                 
   13863           0 :                 string decodedString;
   13864           0 :                 Base64 b64;
   13865           0 :                 b64.decode(xmlField, decodedString);
   13866             :                 
   13867           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13868           0 :                 iss.str(decodedString);
   13869             :                 
   13870           0 :                 attribute.clear();
   13871             :                 
   13872           0 :                 unsigned int ndim = 0;
   13873             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13874           0 :                 TRYREAD(iss,ndim);
   13875             :                 
   13876           0 :                 unsigned int dim1 = 0;
   13877             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13878           0 :                 TRYREAD(iss,dim1);
   13879           0 :                 if (ndim != 1) {
   13880           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   13881             :                         }
   13882             :                 
   13883           0 :                 attribute.reserve(dim1);
   13884             :                 
   13885             :                 Long_CPP v;
   13886           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13887             :                         //iss.read((char*) &v, sizeof(v));
   13888           0 :                         TRYREAD(iss,v);
   13889             :                 
   13890           0 :                         attribute.push_back(Interval(v));
   13891             :                         
   13892             :                 }
   13893           0 :                 return attribute;
   13894           0 :         }
   13895             :         
   13896             :          
   13897           0 :         vector <vector<Interval> >& Parser::get2DIntervalFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<Interval> >& attribute)
   13898             :         {
   13899           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13900           0 :                 if (xmlField.length() == 0) {
   13901           0 :                         throw ConversionException("Error: Field \"" + 
   13902           0 :                                         name + "\": Invalid XML syntax", tableName);
   13903             :                 }
   13904             :                 
   13905           0 :                 string decodedString;
   13906           0 :                 Base64 b64;
   13907           0 :                 b64.decode(xmlField, decodedString);
   13908             :                 
   13909           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13910           0 :                 iss.str(decodedString);
   13911             :                 
   13912           0 :                 attribute.clear();
   13913             :                 
   13914           0 :                 unsigned int ndim = 0;
   13915             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13916           0 :                 TRYREAD(iss,ndim);
   13917             :                 
   13918           0 :                 if (ndim != 2) {
   13919           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   13920             :                 }
   13921             :         
   13922           0 :                 unsigned int dim1 = 0;
   13923             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13924           0 :                 TRYREAD(iss,dim1);
   13925             :                 
   13926           0 :                 unsigned int dim2 = 0;
   13927             :                 //iss.read((char *)&dim2, sizeof(dim2));
   13928           0 :                 TRYREAD(iss,dim2);
   13929             :                 
   13930           0 :                 attribute.reserve(dim1);
   13931             :                 
   13932             :                 Long_CPP v;
   13933           0 :                 vector<Interval> aux2;
   13934           0 :                 aux2.reserve(dim2);
   13935           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13936           0 :                         aux2.clear();
   13937           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   13938             :                                 //iss.read((char*) &v, sizeof(v));
   13939           0 :                                 TRYREAD(iss,v);
   13940             :                 
   13941           0 :                                 aux2.push_back(Interval(v));
   13942             :                 
   13943             :                         }
   13944           0 :                         attribute.push_back(aux2);      
   13945             :                 }
   13946           0 :                 return attribute;
   13947           0 :         }
   13948             :                 
   13949             :         
   13950           0 :         vector <vector <vector<Interval> > >& Parser::get3DIntervalFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<Interval> > >& attribute)
   13951             :         {
   13952           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   13953           0 :                 if (xmlField.length() == 0) {
   13954           0 :                         throw ConversionException("Error: Field \"" + 
   13955           0 :                                         name + "\": Invalid XML syntax", tableName);
   13956             :                 }
   13957             :                 
   13958           0 :                 string decodedString;
   13959           0 :                 Base64 b64;
   13960           0 :                 b64.decode(xmlField, decodedString);
   13961             :                 
   13962           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   13963           0 :                 iss.str(decodedString);
   13964             :                 
   13965           0 :                 attribute.clear();
   13966             :                 
   13967           0 :                 unsigned int ndim = 0;
   13968             :                 //iss.read((char *)&ndim, sizeof(ndim));
   13969           0 :                 TRYREAD(iss, ndim);     
   13970           0 :                 if (ndim != 3) {
   13971           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   13972             :                 }
   13973             :                                 
   13974           0 :                 unsigned int dim1 = 0;
   13975             :                 //iss.read((char *)&dim1, sizeof(dim1));
   13976           0 :                 TRYREAD(iss,dim1);
   13977             :                 
   13978           0 :                 unsigned int dim2 = 0;
   13979             :                 //iss.read((char *)&dim2, sizeof(dim2));
   13980           0 :                 TRYREAD(iss,dim2);
   13981             :                 
   13982           0 :                 unsigned int dim3 = 0;
   13983             :                 //iss.read((char *)&dim2, sizeof(dim3));
   13984           0 :                 TRYREAD(iss,dim3);
   13985             :                 
   13986           0 :                 attribute.reserve(dim1);
   13987             :                 
   13988             :                 Long_CPP v;
   13989           0 :                 vector <vector<Interval> > aux2;
   13990           0 :                 vector<Interval> aux3;            
   13991           0 :                 aux2.reserve(dim2);
   13992           0 :                 aux3.reserve(dim3);
   13993             :                 
   13994           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   13995           0 :                         aux2.clear();
   13996           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   13997           0 :                                 aux3.clear();
   13998           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   13999             :                                         //iss.read((char*) &v, sizeof(v));
   14000           0 :                                         TRYREAD(iss,v);
   14001             :                 
   14002           0 :                                         aux3.push_back(Interval(v));
   14003             :                 
   14004             :                                 }
   14005           0 :                                 aux2.push_back(aux3);
   14006             :                         }
   14007           0 :                         attribute.push_back(aux2);      
   14008             :                 }
   14009           0 :                 return attribute;
   14010             :                 ;
   14011           0 :         }
   14012             :         
   14013             :         
   14014           0 :         vector <vector <vector <vector<Interval> > > >& Parser::get4DIntervalFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<Interval> > > >& attribute)
   14015             :         {
   14016           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14017           0 :                 if (xmlField.length() == 0) {
   14018           0 :                         throw ConversionException("Error: Field \"" + 
   14019           0 :                                         name + "\": Invalid XML syntax", tableName);
   14020             :                 }
   14021             :                 
   14022           0 :                 string decodedString;
   14023           0 :                 Base64 b64;
   14024           0 :                 b64.decode(xmlField, decodedString);
   14025             :                 
   14026           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14027           0 :                 iss.str(decodedString);
   14028             :                 
   14029           0 :                 attribute.clear();
   14030             :                 
   14031           0 :                 unsigned int ndim = 0;
   14032             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14033           0 :                 TRYREAD(iss, ndim);     
   14034           0 :                 if (ndim != 4) {
   14035           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   14036             :                 }
   14037             :                                 
   14038           0 :                 unsigned int dim1 = 0;
   14039             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14040           0 :                 TRYREAD(iss,dim1);
   14041             :                 
   14042           0 :                 unsigned int dim2 = 0;
   14043             :                 //iss.read((char *)&dim2, sizeof(dim2));
   14044           0 :                 TRYREAD(iss,dim2);
   14045             :                 
   14046           0 :                 unsigned int dim3 = 0;
   14047             :                 //iss.read((char *)&dim2, sizeof(dim3));
   14048           0 :                 TRYREAD(iss,dim3);
   14049             :                 
   14050           0 :                 unsigned int dim4 = 0;
   14051             :                 //iss.read((char *)&dim2, sizeof(dim3));
   14052           0 :                 TRYREAD(iss,dim3);
   14053             :                 
   14054           0 :                 attribute.reserve(dim1);
   14055             :                 
   14056             :                 Long_CPP v;
   14057           0 :                 vector <vector <vector<Interval> > > aux2;
   14058           0 :                 vector <vector<Interval> > aux3;
   14059           0 :                 vector<Interval> aux4;            
   14060           0 :                 aux2.reserve(dim2);
   14061           0 :                 aux3.reserve(dim3);
   14062           0 :                 aux4.reserve(dim4);
   14063             :                 
   14064           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14065           0 :                         aux2.clear();
   14066           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   14067           0 :                                 aux3.clear();
   14068           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   14069           0 :                                         aux4.clear();
   14070           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   14071             :                                         //iss.read((char*) &v, sizeof(v));
   14072           0 :                                                 TRYREAD(iss,v);
   14073             :                 
   14074           0 :                                                 aux4.push_back(Interval(v));
   14075             :                 
   14076             :                                         }
   14077           0 :                                         aux3.push_back(aux4);
   14078             :                                 }
   14079           0 :                                 aux2.push_back(aux3);
   14080             :                         }
   14081           0 :                         attribute.push_back(aux2);      
   14082             :                 }
   14083           0 :                 return attribute;
   14084             :                 ;
   14085           0 :         }
   14086             :         
   14087             :         
   14088             : 
   14089             :         
   14090             :         
   14091             :         
   14092             :         
   14093           0 :         void Parser::toXMLBase64(vector<Length> data, const string &name, string &buf){
   14094           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14095           0 :                 string encoded;
   14096             :                 
   14097           0 :                 buf.append("<" + name + "> ");
   14098           0 :                 int ndim = 1;
   14099           0 :                 int dim1 = data.size();
   14100             :  
   14101           0 :                 oss.write((char *)&ndim, sizeof(int));
   14102           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14103             : 
   14104           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   14105             :                 
   14106           0 :                  double v = data.at(i).get();
   14107             :                 
   14108           0 :                 oss.write((char *) &v, sizeof(v));
   14109             :         }
   14110             : 
   14111           0 :                 Base64 b64;
   14112           0 :             b64.encode(oss.str(), encoded, false);
   14113           0 :             buf.append(encoded);
   14114           0 :                 buf.append(" </" + name + "> ");      
   14115           0 :         }
   14116             :         
   14117             :         
   14118           0 :         void Parser::toXMLBase64(vector< vector<Length> > data, const string &name, string &buf){
   14119           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14120           0 :                 string encoded;
   14121             :                 
   14122           0 :                 buf.append("<" + name + "> ");
   14123           0 :                 int ndim = 2;
   14124           0 :                 int dim1 = data.size();
   14125           0 :                 int dim2 = data.at(0).size();
   14126             : 
   14127           0 :                 oss.write((char *)&ndim, sizeof(int));
   14128           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14129           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   14130           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   14131           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   14132             :                 
   14133           0 :                         double v = data.at(i).at(j).get();
   14134             :                 
   14135           0 :                         oss.write((char *) &v, sizeof(v));
   14136             :                 }
   14137             : 
   14138           0 :                 Base64 b64;
   14139           0 :             b64.encode(oss.str(), encoded, false);
   14140           0 :             buf.append(encoded);
   14141           0 :                 buf.append(" </" + name + "> ")
   14142             :                 ;
   14143           0 :         }
   14144             :         
   14145             :         
   14146           0 :         void Parser::toXMLBase64(vector< vector< vector<Length> > > data, const string &name, string &buf){
   14147           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14148           0 :                 string encoded;
   14149             :                 
   14150           0 :                 buf.append("<" + name + "> ");
   14151           0 :                 int ndim = 3;
   14152           0 :                 int dim1 = data.size();
   14153           0 :                 int dim2 = data.at(0).size();
   14154           0 :                 int dim3 = data.at(0).at(0).size();
   14155             : 
   14156           0 :                 oss.write((char *)&ndim, sizeof(int));
   14157           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14158           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   14159           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   14160           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   14161           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   14162           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   14163             :                 
   14164           0 :                                 double v = data.at(i).at(j).at(k).get();
   14165             :                 
   14166           0 :                                 oss.write((char *) &v, sizeof(v));
   14167             :                         }
   14168             : 
   14169           0 :                 Base64 b64;
   14170           0 :             b64.encode(oss.str(), encoded, false);
   14171           0 :             buf.append(encoded);
   14172           0 :                 buf.append(" </" + name + "> ")
   14173             :                 ;
   14174           0 :         }
   14175             :         
   14176             :         
   14177           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<Length> > > >data, const string &name, string &buf){
   14178           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14179           0 :                 string encoded;
   14180             :                 
   14181           0 :                 buf.append("<" + name + "> ");
   14182           0 :                 int ndim = 3;
   14183           0 :                 int dim1 = data.size();
   14184           0 :                 int dim2 = data.at(0).size();
   14185           0 :                 int dim3 = data.at(0).at(0).size();
   14186           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   14187             :                 
   14188           0 :                 oss.write((char *)&ndim, sizeof(int));
   14189           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14190           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   14191           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   14192           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   14193           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   14194           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   14195           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   14196           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   14197             :                 
   14198           0 :                                         double v = data.at(i).at(j).at(k).at(l).get();
   14199             :                 
   14200           0 :                                 oss.write((char *) &v, sizeof(v));
   14201             :                                 }
   14202             : 
   14203           0 :                 Base64 b64;
   14204           0 :             b64.encode(oss.str(), encoded, false);
   14205           0 :             buf.append(encoded);
   14206           0 :                 buf.append(" </" + name + "> ")
   14207             :                 ;
   14208           0 :         }
   14209             :         
   14210             :         
   14211             : #ifndef Double_CPP
   14212             :                 
   14213             : #define Double_CPP double       
   14214             :                 
   14215             : #endif
   14216             :         
   14217             : 
   14218             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   14219             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   14220             :                 
   14221             :     
   14222           0 :         vector<Length>& Parser::get1DLengthFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<Length>& attribute)
   14223             :         {
   14224           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14225           0 :                 if (xmlField.length() == 0) {
   14226           0 :                         throw ConversionException("Error: Field \"" + 
   14227           0 :                                         name + "\": Invalid XML syntax", tableName);
   14228             :                 }
   14229             :                 
   14230           0 :                 string decodedString;
   14231           0 :                 Base64 b64;
   14232           0 :                 b64.decode(xmlField, decodedString);
   14233             :                 
   14234           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14235           0 :                 iss.str(decodedString);
   14236             :                 
   14237           0 :                 attribute.clear();
   14238             :                 
   14239           0 :                 unsigned int ndim = 0;
   14240             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14241           0 :                 TRYREAD(iss,ndim);
   14242             :                 
   14243           0 :                 unsigned int dim1 = 0;
   14244             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14245           0 :                 TRYREAD(iss,dim1);
   14246           0 :                 if (ndim != 1) {
   14247           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   14248             :                         }
   14249             :                 
   14250           0 :                 attribute.reserve(dim1);
   14251             :                 
   14252             :                 Double_CPP v;
   14253           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14254             :                         //iss.read((char*) &v, sizeof(v));
   14255           0 :                         TRYREAD(iss,v);
   14256             :                 
   14257           0 :                         attribute.push_back(Length(v));
   14258             :                         
   14259             :                 }
   14260           0 :                 return attribute;
   14261           0 :         }
   14262             :         
   14263             :          
   14264           0 :         vector <vector<Length> >& Parser::get2DLengthFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<Length> >& attribute)
   14265             :         {
   14266           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14267           0 :                 if (xmlField.length() == 0) {
   14268           0 :                         throw ConversionException("Error: Field \"" + 
   14269           0 :                                         name + "\": Invalid XML syntax", tableName);
   14270             :                 }
   14271             :                 
   14272           0 :                 string decodedString;
   14273           0 :                 Base64 b64;
   14274           0 :                 b64.decode(xmlField, decodedString);
   14275             :                 
   14276           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14277           0 :                 iss.str(decodedString);
   14278             :                 
   14279           0 :                 attribute.clear();
   14280             :                 
   14281           0 :                 unsigned int ndim = 0;
   14282             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14283           0 :                 TRYREAD(iss,ndim);
   14284             :                 
   14285           0 :                 if (ndim != 2) {
   14286           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   14287             :                 }
   14288             :         
   14289           0 :                 unsigned int dim1 = 0;
   14290             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14291           0 :                 TRYREAD(iss,dim1);
   14292             :                 
   14293           0 :                 unsigned int dim2 = 0;
   14294             :                 //iss.read((char *)&dim2, sizeof(dim2));
   14295           0 :                 TRYREAD(iss,dim2);
   14296             :                 
   14297           0 :                 attribute.reserve(dim1);
   14298             :                 
   14299             :                 Double_CPP v;
   14300           0 :                 vector<Length> aux2;
   14301           0 :                 aux2.reserve(dim2);
   14302           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14303           0 :                         aux2.clear();
   14304           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   14305             :                                 //iss.read((char*) &v, sizeof(v));
   14306           0 :                                 TRYREAD(iss,v);
   14307             :                 
   14308           0 :                                 aux2.push_back(Length(v));
   14309             :                 
   14310             :                         }
   14311           0 :                         attribute.push_back(aux2);      
   14312             :                 }
   14313           0 :                 return attribute;
   14314           0 :         }
   14315             :                 
   14316             :         
   14317           0 :         vector <vector <vector<Length> > >& Parser::get3DLengthFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<Length> > >& attribute)
   14318             :         {
   14319           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14320           0 :                 if (xmlField.length() == 0) {
   14321           0 :                         throw ConversionException("Error: Field \"" + 
   14322           0 :                                         name + "\": Invalid XML syntax", tableName);
   14323             :                 }
   14324             :                 
   14325           0 :                 string decodedString;
   14326           0 :                 Base64 b64;
   14327           0 :                 b64.decode(xmlField, decodedString);
   14328             :                 
   14329           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14330           0 :                 iss.str(decodedString);
   14331             :                 
   14332           0 :                 attribute.clear();
   14333             :                 
   14334           0 :                 unsigned int ndim = 0;
   14335             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14336           0 :                 TRYREAD(iss, ndim);     
   14337           0 :                 if (ndim != 3) {
   14338           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   14339             :                 }
   14340             :                                 
   14341           0 :                 unsigned int dim1 = 0;
   14342             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14343           0 :                 TRYREAD(iss,dim1);
   14344             :                 
   14345           0 :                 unsigned int dim2 = 0;
   14346             :                 //iss.read((char *)&dim2, sizeof(dim2));
   14347           0 :                 TRYREAD(iss,dim2);
   14348             :                 
   14349           0 :                 unsigned int dim3 = 0;
   14350             :                 //iss.read((char *)&dim2, sizeof(dim3));
   14351           0 :                 TRYREAD(iss,dim3);
   14352             :                 
   14353           0 :                 attribute.reserve(dim1);
   14354             :                 
   14355             :                 Double_CPP v;
   14356           0 :                 vector <vector<Length> > aux2;
   14357           0 :                 vector<Length> aux3;              
   14358           0 :                 aux2.reserve(dim2);
   14359           0 :                 aux3.reserve(dim3);
   14360             :                 
   14361           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14362           0 :                         aux2.clear();
   14363           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   14364           0 :                                 aux3.clear();
   14365           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   14366             :                                         //iss.read((char*) &v, sizeof(v));
   14367           0 :                                         TRYREAD(iss,v);
   14368             :                 
   14369           0 :                                         aux3.push_back(Length(v));
   14370             :                 
   14371             :                                 }
   14372           0 :                                 aux2.push_back(aux3);
   14373             :                         }
   14374           0 :                         attribute.push_back(aux2);      
   14375             :                 }
   14376           0 :                 return attribute;
   14377             :                 ;
   14378           0 :         }
   14379             :         
   14380             :         
   14381           0 :         vector <vector <vector <vector<Length> > > >& Parser::get4DLengthFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<Length> > > >& attribute)
   14382             :         {
   14383           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14384           0 :                 if (xmlField.length() == 0) {
   14385           0 :                         throw ConversionException("Error: Field \"" + 
   14386           0 :                                         name + "\": Invalid XML syntax", tableName);
   14387             :                 }
   14388             :                 
   14389           0 :                 string decodedString;
   14390           0 :                 Base64 b64;
   14391           0 :                 b64.decode(xmlField, decodedString);
   14392             :                 
   14393           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14394           0 :                 iss.str(decodedString);
   14395             :                 
   14396           0 :                 attribute.clear();
   14397             :                 
   14398           0 :                 unsigned int ndim = 0;
   14399             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14400           0 :                 TRYREAD(iss, ndim);     
   14401           0 :                 if (ndim != 4) {
   14402           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   14403             :                 }
   14404             :                                 
   14405           0 :                 unsigned int dim1 = 0;
   14406             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14407           0 :                 TRYREAD(iss,dim1);
   14408             :                 
   14409           0 :                 unsigned int dim2 = 0;
   14410             :                 //iss.read((char *)&dim2, sizeof(dim2));
   14411           0 :                 TRYREAD(iss,dim2);
   14412             :                 
   14413           0 :                 unsigned int dim3 = 0;
   14414             :                 //iss.read((char *)&dim2, sizeof(dim3));
   14415           0 :                 TRYREAD(iss,dim3);
   14416             :                 
   14417           0 :                 unsigned int dim4 = 0;
   14418             :                 //iss.read((char *)&dim2, sizeof(dim3));
   14419           0 :                 TRYREAD(iss,dim3);
   14420             :                 
   14421           0 :                 attribute.reserve(dim1);
   14422             :                 
   14423             :                 Double_CPP v;
   14424           0 :                 vector <vector <vector<Length> > > aux2;
   14425           0 :                 vector <vector<Length> > aux3;
   14426           0 :                 vector<Length> aux4;              
   14427           0 :                 aux2.reserve(dim2);
   14428           0 :                 aux3.reserve(dim3);
   14429           0 :                 aux4.reserve(dim4);
   14430             :                 
   14431           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14432           0 :                         aux2.clear();
   14433           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   14434           0 :                                 aux3.clear();
   14435           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   14436           0 :                                         aux4.clear();
   14437           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   14438             :                                         //iss.read((char*) &v, sizeof(v));
   14439           0 :                                                 TRYREAD(iss,v);
   14440             :                 
   14441           0 :                                                 aux4.push_back(Length(v));
   14442             :                 
   14443             :                                         }
   14444           0 :                                         aux3.push_back(aux4);
   14445             :                                 }
   14446           0 :                                 aux2.push_back(aux3);
   14447             :                         }
   14448           0 :                         attribute.push_back(aux2);      
   14449             :                 }
   14450           0 :                 return attribute;
   14451             :                 ;
   14452           0 :         }
   14453             :         
   14454             :         
   14455             : 
   14456             :         
   14457             :         
   14458             :         
   14459             :         
   14460           0 :         void Parser::toXMLBase64(vector<Pressure> data, const string &name, string &buf){
   14461           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14462           0 :                 string encoded;
   14463             :                 
   14464           0 :                 buf.append("<" + name + "> ");
   14465           0 :                 int ndim = 1;
   14466           0 :                 int dim1 = data.size();
   14467             :  
   14468           0 :                 oss.write((char *)&ndim, sizeof(int));
   14469           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14470             : 
   14471           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   14472             :                 
   14473           0 :                  double v = data.at(i).get();
   14474             :                 
   14475           0 :                 oss.write((char *) &v, sizeof(v));
   14476             :         }
   14477             : 
   14478           0 :                 Base64 b64;
   14479           0 :             b64.encode(oss.str(), encoded, false);
   14480           0 :             buf.append(encoded);
   14481           0 :                 buf.append(" </" + name + "> ");      
   14482           0 :         }
   14483             :         
   14484             :         
   14485           0 :         void Parser::toXMLBase64(vector< vector<Pressure> > data, const string &name, string &buf){
   14486           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14487           0 :                 string encoded;
   14488             :                 
   14489           0 :                 buf.append("<" + name + "> ");
   14490           0 :                 int ndim = 2;
   14491           0 :                 int dim1 = data.size();
   14492           0 :                 int dim2 = data.at(0).size();
   14493             : 
   14494           0 :                 oss.write((char *)&ndim, sizeof(int));
   14495           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14496           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   14497           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   14498           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   14499             :                 
   14500           0 :                         double v = data.at(i).at(j).get();
   14501             :                 
   14502           0 :                         oss.write((char *) &v, sizeof(v));
   14503             :                 }
   14504             : 
   14505           0 :                 Base64 b64;
   14506           0 :             b64.encode(oss.str(), encoded, false);
   14507           0 :             buf.append(encoded);
   14508           0 :                 buf.append(" </" + name + "> ")
   14509             :                 ;
   14510           0 :         }
   14511             :         
   14512             :         
   14513           0 :         void Parser::toXMLBase64(vector< vector< vector<Pressure> > > data, const string &name, string &buf){
   14514           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14515           0 :                 string encoded;
   14516             :                 
   14517           0 :                 buf.append("<" + name + "> ");
   14518           0 :                 int ndim = 3;
   14519           0 :                 int dim1 = data.size();
   14520           0 :                 int dim2 = data.at(0).size();
   14521           0 :                 int dim3 = data.at(0).at(0).size();
   14522             : 
   14523           0 :                 oss.write((char *)&ndim, sizeof(int));
   14524           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14525           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   14526           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   14527           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   14528           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   14529           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   14530             :                 
   14531           0 :                                 double v = data.at(i).at(j).at(k).get();
   14532             :                 
   14533           0 :                                 oss.write((char *) &v, sizeof(v));
   14534             :                         }
   14535             : 
   14536           0 :                 Base64 b64;
   14537           0 :             b64.encode(oss.str(), encoded, false);
   14538           0 :             buf.append(encoded);
   14539           0 :                 buf.append(" </" + name + "> ")
   14540             :                 ;
   14541           0 :         }
   14542             :         
   14543             :         
   14544           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<Pressure> > > >data, const string &name, string &buf){
   14545           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14546           0 :                 string encoded;
   14547             :                 
   14548           0 :                 buf.append("<" + name + "> ");
   14549           0 :                 int ndim = 3;
   14550           0 :                 int dim1 = data.size();
   14551           0 :                 int dim2 = data.at(0).size();
   14552           0 :                 int dim3 = data.at(0).at(0).size();
   14553           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   14554             :                 
   14555           0 :                 oss.write((char *)&ndim, sizeof(int));
   14556           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14557           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   14558           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   14559           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   14560           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   14561           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   14562           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   14563           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   14564             :                 
   14565           0 :                                         double v = data.at(i).at(j).at(k).at(l).get();
   14566             :                 
   14567           0 :                                 oss.write((char *) &v, sizeof(v));
   14568             :                                 }
   14569             : 
   14570           0 :                 Base64 b64;
   14571           0 :             b64.encode(oss.str(), encoded, false);
   14572           0 :             buf.append(encoded);
   14573           0 :                 buf.append(" </" + name + "> ")
   14574             :                 ;
   14575           0 :         }
   14576             :         
   14577             :         
   14578             : #ifndef Double_CPP
   14579             :                 
   14580             : #define Double_CPP double       
   14581             :                 
   14582             : #endif
   14583             :         
   14584             : 
   14585             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   14586             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   14587             :                 
   14588             :     
   14589           0 :         vector<Pressure>& Parser::get1DPressureFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<Pressure>& attribute)
   14590             :         {
   14591           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14592           0 :                 if (xmlField.length() == 0) {
   14593           0 :                         throw ConversionException("Error: Field \"" + 
   14594           0 :                                         name + "\": Invalid XML syntax", tableName);
   14595             :                 }
   14596             :                 
   14597           0 :                 string decodedString;
   14598           0 :                 Base64 b64;
   14599           0 :                 b64.decode(xmlField, decodedString);
   14600             :                 
   14601           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14602           0 :                 iss.str(decodedString);
   14603             :                 
   14604           0 :                 attribute.clear();
   14605             :                 
   14606           0 :                 unsigned int ndim = 0;
   14607             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14608           0 :                 TRYREAD(iss,ndim);
   14609             :                 
   14610           0 :                 unsigned int dim1 = 0;
   14611             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14612           0 :                 TRYREAD(iss,dim1);
   14613           0 :                 if (ndim != 1) {
   14614           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   14615             :                         }
   14616             :                 
   14617           0 :                 attribute.reserve(dim1);
   14618             :                 
   14619             :                 Double_CPP v;
   14620           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14621             :                         //iss.read((char*) &v, sizeof(v));
   14622           0 :                         TRYREAD(iss,v);
   14623             :                 
   14624           0 :                         attribute.push_back(Pressure(v));
   14625             :                         
   14626             :                 }
   14627           0 :                 return attribute;
   14628           0 :         }
   14629             :         
   14630             :          
   14631           0 :         vector <vector<Pressure> >& Parser::get2DPressureFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<Pressure> >& attribute)
   14632             :         {
   14633           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14634           0 :                 if (xmlField.length() == 0) {
   14635           0 :                         throw ConversionException("Error: Field \"" + 
   14636           0 :                                         name + "\": Invalid XML syntax", tableName);
   14637             :                 }
   14638             :                 
   14639           0 :                 string decodedString;
   14640           0 :                 Base64 b64;
   14641           0 :                 b64.decode(xmlField, decodedString);
   14642             :                 
   14643           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14644           0 :                 iss.str(decodedString);
   14645             :                 
   14646           0 :                 attribute.clear();
   14647             :                 
   14648           0 :                 unsigned int ndim = 0;
   14649             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14650           0 :                 TRYREAD(iss,ndim);
   14651             :                 
   14652           0 :                 if (ndim != 2) {
   14653           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   14654             :                 }
   14655             :         
   14656           0 :                 unsigned int dim1 = 0;
   14657             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14658           0 :                 TRYREAD(iss,dim1);
   14659             :                 
   14660           0 :                 unsigned int dim2 = 0;
   14661             :                 //iss.read((char *)&dim2, sizeof(dim2));
   14662           0 :                 TRYREAD(iss,dim2);
   14663             :                 
   14664           0 :                 attribute.reserve(dim1);
   14665             :                 
   14666             :                 Double_CPP v;
   14667           0 :                 vector<Pressure> aux2;
   14668           0 :                 aux2.reserve(dim2);
   14669           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14670           0 :                         aux2.clear();
   14671           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   14672             :                                 //iss.read((char*) &v, sizeof(v));
   14673           0 :                                 TRYREAD(iss,v);
   14674             :                 
   14675           0 :                                 aux2.push_back(Pressure(v));
   14676             :                 
   14677             :                         }
   14678           0 :                         attribute.push_back(aux2);      
   14679             :                 }
   14680           0 :                 return attribute;
   14681           0 :         }
   14682             :                 
   14683             :         
   14684           0 :         vector <vector <vector<Pressure> > >& Parser::get3DPressureFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<Pressure> > >& attribute)
   14685             :         {
   14686           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14687           0 :                 if (xmlField.length() == 0) {
   14688           0 :                         throw ConversionException("Error: Field \"" + 
   14689           0 :                                         name + "\": Invalid XML syntax", tableName);
   14690             :                 }
   14691             :                 
   14692           0 :                 string decodedString;
   14693           0 :                 Base64 b64;
   14694           0 :                 b64.decode(xmlField, decodedString);
   14695             :                 
   14696           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14697           0 :                 iss.str(decodedString);
   14698             :                 
   14699           0 :                 attribute.clear();
   14700             :                 
   14701           0 :                 unsigned int ndim = 0;
   14702             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14703           0 :                 TRYREAD(iss, ndim);     
   14704           0 :                 if (ndim != 3) {
   14705           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   14706             :                 }
   14707             :                                 
   14708           0 :                 unsigned int dim1 = 0;
   14709             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14710           0 :                 TRYREAD(iss,dim1);
   14711             :                 
   14712           0 :                 unsigned int dim2 = 0;
   14713             :                 //iss.read((char *)&dim2, sizeof(dim2));
   14714           0 :                 TRYREAD(iss,dim2);
   14715             :                 
   14716           0 :                 unsigned int dim3 = 0;
   14717             :                 //iss.read((char *)&dim2, sizeof(dim3));
   14718           0 :                 TRYREAD(iss,dim3);
   14719             :                 
   14720           0 :                 attribute.reserve(dim1);
   14721             :                 
   14722             :                 Double_CPP v;
   14723           0 :                 vector <vector<Pressure> > aux2;
   14724           0 :                 vector<Pressure> aux3;            
   14725           0 :                 aux2.reserve(dim2);
   14726           0 :                 aux3.reserve(dim3);
   14727             :                 
   14728           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14729           0 :                         aux2.clear();
   14730           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   14731           0 :                                 aux3.clear();
   14732           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   14733             :                                         //iss.read((char*) &v, sizeof(v));
   14734           0 :                                         TRYREAD(iss,v);
   14735             :                 
   14736           0 :                                         aux3.push_back(Pressure(v));
   14737             :                 
   14738             :                                 }
   14739           0 :                                 aux2.push_back(aux3);
   14740             :                         }
   14741           0 :                         attribute.push_back(aux2);      
   14742             :                 }
   14743           0 :                 return attribute;
   14744             :                 ;
   14745           0 :         }
   14746             :         
   14747             :         
   14748           0 :         vector <vector <vector <vector<Pressure> > > >& Parser::get4DPressureFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<Pressure> > > >& attribute)
   14749             :         {
   14750           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14751           0 :                 if (xmlField.length() == 0) {
   14752           0 :                         throw ConversionException("Error: Field \"" + 
   14753           0 :                                         name + "\": Invalid XML syntax", tableName);
   14754             :                 }
   14755             :                 
   14756           0 :                 string decodedString;
   14757           0 :                 Base64 b64;
   14758           0 :                 b64.decode(xmlField, decodedString);
   14759             :                 
   14760           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14761           0 :                 iss.str(decodedString);
   14762             :                 
   14763           0 :                 attribute.clear();
   14764             :                 
   14765           0 :                 unsigned int ndim = 0;
   14766             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14767           0 :                 TRYREAD(iss, ndim);     
   14768           0 :                 if (ndim != 4) {
   14769           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   14770             :                 }
   14771             :                                 
   14772           0 :                 unsigned int dim1 = 0;
   14773             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14774           0 :                 TRYREAD(iss,dim1);
   14775             :                 
   14776           0 :                 unsigned int dim2 = 0;
   14777             :                 //iss.read((char *)&dim2, sizeof(dim2));
   14778           0 :                 TRYREAD(iss,dim2);
   14779             :                 
   14780           0 :                 unsigned int dim3 = 0;
   14781             :                 //iss.read((char *)&dim2, sizeof(dim3));
   14782           0 :                 TRYREAD(iss,dim3);
   14783             :                 
   14784           0 :                 unsigned int dim4 = 0;
   14785             :                 //iss.read((char *)&dim2, sizeof(dim3));
   14786           0 :                 TRYREAD(iss,dim3);
   14787             :                 
   14788           0 :                 attribute.reserve(dim1);
   14789             :                 
   14790             :                 Double_CPP v;
   14791           0 :                 vector <vector <vector<Pressure> > > aux2;
   14792           0 :                 vector <vector<Pressure> > aux3;
   14793           0 :                 vector<Pressure> aux4;            
   14794           0 :                 aux2.reserve(dim2);
   14795           0 :                 aux3.reserve(dim3);
   14796           0 :                 aux4.reserve(dim4);
   14797             :                 
   14798           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14799           0 :                         aux2.clear();
   14800           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   14801           0 :                                 aux3.clear();
   14802           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   14803           0 :                                         aux4.clear();
   14804           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   14805             :                                         //iss.read((char*) &v, sizeof(v));
   14806           0 :                                                 TRYREAD(iss,v);
   14807             :                 
   14808           0 :                                                 aux4.push_back(Pressure(v));
   14809             :                 
   14810             :                                         }
   14811           0 :                                         aux3.push_back(aux4);
   14812             :                                 }
   14813           0 :                                 aux2.push_back(aux3);
   14814             :                         }
   14815           0 :                         attribute.push_back(aux2);      
   14816             :                 }
   14817           0 :                 return attribute;
   14818             :                 ;
   14819           0 :         }
   14820             :         
   14821             :         
   14822             : 
   14823             :         
   14824             :         
   14825             :         
   14826             :         
   14827           0 :         void Parser::toXMLBase64(vector<Speed> data, const string &name, string &buf){
   14828           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14829           0 :                 string encoded;
   14830             :                 
   14831           0 :                 buf.append("<" + name + "> ");
   14832           0 :                 int ndim = 1;
   14833           0 :                 int dim1 = data.size();
   14834             :  
   14835           0 :                 oss.write((char *)&ndim, sizeof(int));
   14836           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14837             : 
   14838           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   14839             :                 
   14840           0 :                  double v = data.at(i).get();
   14841             :                 
   14842           0 :                 oss.write((char *) &v, sizeof(v));
   14843             :         }
   14844             : 
   14845           0 :                 Base64 b64;
   14846           0 :             b64.encode(oss.str(), encoded, false);
   14847           0 :             buf.append(encoded);
   14848           0 :                 buf.append(" </" + name + "> ");      
   14849           0 :         }
   14850             :         
   14851             :         
   14852           0 :         void Parser::toXMLBase64(vector< vector<Speed> > data, const string &name, string &buf){
   14853           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14854           0 :                 string encoded;
   14855             :                 
   14856           0 :                 buf.append("<" + name + "> ");
   14857           0 :                 int ndim = 2;
   14858           0 :                 int dim1 = data.size();
   14859           0 :                 int dim2 = data.at(0).size();
   14860             : 
   14861           0 :                 oss.write((char *)&ndim, sizeof(int));
   14862           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14863           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   14864           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   14865           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   14866             :                 
   14867           0 :                         double v = data.at(i).at(j).get();
   14868             :                 
   14869           0 :                         oss.write((char *) &v, sizeof(v));
   14870             :                 }
   14871             : 
   14872           0 :                 Base64 b64;
   14873           0 :             b64.encode(oss.str(), encoded, false);
   14874           0 :             buf.append(encoded);
   14875           0 :                 buf.append(" </" + name + "> ")
   14876             :                 ;
   14877           0 :         }
   14878             :         
   14879             :         
   14880           0 :         void Parser::toXMLBase64(vector< vector< vector<Speed> > > data, const string &name, string &buf){
   14881           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14882           0 :                 string encoded;
   14883             :                 
   14884           0 :                 buf.append("<" + name + "> ");
   14885           0 :                 int ndim = 3;
   14886           0 :                 int dim1 = data.size();
   14887           0 :                 int dim2 = data.at(0).size();
   14888           0 :                 int dim3 = data.at(0).at(0).size();
   14889             : 
   14890           0 :                 oss.write((char *)&ndim, sizeof(int));
   14891           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14892           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   14893           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   14894           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   14895           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   14896           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   14897             :                 
   14898           0 :                                 double v = data.at(i).at(j).at(k).get();
   14899             :                 
   14900           0 :                                 oss.write((char *) &v, sizeof(v));
   14901             :                         }
   14902             : 
   14903           0 :                 Base64 b64;
   14904           0 :             b64.encode(oss.str(), encoded, false);
   14905           0 :             buf.append(encoded);
   14906           0 :                 buf.append(" </" + name + "> ")
   14907             :                 ;
   14908           0 :         }
   14909             :         
   14910             :         
   14911           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<Speed> > > >data, const string &name, string &buf){
   14912           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   14913           0 :                 string encoded;
   14914             :                 
   14915           0 :                 buf.append("<" + name + "> ");
   14916           0 :                 int ndim = 3;
   14917           0 :                 int dim1 = data.size();
   14918           0 :                 int dim2 = data.at(0).size();
   14919           0 :                 int dim3 = data.at(0).at(0).size();
   14920           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   14921             :                 
   14922           0 :                 oss.write((char *)&ndim, sizeof(int));
   14923           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   14924           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   14925           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   14926           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   14927           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   14928           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   14929           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   14930           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   14931             :                 
   14932           0 :                                         double v = data.at(i).at(j).at(k).at(l).get();
   14933             :                 
   14934           0 :                                 oss.write((char *) &v, sizeof(v));
   14935             :                                 }
   14936             : 
   14937           0 :                 Base64 b64;
   14938           0 :             b64.encode(oss.str(), encoded, false);
   14939           0 :             buf.append(encoded);
   14940           0 :                 buf.append(" </" + name + "> ")
   14941             :                 ;
   14942           0 :         }
   14943             :         
   14944             :         
   14945             : #ifndef Double_CPP
   14946             :                 
   14947             : #define Double_CPP double       
   14948             :                 
   14949             : #endif
   14950             :         
   14951             : 
   14952             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   14953             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   14954             :                 
   14955             :     
   14956           0 :         vector<Speed>& Parser::get1DSpeedFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<Speed>& attribute)
   14957             :         {
   14958           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   14959           0 :                 if (xmlField.length() == 0) {
   14960           0 :                         throw ConversionException("Error: Field \"" + 
   14961           0 :                                         name + "\": Invalid XML syntax", tableName);
   14962             :                 }
   14963             :                 
   14964           0 :                 string decodedString;
   14965           0 :                 Base64 b64;
   14966           0 :                 b64.decode(xmlField, decodedString);
   14967             :                 
   14968           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   14969           0 :                 iss.str(decodedString);
   14970             :                 
   14971           0 :                 attribute.clear();
   14972             :                 
   14973           0 :                 unsigned int ndim = 0;
   14974             :                 //iss.read((char *)&ndim, sizeof(ndim));
   14975           0 :                 TRYREAD(iss,ndim);
   14976             :                 
   14977           0 :                 unsigned int dim1 = 0;
   14978             :                 //iss.read((char *)&dim1, sizeof(dim1));
   14979           0 :                 TRYREAD(iss,dim1);
   14980           0 :                 if (ndim != 1) {
   14981           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   14982             :                         }
   14983             :                 
   14984           0 :                 attribute.reserve(dim1);
   14985             :                 
   14986             :                 Double_CPP v;
   14987           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   14988             :                         //iss.read((char*) &v, sizeof(v));
   14989           0 :                         TRYREAD(iss,v);
   14990             :                 
   14991           0 :                         attribute.push_back(Speed(v));
   14992             :                         
   14993             :                 }
   14994           0 :                 return attribute;
   14995           0 :         }
   14996             :         
   14997             :          
   14998           0 :         vector <vector<Speed> >& Parser::get2DSpeedFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<Speed> >& attribute)
   14999             :         {
   15000           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   15001           0 :                 if (xmlField.length() == 0) {
   15002           0 :                         throw ConversionException("Error: Field \"" + 
   15003           0 :                                         name + "\": Invalid XML syntax", tableName);
   15004             :                 }
   15005             :                 
   15006           0 :                 string decodedString;
   15007           0 :                 Base64 b64;
   15008           0 :                 b64.decode(xmlField, decodedString);
   15009             :                 
   15010           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   15011           0 :                 iss.str(decodedString);
   15012             :                 
   15013           0 :                 attribute.clear();
   15014             :                 
   15015           0 :                 unsigned int ndim = 0;
   15016             :                 //iss.read((char *)&ndim, sizeof(ndim));
   15017           0 :                 TRYREAD(iss,ndim);
   15018             :                 
   15019           0 :                 if (ndim != 2) {
   15020           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   15021             :                 }
   15022             :         
   15023           0 :                 unsigned int dim1 = 0;
   15024             :                 //iss.read((char *)&dim1, sizeof(dim1));
   15025           0 :                 TRYREAD(iss,dim1);
   15026             :                 
   15027           0 :                 unsigned int dim2 = 0;
   15028             :                 //iss.read((char *)&dim2, sizeof(dim2));
   15029           0 :                 TRYREAD(iss,dim2);
   15030             :                 
   15031           0 :                 attribute.reserve(dim1);
   15032             :                 
   15033             :                 Double_CPP v;
   15034           0 :                 vector<Speed> aux2;
   15035           0 :                 aux2.reserve(dim2);
   15036           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   15037           0 :                         aux2.clear();
   15038           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   15039             :                                 //iss.read((char*) &v, sizeof(v));
   15040           0 :                                 TRYREAD(iss,v);
   15041             :                 
   15042           0 :                                 aux2.push_back(Speed(v));
   15043             :                 
   15044             :                         }
   15045           0 :                         attribute.push_back(aux2);      
   15046             :                 }
   15047           0 :                 return attribute;
   15048           0 :         }
   15049             :                 
   15050             :         
   15051           0 :         vector <vector <vector<Speed> > >& Parser::get3DSpeedFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<Speed> > >& attribute)
   15052             :         {
   15053           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   15054           0 :                 if (xmlField.length() == 0) {
   15055           0 :                         throw ConversionException("Error: Field \"" + 
   15056           0 :                                         name + "\": Invalid XML syntax", tableName);
   15057             :                 }
   15058             :                 
   15059           0 :                 string decodedString;
   15060           0 :                 Base64 b64;
   15061           0 :                 b64.decode(xmlField, decodedString);
   15062             :                 
   15063           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   15064           0 :                 iss.str(decodedString);
   15065             :                 
   15066           0 :                 attribute.clear();
   15067             :                 
   15068           0 :                 unsigned int ndim = 0;
   15069             :                 //iss.read((char *)&ndim, sizeof(ndim));
   15070           0 :                 TRYREAD(iss, ndim);     
   15071           0 :                 if (ndim != 3) {
   15072           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   15073             :                 }
   15074             :                                 
   15075           0 :                 unsigned int dim1 = 0;
   15076             :                 //iss.read((char *)&dim1, sizeof(dim1));
   15077           0 :                 TRYREAD(iss,dim1);
   15078             :                 
   15079           0 :                 unsigned int dim2 = 0;
   15080             :                 //iss.read((char *)&dim2, sizeof(dim2));
   15081           0 :                 TRYREAD(iss,dim2);
   15082             :                 
   15083           0 :                 unsigned int dim3 = 0;
   15084             :                 //iss.read((char *)&dim2, sizeof(dim3));
   15085           0 :                 TRYREAD(iss,dim3);
   15086             :                 
   15087           0 :                 attribute.reserve(dim1);
   15088             :                 
   15089             :                 Double_CPP v;
   15090           0 :                 vector <vector<Speed> > aux2;
   15091           0 :                 vector<Speed> aux3;               
   15092           0 :                 aux2.reserve(dim2);
   15093           0 :                 aux3.reserve(dim3);
   15094             :                 
   15095           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   15096           0 :                         aux2.clear();
   15097           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   15098           0 :                                 aux3.clear();
   15099           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   15100             :                                         //iss.read((char*) &v, sizeof(v));
   15101           0 :                                         TRYREAD(iss,v);
   15102             :                 
   15103           0 :                                         aux3.push_back(Speed(v));
   15104             :                 
   15105             :                                 }
   15106           0 :                                 aux2.push_back(aux3);
   15107             :                         }
   15108           0 :                         attribute.push_back(aux2);      
   15109             :                 }
   15110           0 :                 return attribute;
   15111             :                 ;
   15112           0 :         }
   15113             :         
   15114             :         
   15115           0 :         vector <vector <vector <vector<Speed> > > >& Parser::get4DSpeedFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<Speed> > > >& attribute)
   15116             :         {
   15117           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   15118           0 :                 if (xmlField.length() == 0) {
   15119           0 :                         throw ConversionException("Error: Field \"" + 
   15120           0 :                                         name + "\": Invalid XML syntax", tableName);
   15121             :                 }
   15122             :                 
   15123           0 :                 string decodedString;
   15124           0 :                 Base64 b64;
   15125           0 :                 b64.decode(xmlField, decodedString);
   15126             :                 
   15127           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   15128           0 :                 iss.str(decodedString);
   15129             :                 
   15130           0 :                 attribute.clear();
   15131             :                 
   15132           0 :                 unsigned int ndim = 0;
   15133             :                 //iss.read((char *)&ndim, sizeof(ndim));
   15134           0 :                 TRYREAD(iss, ndim);     
   15135           0 :                 if (ndim != 4) {
   15136           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   15137             :                 }
   15138             :                                 
   15139           0 :                 unsigned int dim1 = 0;
   15140             :                 //iss.read((char *)&dim1, sizeof(dim1));
   15141           0 :                 TRYREAD(iss,dim1);
   15142             :                 
   15143           0 :                 unsigned int dim2 = 0;
   15144             :                 //iss.read((char *)&dim2, sizeof(dim2));
   15145           0 :                 TRYREAD(iss,dim2);
   15146             :                 
   15147           0 :                 unsigned int dim3 = 0;
   15148             :                 //iss.read((char *)&dim2, sizeof(dim3));
   15149           0 :                 TRYREAD(iss,dim3);
   15150             :                 
   15151           0 :                 unsigned int dim4 = 0;
   15152             :                 //iss.read((char *)&dim2, sizeof(dim3));
   15153           0 :                 TRYREAD(iss,dim3);
   15154             :                 
   15155           0 :                 attribute.reserve(dim1);
   15156             :                 
   15157             :                 Double_CPP v;
   15158           0 :                 vector <vector <vector<Speed> > > aux2;
   15159           0 :                 vector <vector<Speed> > aux3;
   15160           0 :                 vector<Speed> aux4;               
   15161           0 :                 aux2.reserve(dim2);
   15162           0 :                 aux3.reserve(dim3);
   15163           0 :                 aux4.reserve(dim4);
   15164             :                 
   15165           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   15166           0 :                         aux2.clear();
   15167           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   15168           0 :                                 aux3.clear();
   15169           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   15170           0 :                                         aux4.clear();
   15171           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   15172             :                                         //iss.read((char*) &v, sizeof(v));
   15173           0 :                                                 TRYREAD(iss,v);
   15174             :                 
   15175           0 :                                                 aux4.push_back(Speed(v));
   15176             :                 
   15177             :                                         }
   15178           0 :                                         aux3.push_back(aux4);
   15179             :                                 }
   15180           0 :                                 aux2.push_back(aux3);
   15181             :                         }
   15182           0 :                         attribute.push_back(aux2);      
   15183             :                 }
   15184           0 :                 return attribute;
   15185             :                 ;
   15186           0 :         }
   15187             :         
   15188             :         
   15189             : 
   15190             :         
   15191             :         
   15192             : 
   15193             :         
   15194             :         
   15195             :         
   15196             :         
   15197           0 :         void Parser::toXMLBase64(vector<Temperature> data, const string &name, string &buf){
   15198           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   15199           0 :                 string encoded;
   15200             :                 
   15201           0 :                 buf.append("<" + name + "> ");
   15202           0 :                 int ndim = 1;
   15203           0 :                 int dim1 = data.size();
   15204             :  
   15205           0 :                 oss.write((char *)&ndim, sizeof(int));
   15206           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   15207             : 
   15208           0 :                 for (unsigned int i = 0; i < data.size(); i++)  {
   15209             :                 
   15210           0 :                  double v = data.at(i).get();
   15211             :                 
   15212           0 :                 oss.write((char *) &v, sizeof(v));
   15213             :         }
   15214             : 
   15215           0 :                 Base64 b64;
   15216           0 :             b64.encode(oss.str(), encoded, false);
   15217           0 :             buf.append(encoded);
   15218           0 :                 buf.append(" </" + name + "> ");      
   15219           0 :         }
   15220             :         
   15221             :         
   15222           0 :         void Parser::toXMLBase64(vector< vector<Temperature> > data, const string &name, string &buf){
   15223           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   15224           0 :                 string encoded;
   15225             :                 
   15226           0 :                 buf.append("<" + name + "> ");
   15227           0 :                 int ndim = 2;
   15228           0 :                 int dim1 = data.size();
   15229           0 :                 int dim2 = data.at(0).size();
   15230             : 
   15231           0 :                 oss.write((char *)&ndim, sizeof(int));
   15232           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   15233           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   15234           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   15235           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) {
   15236             :                 
   15237           0 :                         double v = data.at(i).at(j).get();
   15238             :                 
   15239           0 :                         oss.write((char *) &v, sizeof(v));
   15240             :                 }
   15241             : 
   15242           0 :                 Base64 b64;
   15243           0 :             b64.encode(oss.str(), encoded, false);
   15244           0 :             buf.append(encoded);
   15245           0 :                 buf.append(" </" + name + "> ")
   15246             :                 ;
   15247           0 :         }
   15248             :         
   15249             :         
   15250           0 :         void Parser::toXMLBase64(vector< vector< vector<Temperature> > > data, const string &name, string &buf){
   15251           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   15252           0 :                 string encoded;
   15253             :                 
   15254           0 :                 buf.append("<" + name + "> ");
   15255           0 :                 int ndim = 3;
   15256           0 :                 int dim1 = data.size();
   15257           0 :                 int dim2 = data.at(0).size();
   15258           0 :                 int dim3 = data.at(0).at(0).size();
   15259             : 
   15260           0 :                 oss.write((char *)&ndim, sizeof(int));
   15261           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   15262           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   15263           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   15264           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   15265           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   15266           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++){
   15267             :                 
   15268           0 :                                 double v = data.at(i).at(j).at(k).get();
   15269             :                 
   15270           0 :                                 oss.write((char *) &v, sizeof(v));
   15271             :                         }
   15272             : 
   15273           0 :                 Base64 b64;
   15274           0 :             b64.encode(oss.str(), encoded, false);
   15275           0 :             buf.append(encoded);
   15276           0 :                 buf.append(" </" + name + "> ")
   15277             :                 ;
   15278           0 :         }
   15279             :         
   15280             :         
   15281           0 :         void Parser::toXMLBase64(vector<vector< vector< vector<Temperature> > > >data, const string &name, string &buf){
   15282           0 :                 stringstream oss(stringstream::out | stringstream::binary);
   15283           0 :                 string encoded;
   15284             :                 
   15285           0 :                 buf.append("<" + name + "> ");
   15286           0 :                 int ndim = 3;
   15287           0 :                 int dim1 = data.size();
   15288           0 :                 int dim2 = data.at(0).size();
   15289           0 :                 int dim3 = data.at(0).at(0).size();
   15290           0 :                 int dim4 = data.at(0).at(0).at(0).size();
   15291             :                 
   15292           0 :                 oss.write((char *)&ndim, sizeof(int));
   15293           0 :                 oss.write((char *)&dim1, sizeof(dim1));
   15294           0 :                 oss.write((char *)&dim2, sizeof(dim2));
   15295           0 :                 oss.write((char *)&dim3, sizeof(dim3));
   15296           0 :                 oss.write((char *)&dim4, sizeof(dim4));
   15297           0 :                 for (unsigned int i = 0; i < data.size(); i++) 
   15298           0 :                 for (unsigned int j = 0; j < data.at(0).size(); j++) 
   15299           0 :                         for (unsigned int k = 0; k < data.at(0).at(0).size(); k++)
   15300           0 :                                 for (unsigned int l = 0; l < data.at(0).at(0).at(0).size(); l++){
   15301             :                 
   15302           0 :                                         double v = data.at(i).at(j).at(k).at(l).get();
   15303             :                 
   15304           0 :                                 oss.write((char *) &v, sizeof(v));
   15305             :                                 }
   15306             : 
   15307           0 :                 Base64 b64;
   15308           0 :             b64.encode(oss.str(), encoded, false);
   15309           0 :             buf.append(encoded);
   15310           0 :                 buf.append(" </" + name + "> ")
   15311             :                 ;
   15312           0 :         }
   15313             :         
   15314             :         
   15315             : #ifndef Double_CPP
   15316             :                 
   15317             : #define Double_CPP double       
   15318             :                 
   15319             : #endif
   15320             :         
   15321             : 
   15322             :         #define TRYREAD(_stream_, _value_) _stream_.read((char*) &(_value_), sizeof(_value_));      \
   15323             :         if (_stream_.bad()) throw ConversionException("I/O error during read of " + name, tableName);
   15324             :                 
   15325             :     
   15326           0 :         vector<Temperature>& Parser::get1DTemperatureFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector<Temperature>& attribute)
   15327             :         {
   15328           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   15329           0 :                 if (xmlField.length() == 0) {
   15330           0 :                         throw ConversionException("Error: Field \"" + 
   15331           0 :                                         name + "\": Invalid XML syntax", tableName);
   15332             :                 }
   15333             :                 
   15334           0 :                 string decodedString;
   15335           0 :                 Base64 b64;
   15336           0 :                 b64.decode(xmlField, decodedString);
   15337             :                 
   15338           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   15339           0 :                 iss.str(decodedString);
   15340             :                 
   15341           0 :                 attribute.clear();
   15342             :                 
   15343           0 :                 unsigned int ndim = 0;
   15344             :                 //iss.read((char *)&ndim, sizeof(ndim));
   15345           0 :                 TRYREAD(iss,ndim);
   15346             :                 
   15347           0 :                 unsigned int dim1 = 0;
   15348             :                 //iss.read((char *)&dim1, sizeof(dim1));
   15349           0 :                 TRYREAD(iss,dim1);
   15350           0 :                 if (ndim != 1) {
   15351           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 1.", tableName);
   15352             :                         }
   15353             :                 
   15354           0 :                 attribute.reserve(dim1);
   15355             :                 
   15356             :                 Double_CPP v;
   15357           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   15358             :                         //iss.read((char*) &v, sizeof(v));
   15359           0 :                         TRYREAD(iss,v);
   15360             :                 
   15361           0 :                         attribute.push_back(Temperature(v));
   15362             :                         
   15363             :                 }
   15364           0 :                 return attribute;
   15365           0 :         }
   15366             :         
   15367             :          
   15368           0 :         vector <vector<Temperature> >& Parser::get2DTemperatureFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector<Temperature> >& attribute)
   15369             :         {
   15370           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   15371           0 :                 if (xmlField.length() == 0) {
   15372           0 :                         throw ConversionException("Error: Field \"" + 
   15373           0 :                                         name + "\": Invalid XML syntax", tableName);
   15374             :                 }
   15375             :                 
   15376           0 :                 string decodedString;
   15377           0 :                 Base64 b64;
   15378           0 :                 b64.decode(xmlField, decodedString);
   15379             :                 
   15380           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   15381           0 :                 iss.str(decodedString);
   15382             :                 
   15383           0 :                 attribute.clear();
   15384             :                 
   15385           0 :                 unsigned int ndim = 0;
   15386             :                 //iss.read((char *)&ndim, sizeof(ndim));
   15387           0 :                 TRYREAD(iss,ndim);
   15388             :                 
   15389           0 :                 if (ndim != 2) {
   15390           0 :                         throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 2.", tableName);
   15391             :                 }
   15392             :         
   15393           0 :                 unsigned int dim1 = 0;
   15394             :                 //iss.read((char *)&dim1, sizeof(dim1));
   15395           0 :                 TRYREAD(iss,dim1);
   15396             :                 
   15397           0 :                 unsigned int dim2 = 0;
   15398             :                 //iss.read((char *)&dim2, sizeof(dim2));
   15399           0 :                 TRYREAD(iss,dim2);
   15400             :                 
   15401           0 :                 attribute.reserve(dim1);
   15402             :                 
   15403             :                 Double_CPP v;
   15404           0 :                 vector<Temperature> aux2;
   15405           0 :                 aux2.reserve(dim2);
   15406           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   15407           0 :                         aux2.clear();
   15408           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   15409             :                                 //iss.read((char*) &v, sizeof(v));
   15410           0 :                                 TRYREAD(iss,v);
   15411             :                 
   15412           0 :                                 aux2.push_back(Temperature(v));
   15413             :                 
   15414             :                         }
   15415           0 :                         attribute.push_back(aux2);      
   15416             :                 }
   15417           0 :                 return attribute;
   15418           0 :         }
   15419             :                 
   15420             :         
   15421           0 :         vector <vector <vector<Temperature> > >& Parser::get3DTemperatureFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector <vector <vector<Temperature> > >& attribute)
   15422             :         {
   15423           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   15424           0 :                 if (xmlField.length() == 0) {
   15425           0 :                         throw ConversionException("Error: Field \"" + 
   15426           0 :                                         name + "\": Invalid XML syntax", tableName);
   15427             :                 }
   15428             :                 
   15429           0 :                 string decodedString;
   15430           0 :                 Base64 b64;
   15431           0 :                 b64.decode(xmlField, decodedString);
   15432             :                 
   15433           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   15434           0 :                 iss.str(decodedString);
   15435             :                 
   15436           0 :                 attribute.clear();
   15437             :                 
   15438           0 :                 unsigned int ndim = 0;
   15439             :                 //iss.read((char *)&ndim, sizeof(ndim));
   15440           0 :                 TRYREAD(iss, ndim);     
   15441           0 :                 if (ndim != 3) {
   15442           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 3.", tableName);
   15443             :                 }
   15444             :                                 
   15445           0 :                 unsigned int dim1 = 0;
   15446             :                 //iss.read((char *)&dim1, sizeof(dim1));
   15447           0 :                 TRYREAD(iss,dim1);
   15448             :                 
   15449           0 :                 unsigned int dim2 = 0;
   15450             :                 //iss.read((char *)&dim2, sizeof(dim2));
   15451           0 :                 TRYREAD(iss,dim2);
   15452             :                 
   15453           0 :                 unsigned int dim3 = 0;
   15454             :                 //iss.read((char *)&dim2, sizeof(dim3));
   15455           0 :                 TRYREAD(iss,dim3);
   15456             :                 
   15457           0 :                 attribute.reserve(dim1);
   15458             :                 
   15459             :                 Double_CPP v;
   15460           0 :                 vector <vector<Temperature> > aux2;
   15461           0 :                 vector<Temperature> aux3;         
   15462           0 :                 aux2.reserve(dim2);
   15463           0 :                 aux3.reserve(dim3);
   15464             :                 
   15465           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   15466           0 :                         aux2.clear();
   15467           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   15468           0 :                                 aux3.clear();
   15469           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   15470             :                                         //iss.read((char*) &v, sizeof(v));
   15471           0 :                                         TRYREAD(iss,v);
   15472             :                 
   15473           0 :                                         aux3.push_back(Temperature(v));
   15474             :                 
   15475             :                                 }
   15476           0 :                                 aux2.push_back(aux3);
   15477             :                         }
   15478           0 :                         attribute.push_back(aux2);      
   15479             :                 }
   15480           0 :                 return attribute;
   15481             :                 ;
   15482           0 :         }
   15483             :         
   15484             :         
   15485           0 :         vector <vector <vector <vector<Temperature> > > >& Parser::get4DTemperatureFromBase64(const string &name, const string &tableName, const string &xmlDoc, vector< vector <vector <vector<Temperature> > > >& attribute)
   15486             :         {
   15487           0 :                 string xmlField = Parser::getField(xmlDoc,name);
   15488           0 :                 if (xmlField.length() == 0) {
   15489           0 :                         throw ConversionException("Error: Field \"" + 
   15490           0 :                                         name + "\": Invalid XML syntax", tableName);
   15491             :                 }
   15492             :                 
   15493           0 :                 string decodedString;
   15494           0 :                 Base64 b64;
   15495           0 :                 b64.decode(xmlField, decodedString);
   15496             :                 
   15497           0 :                 stringstream iss(stringstream::in | stringstream::binary);
   15498           0 :                 iss.str(decodedString);
   15499             :                 
   15500           0 :                 attribute.clear();
   15501             :                 
   15502           0 :                 unsigned int ndim = 0;
   15503             :                 //iss.read((char *)&ndim, sizeof(ndim));
   15504           0 :                 TRYREAD(iss, ndim);     
   15505           0 :                 if (ndim != 4) {
   15506           0 :                                 throw ConversionException("Error while decoding Base64 representation of \"" + name + "\" : found " + Integer::toString(ndim) + " for the number of dimensions, expecting 4.", tableName);
   15507             :                 }
   15508             :                                 
   15509           0 :                 unsigned int dim1 = 0;
   15510             :                 //iss.read((char *)&dim1, sizeof(dim1));
   15511           0 :                 TRYREAD(iss,dim1);
   15512             :                 
   15513           0 :                 unsigned int dim2 = 0;
   15514             :                 //iss.read((char *)&dim2, sizeof(dim2));
   15515           0 :                 TRYREAD(iss,dim2);
   15516             :                 
   15517           0 :                 unsigned int dim3 = 0;
   15518             :                 //iss.read((char *)&dim2, sizeof(dim3));
   15519           0 :                 TRYREAD(iss,dim3);
   15520             :                 
   15521           0 :                 unsigned int dim4 = 0;
   15522             :                 //iss.read((char *)&dim2, sizeof(dim3));
   15523           0 :                 TRYREAD(iss,dim3);
   15524             :                 
   15525           0 :                 attribute.reserve(dim1);
   15526             :                 
   15527             :                 Double_CPP v;
   15528           0 :                 vector <vector <vector<Temperature> > > aux2;
   15529           0 :                 vector <vector<Temperature> > aux3;
   15530           0 :                 vector<Temperature> aux4;         
   15531           0 :                 aux2.reserve(dim2);
   15532           0 :                 aux3.reserve(dim3);
   15533           0 :                 aux4.reserve(dim4);
   15534             :                 
   15535           0 :                 for (unsigned int i = 0; i < dim1; i++) {
   15536           0 :                         aux2.clear();
   15537           0 :                         for (unsigned int j = 0; j < dim2; j++) {
   15538           0 :                                 aux3.clear();
   15539           0 :                                 for (unsigned int k = 0; k < dim3; k++) {
   15540           0 :                                         aux4.clear();
   15541           0 :                                         for (unsigned int l = 0; l < dim4; l++) {
   15542             :                                         //iss.read((char*) &v, sizeof(v));
   15543           0 :                                                 TRYREAD(iss,v);
   15544             :                 
   15545           0 :                                                 aux4.push_back(Temperature(v));
   15546             :                 
   15547             :                                         }
   15548           0 :                                         aux3.push_back(aux4);
   15549             :                                 }
   15550           0 :                                 aux2.push_back(aux3);
   15551             :                         }
   15552           0 :                         attribute.push_back(aux2);      
   15553             :                 }
   15554           0 :                 return attribute;
   15555             :                 ;
   15556           0 :         }
   15557             :         
   15558             :         
   15559             : 
   15560             : 
   15561             :  } // End namespace asdm
   15562             :  

Generated by: LCOV version 1.16