CASToR  1.0
Tomographic Reconstruction (PET/SPECT)
gOptions.cc
Go to the documentation of this file.
00001 
00002 /*
00003   Implementation of class file gOptions.hh
00004 
00005   - separators: X
00006   - doxygen: X
00007   - default initialization: none
00008   - CASTOR_DEBUG: none
00009   - CASTOR_VERBOSE: none (no verbose member variable)
00010 */
00011 
00020 #include "gVariables.hh"
00021 #include "gOptions.hh"
00022 #include "sOutputManager.hh"
00023 // For error handling
00024 #include <errno.h> 
00025 #include <limits.h>
00026 #ifdef _WIN32
00027 // Avoid compilation errors due to mix up between std::min()/max() and
00028 // min max macros
00029 #undef min
00030 #undef max
00031 #endif
00032  
00033 // =====================================================================
00034 // ---------------------------------------------------------------------
00035 // ---------------------------------------------------------------------
00036 // =====================================================================
00037 /*
00038   \fn ReadStringOption
00039   \param a_input : string to parse
00040   \param ap_return : (templated) array in which the parsed elements will be returned
00041   \param a_nbElts : a number of elements to parse
00042   \param sep : the separator (usually comma)
00043   \param a_option : string indicating from where the function has been called
00044   \brief Parse the 'a_input' string corresponding to the 'a_option' into 'a_nbElts' elements, using the 'sep' separator. 
00045          The results are returned in the templated 'ap_return' dynamic templated array. 
00046          Call "ConvertFromString()" to perform the correct conversion depending on the type of the data to convert
00047   \return 0 if success, and positive value otherwise.
00048 */
00049 template<class T> 
00050 int ReadStringOption(const string& a_input, T* ap_return, int a_nbElts, const string& sep, const string& a_option)
00051 {
00052 
00053   size_t pos = 0;
00054   size_t pos2 = a_input.find_first_of(sep, 0);
00055 
00056   if (a_nbElts>1 && pos2 == string::npos)
00057   {
00058     Cerr("***** gOptions::ReadStringOption() -> Error : '" << sep << "' not found in option: " << a_option << endl);
00059     return 1;
00060   }
00061   else
00062   {
00063     for (int i=0 ; i<a_nbElts ; i++)
00064     {
00065       string elt = a_input.substr(pos, pos2-pos); //substr(position, nbEltToRead)
00066       
00067       if(ConvertFromString(elt, &ap_return[i]))
00068       {
00069         Cerr("***** gOptions::ReadStringOption() -> Error when trying to read input data for option: " << a_option <<  endl);
00070         return 1;
00071       } 
00072 
00073       pos = pos2+1;
00074       pos2 = a_input.find_first_of(sep, pos);
00075 
00076       // TODO Errors in case of too many/few elements in the string
00077     }
00078   }
00079   return 0;
00080 }
00081 
00082 
00083 
00084 
00085 // =====================================================================
00086 // ---------------------------------------------------------------------
00087 // ---------------------------------------------------------------------
00088 // =====================================================================
00089 /*
00090   \fn ReadDataASCIIFile
00091   \param a_file : string containing the path to the ASCII file
00092   \param a_keyword : key related to the data we want to recover
00093   \param ap_return : templated array in which the data will be returned
00094                      the recovered data will be converted to its type
00095                      its size should be equal to the number of elts to recover
00096   \param a_nbElts : number of elements to recover
00097   \param a_mandatoryFlag : boolean indicating the data to recover is 
00098                            mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
00099                         or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
00100   \brief Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter 
00101          and return the corresponding value(s) in the "ap_return" templated array.
00102          This function expects the following parsing :
00103          KEY : elt1,elt2,...,eltN
00104   \details This function assumes the following separators :
00105            ":" is used as separator between the keyworld and the value
00106            "#" is used for comment. Every following characters will be discarded
00107            "," is used to separate elements if more than one are required
00108   \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
00109 */
00110 template<class T> 
00111 int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T* ap_return, int a_nbElts, bool a_mandatoryFlag)
00112 {
00113   ifstream input_file(a_file.c_str(), ios::in);
00114   string line;
00115   string sep = ":";
00116   string sep_comment = "#";
00117   string sep_elt = ",";
00118   
00119   // Check file
00120   if (input_file)
00121   {
00122     while(!input_file.eof())
00123     {
00124       getline(input_file, line);
00125   
00126       //remove comment
00127       if (line.find(sep_comment) != string::npos) line = line.substr(0, line.find_first_of(sep_comment)) ;
00128       
00129       if (line.find(a_keyword) != string::npos)
00130       //if (line.compare(a_keyword) == 0)
00131       {
00132         //remove field in string
00133         line = line.substr(line.find_first_of(sep)+1);
00134 
00135         //clear every spaces in the line string;
00136         //line.erase(remove_if(line.begin(), line.end(), (int(*)(int))isspace), line.end()); // Explicit type (int(*)(int)) is required to tell compiler which function to take the address of.
00137 
00138         // Erase all blank stuff before first character
00139         line.erase(0, line.find_first_not_of(" !\t\r\n")); // Erase all blank stuff before first character
00140         line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
00141         
00142         size_t pos = 0;
00143         size_t pos2 = line.find_first_of(sep_elt, pos);
00144 
00145         // Check if separators were found
00146         if (a_nbElts>1 && pos2 == string::npos)
00147         {
00148           Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
00149           return 1;
00150         }
00151         else // Read one element, or several (a_nbElts) elements separated with ','
00152         {
00153           for (int i=0 ; i<a_nbElts ; i++)
00154           {
00155             // Check if we reach the end of the line before initializing all elements
00156             if(pos<0)
00157             {
00158               Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
00159               Cerr("*****                                  Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
00160               return 1;
00161             }
00162             
00163             // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
00164             string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
00165             
00166             if (ConvertFromString(elt, &ap_return[i]))
00167             {
00168               Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
00169               return 1;
00170             }
00171             
00172             
00173             //pos = pos2+1;
00174             // return -1 if pos2 not found, meaning we reach the end of the line
00175             pos = (pos2<0) ? -1 : pos2+1 ;
00176             pos2 = line.find_first_of(sep_elt, pos);
00177             
00178           }
00179         }
00180         return 0;
00181       }
00182   
00183     }
00184     // Throw an error message if the tag is mandatory
00185     if (a_mandatoryFlag == true) 
00186     {
00187       Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
00188       return KEYWORD_MANDATORY_NOT_FOUND;
00189     }
00190     else
00191     {
00192       return KEYWORD_OPTIONAL_NOT_FOUND;
00193     }
00194   }
00195   else
00196   {
00197     Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '"<< a_file << "' !" << endl);
00198     return 1;
00199   }
00200 }
00201 
00202 
00203 
00204 
00205 // =====================================================================
00206 // ---------------------------------------------------------------------
00207 // ---------------------------------------------------------------------
00208 // =====================================================================
00209 /*
00210   \fn ReadDataASCIIFile
00211   \param a_file : string containing the path to the ASCII file
00212   \param a_keyword : key related to the data we want to recover
00213   \param ap_return : templated array in which the data will be returned
00214                      the recovered data will be converted to its type
00215                      its size should be equal to the nb of lines*nb of elts to recover
00216   \param a_nbElts : number of elements to recover (on each line)
00217   \param a_nbLines : number of lines to recover
00218   \param a_mandatoryFlag : boolean indicating the data to recover is 
00219                            mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
00220                         or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
00221   \brief Look for "a_nbLines" lines of "a_nbElts" elts in the 'a_file' file matching the "a_keyword" string 
00222          passed as parameter and return the corresponding value(s) in the "ap_return" templated 1D array.
00223          This function expects the following parsing :
00224          KEY : 
00225          line1 : elt1,elt2,...,eltN
00226          line2 : elt1,elt2,...,eltN
00227          (...)
00228          lineN : elt1,elt2,...,eltN
00229   \details This function assumes the following separators :
00230            ":" is used as separator between the keyworld and the value
00231            "#" is used for comment. Every following characters will be discarded
00232            "," is used to separate elements if more than one are required
00233   \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
00234 */
00235 template<class T> 
00236 int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag)
00237 {  
00238   ifstream input_file(a_file.c_str(), ios::in);
00239   string line;
00240   string sep = ":";
00241   string sep_comment = "#";
00242   string sep_elt = ",";
00243 
00244   // Check file
00245   if (input_file)
00246   {
00247     while (!input_file.eof())
00248     {
00249       getline(input_file, line);
00250   
00251       //remove comment
00252       if (line.find(sep_comment)) line = line.substr(0, line.find_first_of(sep_comment));
00253   
00254       if (line.find(a_keyword) != string::npos)
00255       //if (line.compare(a_keyword) == 0)
00256       {
00257         for (int l=0 ; l<a_nbLines ; l++)
00258         {
00259           getline(input_file, line);
00260           //remove field in string
00261           line = line.substr(line.find_first_of(sep)+1);
00262   
00263           //clear the space before the first element in the line string;
00264           //line.erase(remove_if(line.begin(), line.end(), (int(*)(int))isspace), line.end()); // Explicit type (int(*)(int)) is required to tell compiler which function to take the address of.
00265 
00266           // Erase all blank stuff before first character
00267           line.erase(0, line.find_first_not_of(" !\t\r\n")); // Erase all blank stuff before first character
00268           line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
00269         
00270           size_t pos = 0;
00271           size_t pos2 = line.find_first_of(sep_elt, pos);
00272               
00273           // Check if separators were found
00274           if (a_nbElts>1 && pos2 == string::npos)
00275           {
00276             Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
00277             return 1;
00278           }
00279           else // Read one element, or several (a_nbElts) elements separated with ','
00280           {
00281             for (int i=0 ; i<a_nbElts ; i++)
00282             {
00283               // Check if we reach the end of the line before initializing all elements
00284               if(pos<0)
00285               {
00286                 Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
00287                 Cerr("*****                                  Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
00288                 return 1;
00289               }
00290               
00291               // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
00292               string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
00293     
00294               if (ConvertFromString(elt, &ap_return[l*a_nbElts+i]))
00295               {
00296                 Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file " << a_file <<  endl);
00297                 return 1;
00298               } 
00299     
00300               //pos = pos2+1;
00301               // return -1 if pos2 not found, meaning we reach the end of the line
00302               pos = (pos2<0) ? -1 : pos2+1 ;
00303               pos2 = line.find_first_of(sep_elt, pos);
00304             }
00305           }
00306         }  
00307         return 0; 
00308       }
00309     }
00310     
00311     // Throw an error message if the tag is mandatory
00312     if (a_mandatoryFlag == true) 
00313     {
00314       Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
00315       return KEYWORD_MANDATORY_NOT_FOUND;
00316     }
00317     else
00318     {
00319       return KEYWORD_OPTIONAL_NOT_FOUND;
00320     }
00321   }
00322   else
00323   {
00324     Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '" << a_file << "' !" << endl);
00325     return 1;
00326   }
00327 }
00328 
00329 
00330 
00331 
00332 // =====================================================================
00333 // ---------------------------------------------------------------------
00334 // ---------------------------------------------------------------------
00335 // =====================================================================
00336 /*
00337   \fn ReadDataASCIIFile
00338   \param a_file : string containing the path to the ASCII file
00339   \param a_keyword : key related to the data we want to recover
00340   \param a2p_return : 2D templated array in which the data will be returned
00341                      the recovered data will be converted to its type
00342                      its size should be equal [nb of lines][nb of elts to recover]
00343   \param a_nbElts : number of elements to recover (on each line)
00344   \param a_nbLines : number of lines to recover
00345   \param a_mandatoryFlag : boolean indicating the data to recover is 
00346                            mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
00347                         or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
00348   \brief Look for "a_nbLines" lines of "a_nbElts" elts in the 'a_file' file matching the "a_keyword" string 
00349          passed as parameter and return the corresponding value(s) in the "a2p_return" 2D array.
00350          The first and second dimensions of "a2p_return" correspond to the line and elements respectively
00351          This function expects the following parsing :
00352          KEY : 
00353          line1 : elt1,elt2,...,eltN
00354          line2 : elt1,elt2,...,eltN
00355          (...)
00356          lineN : elt1,elt2,...,eltN
00357   \details This function assumes the following separators :
00358            ":" is used as separator between the keyworld and the value
00359            "#" is used for comment. Every following characters will be discarded
00360            "," is used to separate elements if more than one are required
00361   \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
00362 */
00363 template<class T> 
00364 int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag)
00365 {  
00366   ifstream input_file(a_file.c_str(), ios::in);
00367   string line;
00368   string sep = ":";
00369   string sep_comment = "#";
00370   string sep_elt = ",";
00371 
00372   // Check file
00373   if (input_file)
00374   {
00375     while (!input_file.eof())
00376     {
00377       getline(input_file, line);
00378   
00379       //remove comment
00380       if (line.find(sep_comment)) line = line.substr(0, line.find_first_of(sep_comment));
00381   
00382       if (line.find(a_keyword) != string::npos)
00383       //if (line.compare(a_keyword) == 0)
00384       {
00385         for (int l=0 ; l<a_nbLines ; l++)
00386         {
00387           getline(input_file, line);
00388           //remove field in string
00389           line = line.substr(line.find_first_of(sep)+1);
00390   
00391           //clear the space before the first element in the line string;
00392           //line.erase(remove_if(line.begin(), line.end(), (int(*)(int))isspace), line.end()); // Explicit type (int(*)(int)) is required to tell compiler which function to take the address of.
00393 
00394           // Erase all blank stuff before first character
00395           line.erase(0, line.find_first_not_of(" !\t\r\n")); // Erase all blank stuff before first character
00396           line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
00397           
00398           size_t pos = 0;
00399           size_t pos2 = line.find_first_of(sep_elt, pos);
00400               
00401           // Check if separators were found
00402           if (a_nbElts>1 && pos2 == string::npos)
00403           {
00404             Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
00405             return 1;
00406           }
00407           else // Read one element, or several (a_nbElts) elements separated with ','
00408           {
00409             for (int i=0 ; i<a_nbElts ; i++)
00410             {
00411               // Check if we reach the end of the line before initializing all elements
00412               if(pos<0)
00413               {
00414                 Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
00415                 Cerr("*****                                  Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
00416                 return 1;
00417               }
00418               
00419               // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
00420               string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
00421     
00422               if (ConvertFromString(elt, &a2p_return[l][i]))
00423               {
00424                 Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file " << a_file <<  endl);
00425                 return 1;
00426               } 
00427     
00428               //pos = pos2+1;
00429               // return -1 if pos2 not found, meaning we reach the end of the line
00430               pos = (pos2<0) ? -1 : pos2+1 ;
00431               pos2 = line.find_first_of(sep_elt, pos);
00432             }
00433           }
00434         }  
00435         return 0; 
00436       }
00437     }
00438     
00439     // Throw an error message if the tag is mandatory
00440     if (a_mandatoryFlag == true ) 
00441     {
00442       Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
00443       return KEYWORD_MANDATORY_NOT_FOUND;
00444     }
00445     else
00446     {
00447       return KEYWORD_OPTIONAL_NOT_FOUND;
00448     }
00449   }
00450   else
00451   {
00452     Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '" << a_file << "' !" << endl);
00453     return 1;
00454   }
00455 }
00456 
00457 
00458 
00459 
00460 // =====================================================================
00461 // ---------------------------------------------------------------------
00462 // ---------------------------------------------------------------------
00463 // =====================================================================
00464 
00465 /*
00466   \fn ReadDataASCIIFile
00467   \param a_file : string containing the path to the ASCII file
00468   \param a_keyword : key related to the data we want to recover
00469   \param ap_return : templated array in which the data will be returned
00470                      the recovered data will be converted to its type
00471                      its size should be equal to the number of elts to recover
00472   \param a_nbElts : number of elements to recover
00473   \param a_mandatoryFlag : boolean indicating the data to recover is 
00474                            mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
00475                         or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
00476   \param a_firstTag : the requested key will be looked for after the first occurence of this string
00477   \param a_lastTag : the requested key will be looked for before the first occurence of this string
00478   \brief Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter
00479          and return the corresponding value(s) in the "ap_return" templated array.
00480          Additionnal two parameters allow to search within two specific tags
00481          This function expects the following parsing :
00482          FIRST_TAG
00483          (...)
00484          KEY : elt1,elt2,...,eltN 
00485          (...)
00486          LAST_TAG
00487   \details This function assumes the following separators :
00488            ":" is used as separator between the keyworld and the value
00489            "#" is used for comment. Every following characters will be discarded
00490            "," is used to separate elements if more than one are required
00491   \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
00492 */
00493 template<class T> 
00494 int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag)
00495 {
00496   ifstream input_file(a_file.c_str(), ios::in);
00497   string line;
00498   string sep = ":";
00499   string sep_comment = "#";
00500   string sep_elt = ",";
00501   bool search_on = false;
00502   
00503   // Check file
00504   if(input_file)
00505   {
00506     while(!input_file.eof())
00507     {
00508       getline(input_file, line);
00509   
00510       //remove comment
00511       if (line.find(sep_comment) != string::npos) line = line.substr(0, line.find_first_of(sep_comment)) ;
00512       
00513       if( line.find(a_firstTag) != string::npos) search_on = true;
00514       if( line.find(a_lastTag) != string::npos || line.find("eof") != string::npos ) search_on = false;
00515       
00516       if( search_on )
00517       {      
00518         if (line.find(a_keyword) != string::npos)
00519         //if (line.compare(a_keyword) == 0)
00520         {
00521           //remove field in string
00522           line = line.substr(line.find_first_of(sep)+1);
00523 
00524           //clear the space before the first element in the line string;
00525           //line.erase(remove_if(line.begin(), line.end(), (int(*)(int))isspace), line.end()); // Explicit type (int(*)(int)) is required to tell compiler which function to take the address of.
00526 
00527           // Erase all blank stuff before first character
00528           line.erase(0, line.find_first_not_of(" !\t\r\n")); // Erase all blank stuff before first character
00529           line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
00530           
00531           size_t pos = 0;
00532           size_t pos2 = line.find_first_of(sep_elt, pos);
00533 
00534           // Check if separators were found
00535           if (a_nbElts>1 && pos2 == string::npos)
00536           {
00537             Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
00538             return 1;
00539           }
00540           else // Read one element, or several (a_nbElts) elements separated with ','
00541           {
00542             for (int i=0 ; i<a_nbElts ; i++)
00543             {
00544               
00545               // Check if we reach the end of the line before initializing all elements
00546               if(pos<0)
00547               {
00548                 Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
00549                 Cerr("*****                                  Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
00550                 return 1;
00551               }
00552             
00553               // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
00554               string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
00555             
00556               if(ConvertFromString(elt, &ap_return[i]))
00557               {
00558                 Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
00559                 return 1;
00560               }
00561             
00562               //pos = pos2+1;
00563               // return -1 if pos2 not found, meaning we reach the end of the line
00564               pos = (pos2<0) ? -1 : pos2+1 ;
00565               pos2 = line.find_first_of(sep_elt, pos);
00566             }
00567           }
00568           return 0;
00569         }
00570       }
00571       
00572       
00573       
00574       
00575   
00576     }
00577     // Throw an error message if the tag is mandatory
00578     if(a_mandatoryFlag == true) 
00579     {
00580       Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
00581       return KEYWORD_MANDATORY_NOT_FOUND;
00582     }
00583     else
00584     {
00585       return KEYWORD_OPTIONAL_NOT_FOUND;
00586     }
00587   }
00588   else
00589   {
00590     Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '"<< a_file << "' !" << endl);
00591     return 1;
00592   }
00593 }
00594 
00595 
00596 
00597 
00598 // =====================================================================
00599 // ---------------------------------------------------------------------
00600 // ---------------------------------------------------------------------
00601 // =====================================================================
00602 /*
00603   \fn ReadDataASCIIFile
00604   \param a_file : string containing the path to the ASCII file
00605   \param a_keyword : key related to the data we want to recover
00606   \param a2p_return : 2D templated array in which the data will be returned
00607                      the recovered data will be converted to its type
00608                      its size should be equal [nb of lines][nb of elts to recover]
00609   \param a_nbElts : number of elements to recover (on each line)
00610   \param a_nbLines : number of lines to recover
00611   \param a_mandatoryFlag : boolean indicating the data to recover is 
00612                            mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
00613                         or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
00614   \param a_firstTag : the requested key will be looked for after the first occurence of this string
00615   \param a_lastTag : the requested key will be looked for before the first occurence of this string
00616   \brief Look for "a_nbLines" lines of "a_nbElts" elts in the "a_file" file matching the "a_keyword" string 
00617          passed as parameter and return the corresponding value(s) in the "a2p_return" templated 2D array.
00618          The first and second dimensions of "a2p_return" correspond to the line and elements respectively
00619          Additionnal two parameters allow to search within two specific tags
00620          This function expects the following parsing :
00621          KEY :
00622           FIRST_TAG
00623          (...)
00624          line1 : elt1,elt2,...,eltN
00625          line2 : elt1,elt2,...,eltN
00626          (...)
00627          lineN : elt1,elt2,...,eltN
00628          (...)
00629          LAST_TAG
00630   \details This function assumes the following separators :
00631            ":" is used as separator between the keyworld and the value
00632            "#" is used for comment. Every following characters will be discarded
00633            "," is used to separate elements if more than one are required
00634   \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
00635 */
00636 template<class T> 
00637 int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag)
00638 {
00639   ifstream input_file(a_file.c_str(), ios::in);
00640   string line;
00641   string sep = ":";
00642   string sep_comment = "#";
00643   string sep_elt = ",";
00644   bool search_on = false;
00645   
00646   // Check file
00647   if(input_file)
00648   {
00649     while(!input_file.eof())
00650     {
00651       getline(input_file, line);
00652   
00653       //remove comment
00654       if (line.find(sep_comment) != string::npos) line = line.substr(0, line.find_first_of(sep_comment)) ;
00655       
00656       if( line.find(a_firstTag) != string::npos) search_on = true;
00657       if( line.find(a_lastTag) != string::npos || line.find("eof") != string::npos ) search_on = false;
00658 
00659       if( search_on )
00660       {      
00661           for (int l=0 ; l<a_nbLines ; l++)
00662           {
00663             getline(input_file, line);
00664             //remove field in string
00665             line = line.substr(line.find_first_of(sep)+1);
00666     
00667             //clear the space before the first element in the line string;
00668             //line.erase(remove_if(line.begin(), line.end(), (int(*)(int))isspace), line.end()); // Explicit type (int(*)(int)) is required to tell compiler which function to take the address of.
00669 
00670             // Erase all blank stuff before and after first character
00671             line.erase(0, line.find_first_not_of(" !\t\r\n"));
00672             line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
00673   
00674             size_t pos = 0;
00675             size_t pos2 = line.find_first_of(sep_elt, pos);
00676                 
00677             // Check if separators were found
00678             if (a_nbElts>1 && pos2 == string::npos)
00679             {
00680               Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
00681               return 1;
00682             }
00683             else // Read one element, or several (a_nbElts) elements separated with ','
00684             {
00685               for (int i=0 ; i<a_nbElts ; i++)
00686               {
00687                 // Check if we reach the end of the line before initializing all elements
00688                 if(pos<0)
00689                 {
00690                   Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
00691                   Cerr("*****                                  Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
00692                   return 1;
00693                 }
00694                 
00695                 // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
00696                 string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
00697 
00698                 if (ConvertFromString(elt, &a2p_return[l][i]))
00699                 {
00700                   Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file " << a_file <<  endl);
00701                   return 1;
00702                 } 
00703       
00704                 //pos = pos2+1;
00705                 // return -1 if pos2 not found, meaning we reach the end of the line
00706                 pos = (pos2<0) ? -1 : pos2+1 ;
00707                 pos2 = line.find_first_of(sep_elt, pos);
00708               }
00709             }
00710             
00711           }
00712           return 0;
00713       }  
00714     }
00715     // Throw an error message if the tag is mandatory
00716     if(a_mandatoryFlag == true) 
00717     {
00718       Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
00719       return KEYWORD_MANDATORY_NOT_FOUND;
00720     }
00721     else
00722     {
00723       return KEYWORD_OPTIONAL_NOT_FOUND;
00724     }
00725   }
00726   else
00727   {
00728     Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '"<< a_file << "' !" << endl);
00729     return 1;
00730   }
00731 }
00732 
00733 
00734 
00735 
00736 // =====================================================================
00737 // ---------------------------------------------------------------------
00738 // ---------------------------------------------------------------------
00739 // =====================================================================
00740 /*
00741   \fn ConvertFromString
00742   \param a_str : string to convert
00743   \param a_result : variable which will recover the result
00744   \brief Copy the 'a_str' string in the position pointed by 'a_result'
00745   \details The only purposes of this function is to have an 
00746            unified templated conversion function for each type
00747   \return 0 if success, and positive value otherwise
00748 */
00749 int ConvertFromString(const string& a_str, string* a_result)
00750 {
00751   *a_result = a_str.c_str();
00752   return 0;
00753 }
00754 
00755 
00756 
00757 
00758 // =====================================================================
00759 // ---------------------------------------------------------------------
00760 // ---------------------------------------------------------------------
00761 // =====================================================================
00762 /*
00763   \fn ConvertFromString
00764   \param a_str : string to convert
00765   \param a_result : variable which will recover the result
00766   \brief Convert the 'a_str' string in float and copy the result in the variable pointed by 'a_result'
00767   \details Uses strtod to check errors with str to float conversion
00768           (implementation similar to c++11 std::stof() ).
00769   \return 0 if success, and positive value otherwise
00770 */
00771 int ConvertFromString(const string& a_str, float* a_result)
00772 {
00773   const char* p = a_str.c_str();
00774   char* end;
00775   errno = 0;
00776   double val = strtod(p, &end);
00777   
00778   if (p == end) 
00779   {
00780     Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into float " << endl);
00781     return 1;
00782   }
00783   if (errno == ERANGE) 
00784   {
00785     Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into float " << endl);
00786     return 1;
00787   }
00788   
00789   *a_result = static_cast<float>(val);
00790   
00791   return 0;  
00792 }
00793 
00794 
00795 
00796 
00797 // =====================================================================
00798 // ---------------------------------------------------------------------
00799 // ---------------------------------------------------------------------
00800 // =====================================================================
00801 /*
00802   \fn ConvertFromString
00803   \param a_str : string to convert
00804   \param a_result : variable which will recover the result
00805   \brief Convert the 'a_str' string in double and copy the result in the position pointed by 'a_result'
00806   \details Uses strtod to check errors with str to double conversion
00807           (implementation similar to c++11 std::stod() ).
00808   \return 0 if success, and positive value otherwise
00809 */
00810 int ConvertFromString(const string& a_str, double* a_result)
00811 {
00812   const char* p = a_str.c_str();
00813   char* end;
00814   errno = 0;
00815   double val = strtod(p, &end);
00816   
00817   if (p == end) 
00818   {
00819     Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into double " << endl);
00820     return 1;
00821   }
00822   if (errno == ERANGE) 
00823   {
00824     Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into double " << endl);
00825     return 1;
00826   }
00827   
00828   *a_result = val;
00829   
00830   return 0;
00831 }
00832 
00833 
00834 
00835 
00836 // =====================================================================
00837 // ---------------------------------------------------------------------
00838 // ---------------------------------------------------------------------
00839 // =====================================================================
00840 /*
00841   \fn ConvertFromString
00842   \param a_str : string to convert
00843   \param a_result : variable which will recover the result
00844   \brief Convert the 'a_str' string in long double and copy the result in the position pointed by 'a_result'
00845   \details Uses strtod to check errors with str to ldouble conversion
00846           (implementation similar to c++11 std::stod() ).
00847   \return 0 if success, and positive value otherwise
00848 */
00849 int ConvertFromString(const string& a_str, long double* a_result)
00850 {
00851   const char* p = a_str.c_str();
00852   char* end;
00853   errno = 0;
00854   long double val = strtold(p, &end);
00855   
00856   if (p == end) 
00857   {
00858     Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into double " << endl);
00859     return 1;
00860   }
00861   if (errno == ERANGE) 
00862   {
00863     Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into double " << endl);
00864     return 1;
00865   }
00866   
00867   *a_result = val;
00868   
00869   return 0;
00870 }
00871 
00872 
00873 
00874 
00875 // =====================================================================
00876 // ---------------------------------------------------------------------
00877 // ---------------------------------------------------------------------
00878 // =====================================================================
00879 /*
00880   \fn ConvertFromString
00881   \param a_str : string to convert
00882   \param a_result : variable which will recover the result
00883   \brief Convert the 'a_str' string in int and copy the result in the position pointed by 'a_result'
00884   \details Uses strtol to check errors with str to int conversion
00885           (implementation similar to c++11 std::stoi() ).
00886   \return 0 if success, and positive value otherwise
00887 */
00888 int ConvertFromString(const string& a_str, int* a_result)
00889 {
00890   const char* p = a_str.c_str();
00891   char* end;
00892   errno = 0;
00893   int64_t val = strtol(p, &end, 10);
00894   
00895   if (p == end) 
00896   {
00897     Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into int " << endl);
00898     return 1;
00899   }
00900   if (errno==ERANGE || val<INT_MIN || val>INT_MAX) 
00901   {
00902     Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into int " << endl);
00903     return 1;
00904   }
00905   
00906   *a_result = static_cast<int>(val);
00907   
00908   return 0;
00909 }
00910 
00911 
00912 
00913 
00914 // =====================================================================
00915 // ---------------------------------------------------------------------
00916 // ---------------------------------------------------------------------
00917 // =====================================================================
00918 /*
00919   \fn ConvertFromString
00920   \param a_str : string to convert
00921   \param a_result : variable which will recover the result
00922   \brief Convert the 'a_str' string in int64_t and copy the result in the position pointed by 'a_result'
00923   \details Uses strtol to check errors with str to lint conversion
00924           (implementation similar to c++11 std::stol() ).
00925   \return 0 if success, and positive value otherwise
00926 */
00927 int ConvertFromString(const string& a_str, int64_t* a_result)
00928 {
00929   const char* p = a_str.c_str();
00930   char* end;
00931   errno = 0;
00932   int64_t val = strtol(p, &end, 10);
00933   
00934   if (p == end) 
00935   {
00936     Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into int64_t " << endl);
00937     return 1;
00938   }
00939   if (errno == ERANGE) 
00940   {
00941     Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into int64_t " << endl);
00942     return 1;
00943   }
00944   
00945   *a_result = val;
00946 
00947   return 0;
00948 }
00949 
00950 
00951 
00952 
00953 // =====================================================================
00954 // ---------------------------------------------------------------------
00955 // ---------------------------------------------------------------------
00956 // =====================================================================
00957 /*
00958   \fn ConvertFromString
00959   \param a_str : string to convert
00960   \param a_result : variable which will recover the result
00961   \brief Convert the 'a_str' string in uint16_t and copy the result in the position pointed by 'a_result'
00962   \details Uses strtol to check errors with str to uint8 conversion
00963           (implementation similar to c++11 std::stoi() ).
00964   \return 0 if success, and positive value otherwise
00965 */
00966 int ConvertFromString(const string& a_str, uint8_t* a_result)
00967 {
00968   const char* p = a_str.c_str();
00969   char* end;
00970   errno = 0;
00971   int64_t val = strtol(p, &end, 10);
00972   
00973   if (p == end) 
00974   {
00975     Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into uint16 " << endl);
00976     return 1;
00977   }
00978   if (errno == ERANGE || val<0 || val>UCHAR_MAX) 
00979   {
00980     Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into uint16 " << endl);
00981     return 1;
00982   }
00983   
00984   *a_result = val;
00985   
00986   return 0;
00987 }
00988 
00989 
00990 
00991 
00992 // =====================================================================
00993 // ---------------------------------------------------------------------
00994 // ---------------------------------------------------------------------
00995 // =====================================================================
00996 /*
00997   \fn ConvertFromString
00998   \param a_str : string to convert
00999   \param a_result : variable which will recover the result
01000   \brief Convert the 'a_str' string in uint16_t and copy the result in the position pointed by 'a_result'
01001   \details Uses strtol to check errors with str to uint16 conversion
01002           (implementation similar to c++11 std::stoi() ).
01003   \return 0 if success, and positive value otherwise
01004 */
01005 int ConvertFromString(const string& a_str, uint16_t* a_result)
01006 {
01007   const char* p = a_str.c_str();
01008   char* end;
01009   errno = 0;
01010   int64_t val = strtol(p, &end, 10);
01011   
01012   if (p == end) 
01013   {
01014     Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into uint16 " << endl);
01015     return 1;
01016   }
01017   if (errno == ERANGE || val<0 || val>USHRT_MAX) 
01018   {
01019     Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into uint16 " << endl);
01020     return 1;
01021   }
01022   
01023   *a_result = val;
01024   
01025   return 0;
01026 }
01027 
01028 
01029 
01030 
01031 // =====================================================================
01032 // ---------------------------------------------------------------------
01033 // ---------------------------------------------------------------------
01034 // =====================================================================
01035 /*
01036   \fn ConvertFromString
01037   \param a_str : string to convert
01038   \param a_result : variable which will recover the result
01039   \brief Convert the 'a_str' string in uint32_t and copy the result in the position pointed by 'a_result'
01040   \details Uses strtol to check errors with str to uint32 conversion
01041           (implementation similar to c++11 std::stoi() ).
01042   \return 0 if success, and positive value otherwise
01043 */
01044 int ConvertFromString(const string& a_str, uint32_t* a_result)
01045 {
01046   const char* p = a_str.c_str();
01047   char* end;
01048   errno = 0;
01049   int64_t val = strtol(p, &end, 10);
01050   
01051   if (p == end) 
01052   {
01053     Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into uint32 " << endl);
01054     return 1;
01055   }
01056   if (errno == ERANGE || val<0 || val>UINT_MAX) 
01057   {
01058     Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into uint32 " << endl);
01059     return 1;
01060   }
01061   
01062   *a_result = val;
01063   
01064   return 0;
01065 }
01066 
01067 
01068 
01069 
01070 // =====================================================================
01071 // ---------------------------------------------------------------------
01072 // ---------------------------------------------------------------------
01073 // =====================================================================
01074 /*
01075   \fn ConvertFromString
01076   \param a_str : string to convert
01077   \param a_result : variable which will recover the result
01078   \brief Convert the 'a_str' string in bool and copy the result in the position pointed by 'a_result'
01079   \details Uses strtol to check errors with str to bool conversion
01080         (implementation similar to c++11 std::stoi() ).
01081   \return 0 if success, and positive value otherwise
01082 */
01083 int ConvertFromString(const string& a_str, bool* a_result)
01084 {
01085   const char* p = a_str.c_str();
01086   char* end;
01087   errno = 0;
01088   int64_t val = strtol(p, &end, 10);
01089   
01090   if (p == end) 
01091   {
01092     Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into bool " << endl);
01093     return 1;
01094   }
01095   if (errno == ERANGE || val<0 || val>1) 
01096   {
01097     Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into bool " << endl);
01098     return 1;
01099   }
01100   
01101   *a_result = val;
01102   
01103   return 0;
01104 }
01105 
01106 
01107 
01108 
01109 // =====================================================================
01110 // ---------------------------------------------------------------------
01111 // ---------------------------------------------------------------------
01112 // =====================================================================
01113 /*
01114   \fn GetFileFromPath()
01115   \param a_pathToFile
01116   \brief Simply return the file from a path string passed in parameter
01117   \return The path.
01118 */
01119 string GetFileFromPath(const string& a_pathToFile)
01120 {
01121   string path = a_pathToFile;
01122 
01123   int pos = path.find_last_of(OS_SEP);
01124   if (path.find_last_of(OS_SEP) == string::npos)
01125     return path;
01126     
01127   path = path.substr(pos+1);
01128   return path;
01129 }
01130 
01131 
01132 
01133 
01134 // =====================================================================
01135 // ---------------------------------------------------------------------
01136 // ---------------------------------------------------------------------
01137 // =====================================================================
01138 /*
01139   \fn GetPathOfFile()
01140   \param a_pathToFile
01141   \brief Simply return the path to the directory of a file path string passed in parameter
01142   \return The path.
01143 */
01144 string GetPathOfFile(const string& a_pathToFile)
01145 {
01146   string path = a_pathToFile;
01147   
01148   int pos = path.find_last_of(OS_SEP);
01149   if (path.find_last_of(OS_SEP) == string::npos)
01150     return "";
01151   
01152   path = path.substr(0,pos+1);
01153 
01154   return path;
01155 }
01156 
01157 
01158 /*
01159   \fn      string ConvertAllSlashOcurrencesToBackSlash()
01160   \param   const string& a_path
01161   \brief   Simply convert all occurrences of "/" to "\"
01162   \return  A new converted string
01163 */
01164 string ConvertAllSlashOccurrencesToBackSlash(const string& a_path)
01165 {
01166   string result = a_path;
01167   size_t position;
01168   while ( (position  = result.find_first_of("/")) != string::npos )
01169   {
01170     result.replace(position,1,"\\");
01171   }
01172   return result;
01173 }
01174 
01175 
01176 /*
01177   \fn      bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps)
01178   \param   a : 1st FLTNB nb to compare
01179   \param   b : 2nd FLTNB nb to compare
01180   \param   a_eps : epsilon for comparison
01181   \brief   Comparison of FLTNB numbers
01182   \return  true if equal according to the provided epsilon, false otherwise
01183 */
01184 bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps)
01185 {
01186   FLTNB absA = abs(a);
01187   FLTNB absB = abs(b);
01188   FLTNB diff = abs(a - b);
01189   
01190   if (a == b)
01191   {
01192     return true;
01193   } 
01194   else if (a == 0 || 
01195            b == 0 || 
01196            diff < std::numeric_limits<FLTNB>::min()) 
01197   { // a or b is 0, or extremely close to it
01198     return diff < (a_eps * std::numeric_limits<FLTNB>::min() );
01199   } 
01200   else 
01201   { // relative error
01202     return diff / min((absA + absB), std::numeric_limits<FLTNB>::max()) < a_eps;
01203   }
01204 }
01205 
01206 
01207 // =====================================================================
01208 // ---------------------------------------------------------------------
01209 // ---------------------------------------------------------------------
01210 // =====================================================================
01211 // Explicit template instantiation 
01212 // (that way no one would use the templated versions of these functions for not yet implemented type (long double, unsigned, ect..) )
01213 template int ReadStringOption<string>(const string& a_input, string* ap_return, int a_nbElts, const string& sep, const string& a_option);
01214 template int ReadStringOption<int>(const string& a_input, int* ap_return, int a_nbElts, const string& sep, const string& a_option);
01215 template int ReadStringOption<int64_t>(const string& a_input, int64_t* ap_return, int a_nbElts, const string& sep, const string& a_option);
01216 template int ReadStringOption<float>(const string& a_input, float* ap_return, int a_nbElts, const string& sep, const string& a_option);
01217 template int ReadStringOption<double>(const string& a_input, double* ap_return, int a_nbElts, const string& sep, const string& a_option);
01218 template int ReadStringOption<long double>(const string& a_input, long double* ap_return, int a_nbElts, const string& sep, const string& a_option);
01219 template int ReadStringOption<uint8_t>(const string& a_input, uint8_t* ap_return, int a_nbElts, const string& sep, const string& a_option);
01220 template int ReadStringOption<uint16_t>(const string& a_input, uint16_t* ap_return, int a_nbElts, const string& sep, const string& a_option);
01221 template int ReadStringOption<uint32_t>(const string& a_input, uint32_t* ap_return, int a_nbElts, const string& sep, const string& a_option);
01222 template int ReadStringOption<bool>(const string& a_input, bool* ap_return, int a_nbElts, const string& sep, const string& a_option);
01223 
01224 template int ReadDataASCIIFile<string>(const string& a_file, const string& a_keyword, string* ap_return, int a_nbElts, bool a_mandatoryFlag);
01225 template int ReadDataASCIIFile<int>(const string& a_file, const string& a_keyword, int* ap_return, int a_nbElts, bool a_mandatoryFlag);
01226 template int ReadDataASCIIFile<int64_t>(const string& a_file, const string& a_keyword, int64_t* ap_return, int a_nbElts, bool a_mandatoryFlag);
01227 template int ReadDataASCIIFile<float>(const string& a_file, const string& a_keyword, float* ap_return, int a_nbElts, bool a_mandatoryFlag);
01228 template int ReadDataASCIIFile<double>(const string& a_file, const string& a_keyword, double* ap_return, int a_nbElts, bool a_mandatoryFlag);
01229 template int ReadDataASCIIFile<long double>(const string& a_file, const string& a_keyword, long double* ap_return, int a_nbElts, bool a_mandatoryFlag);
01230 template int ReadDataASCIIFile<uint8_t>(const string& a_file, const string& a_keyword, uint8_t* ap_return, int a_nbElts, bool a_mandatoryFlag);
01231 template int ReadDataASCIIFile<uint16_t>(const string& a_file, const string& a_keyword, uint16_t* ap_return, int a_nbElts, bool a_mandatoryFlag);
01232 template int ReadDataASCIIFile<uint32_t>(const string& a_file, const string& a_keyword, uint32_t* ap_return, int a_nbElts, bool a_mandatoryFlag);
01233 template int ReadDataASCIIFile<bool>(const string& a_file, const string& a_keyword, bool* ap_return, int a_nbElts, bool a_mandatoryFlag);
01234 
01235 template int ReadDataASCIIFile<string>(const string& a_file, const string& a_keyword, string* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01236 template int ReadDataASCIIFile<int>(const string& a_file, const string& a_keyword, int* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01237 template int ReadDataASCIIFile<int64_t>(const string& a_file, const string& a_keyword, int64_t* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01238 template int ReadDataASCIIFile<float>(const string& a_file, const string& a_keyword, float* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01239 template int ReadDataASCIIFile<double>(const string& a_file, const string& a_keyword, double* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01240 template int ReadDataASCIIFile<long double>(const string& a_file, const string& a_keyword, long double* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01241 template int ReadDataASCIIFile<uint8_t>(const string& a_file, const string& a_keyword, uint8_t* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01242 template int ReadDataASCIIFile<uint16_t>(const string& a_file, const string& a_keyword, uint16_t* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01243 template int ReadDataASCIIFile<uint32_t>(const string& a_file, const string& a_keyword, uint32_t* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01244 template int ReadDataASCIIFile<bool>(const string& a_file, const string& a_keyword, bool* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01245 
01246 template int ReadDataASCIIFile<string>(const string& a_file, const string& a_keyword, string** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01247 template int ReadDataASCIIFile<int>(const string& a_file, const string& a_keyword, int** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01248 template int ReadDataASCIIFile<int64_t>(const string& a_file, const string& a_keyword, int64_t** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01249 template int ReadDataASCIIFile<float>(const string& a_file, const string& a_keyword, float** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01250 template int ReadDataASCIIFile<double>(const string& a_file, const string& a_keyword, double** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01251 template int ReadDataASCIIFile<long double>(const string& a_file, const string& a_keyword, long double** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01252 template int ReadDataASCIIFile<uint8_t>(const string& a_file, const string& a_keyword, uint8_t** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01253 template int ReadDataASCIIFile<uint16_t>(const string& a_file, const string& a_keyword, uint16_t** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01254 template int ReadDataASCIIFile<uint32_t>(const string& a_file, const string& a_keyword, uint32_t** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01255 template int ReadDataASCIIFile<bool>(const string& a_file, const string& a_keyword, bool** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
01256 
01257 template int ReadDataASCIIFile<string>(const string& a_file, const string& a_keyword, string* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01258 template int ReadDataASCIIFile<int>(const string& a_file, const string& a_keyword, int* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01259 template int ReadDataASCIIFile<int64_t>(const string& a_file, const string& a_keyword, int64_t* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01260 template int ReadDataASCIIFile<float>(const string& a_file, const string& a_keyword, float* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01261 template int ReadDataASCIIFile<double>(const string& a_file, const string& a_keyword, double* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01262 template int ReadDataASCIIFile<long double>(const string& a_file, const string& a_keyword, long double* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01263 template int ReadDataASCIIFile<uint8_t>(const string& a_file, const string& a_keyword, uint8_t* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01264 template int ReadDataASCIIFile<uint16_t>(const string& a_file, const string& a_keyword, uint16_t* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01265 template int ReadDataASCIIFile<uint32_t>(const string& a_file, const string& a_keyword, uint32_t* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01266 template int ReadDataASCIIFile<bool>(const string& a_file, const string& a_keyword, bool* ap_return, int a_nbElts, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01267 
01268 template int ReadDataASCIIFile<string>(const string& a_file, const string& a_keyword, string** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01269 template int ReadDataASCIIFile<int>(const string& a_file, const string& a_keyword, int** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01270 template int ReadDataASCIIFile<int64_t>(const string& a_file, const string& a_keyword, int64_t** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01271 template int ReadDataASCIIFile<float>(const string& a_file, const string& a_keyword, float** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01272 template int ReadDataASCIIFile<double>(const string& a_file, const string& a_keyword, double** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01273 template int ReadDataASCIIFile<long double>(const string& a_file, const string& a_keyword, long double** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01274 template int ReadDataASCIIFile<uint8_t>(const string& a_file, const string& a_keyword, uint8_t** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01275 template int ReadDataASCIIFile<uint16_t>(const string& a_file, const string& a_keyword, uint16_t** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01276 template int ReadDataASCIIFile<uint32_t>(const string& a_file, const string& a_keyword, uint32_t** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
01277 template int ReadDataASCIIFile<bool>(const string& a_file, const string& a_keyword, bool** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag, string a_firstTag, string a_lastTag);
 All Classes Files Functions Variables Typedefs Defines