CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
code/src/management/gOptions.cc
Go to the documentation of this file.
1 
9 #include "gVariables.hh"
10 #include "gOptions.hh"
11 #include "sOutputManager.hh"
12 // For error handling
13 #include <errno.h>
14 #include <limits.h>
15 #ifdef _WIN32
16 // Avoid compilation errors due to mix up between std::min()/max() and
17 // min max macros
18 #undef min
19 #undef max
20 #endif
21 
22 // =====================================================================
23 // ---------------------------------------------------------------------
24 // ---------------------------------------------------------------------
25 // =====================================================================
26 
27 template<class T>
28 int ReadStringOption(const string& a_input, T* ap_return, int a_nbElts, const string& a_sep, const string& a_option)
29 {
30  // If number of elements is negative or null, then exit
31  if (a_nbElts<=0) return 0;
32  // Check that the separator is not empty
33  if (a_sep=="")
34  {
35  Cerr("***** gOptions::ReadStringOption() -> Separator is empty while reading option '" << a_option << "' !" << endl);
36  return 1;
37  }
38  // Count the number of separators in the input string
39  int nb_sep = 0;
40  string tmp_input = a_input;
41  size_t pos = 0;
42  while ((pos=tmp_input.find_first_of(a_sep,0))!=string::npos)
43  {
44  tmp_input = tmp_input.substr(pos+1);
45  nb_sep++;
46  }
47  // Check for too many parameters
48  if (nb_sep>a_nbElts-1)
49  {
50  Cerr("***** gOptions::ReadStringOption() -> Too many parameters in '" << a_input << "' while reading option '" << a_option << "' (expecting " << a_nbElts << ") !" << endl);
51  return 1;
52  }
53  // Check for not enough parameters
54  if (nb_sep<a_nbElts-1)
55  {
56  Cerr("***** gOptions::ReadStringOption() -> Not enough parameters in '" << a_input << "' while reading option '" << a_option << "' (expecting " << a_nbElts << ") !" << endl);
57  return 1;
58  }
59  // Loop on elements to be read
60  size_t pos1 = 0;
61  size_t pos2 = a_input.find_first_of(a_sep, 0);
62  for (int i=0; i<a_nbElts; i++)
63  {
64  // Extract element and convert the parameter
65  string elt = a_input.substr(pos1, pos2-pos1);
66  if (ConvertFromString(elt, &ap_return[i]))
67  {
68  Cerr("***** gOptions::ReadStringOption() -> Error when trying to read input data for option '" << a_option << "' !" << endl);
69  return 1;
70  }
71  pos1 = pos2+1;
72  pos2 = a_input.find_first_of(a_sep, pos1);
73  }
74  // Normal end
75  return 0;
76 }
77 
78 
79 
80 
81 // =====================================================================
82 // ---------------------------------------------------------------------
83 // ---------------------------------------------------------------------
84 // =====================================================================
85 /*
86  \fn ReadDataASCIIFile
87  \param a_file : string containing the path to the ASCII file
88  \param a_keyword : key related to the data we want to recover
89  \param ap_return : templated array in which the data will be returned
90  the recovered data will be converted to its type
91  its size should be equal to the number of elts to recover
92  \param a_nbElts : number of elements to recover
93  \param a_mandatoryFlag : boolean indicating the data to recover is
94  mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
95  or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
96  \brief Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter
97  and return the corresponding value(s) in the "ap_return" templated array.
98  This function expects the following parsing :
99  KEY : elt1,elt2,...,eltN
100  \details This function assumes the following separators :
101  ":" is used as separator between the keyworld and the value
102  "#" is used for comment. Every following characters will be discarded
103  "," is used to separate elements if more than one are required
104  \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
105 */
106 template<class T>
107 int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T* ap_return, int a_nbElts, bool a_mandatoryFlag)
108 {
109  ifstream input_file(a_file.c_str(), ios::in);
110  string line;
111  string sep = ":";
112  string sep_comment = "#";
113  string sep_elt = ",";
114 
115  // Check file
116  if (input_file)
117  {
118  while(!input_file.eof())
119  {
120  getline(input_file, line);
121 
122  //remove comment
123  if (line.find(sep_comment) != string::npos) line = line.substr(0, line.find_first_of(sep_comment)) ;
124 
125  if (line.find(a_keyword) != string::npos)
126  //if (line.compare(a_keyword) == 0)
127  {
128  //remove field in string
129  line = line.substr(line.find_first_of(sep)+1);
130 
131  //clear every spaces in the line string;
132  //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.
133 
134  // Erase all blank stuff before first character
135  line.erase(0, line.find_first_not_of(" !\t\r\n")); // Erase all blank stuff before first character
136  line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
137 
138  size_t pos = 0;
139  size_t pos2 = line.find_first_of(sep_elt, pos);
140 
141  // Check if separators were found
142  if (a_nbElts>1 && pos2 == string::npos)
143  {
144  Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
145  return 1;
146  }
147  else // Read one element, or several (a_nbElts) elements separated with ','
148  {
149  for (int i=0 ; i<a_nbElts ; i++)
150  {
151  // Check if we reach the end of the line before initializing all elements
152  // SS: corrected this incorrect line: if(pos<0)
153  if (pos==string::npos)
154  {
155  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
156  Cerr("***** Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
157  return 1;
158  }
159 
160  // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
161  string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
162 
163  if (ConvertFromString(elt, &ap_return[i]))
164  {
165  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
166  return 1;
167  }
168 
169 
170  //pos = pos2+1;
171  // return string::npos if pos2 not found, meaning we reach the end of the line
172  // SS: corrected this incorrect line pos = (pos2<0) ? -1 : pos2+1 ;
173  pos = (pos2==string::npos) ? string::npos : pos2+1;
174  pos2 = line.find_first_of(sep_elt, pos);
175 
176  }
177  }
178  return 0;
179  }
180 
181  }
182  // Throw an error message if the tag is mandatory
183  if (a_mandatoryFlag == true)
184  {
185  Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
187  }
188  else
189  {
191  }
192  }
193  else
194  {
195  Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '"<< a_file << "' !" << endl);
196  return 1;
197  }
198 }
199 
200 
201 
202 
203 // =====================================================================
204 // ---------------------------------------------------------------------
205 // ---------------------------------------------------------------------
206 // =====================================================================
207 /*
208  \fn ReadDataASCIIFile
209  \param a_file : string containing the path to the ASCII file
210  \param a_keyword : key related to the data we want to recover
211  \param ap_return : templated array in which the data will be returned
212  the recovered data will be converted to its type
213  its size should be equal to the nb of lines*nb of elts to recover
214  \param a_nbElts : number of elements to recover (on each line)
215  \param a_nbLines : number of lines to recover
216  \param a_mandatoryFlag : boolean indicating the data to recover is
217  mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
218  or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
219  \brief Look for "a_nbLines" lines of "a_nbElts" elts in the 'a_file' file matching the "a_keyword" string
220  passed as parameter and return the corresponding value(s) in the "ap_return" templated 1D array.
221  This function expects the following parsing :
222  KEY :
223  line1 : elt1,elt2,...,eltN
224  line2 : elt1,elt2,...,eltN
225  (...)
226  lineN : elt1,elt2,...,eltN
227  \details This function assumes the following separators :
228  ":" is used as separator between the keyworld and the value
229  "#" is used for comment. Every following characters will be discarded
230  "," is used to separate elements if more than one are required
231  \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
232 */
233 template<class T>
234 int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag)
235 {
236  ifstream input_file(a_file.c_str(), ios::in);
237  string line;
238  string sep = ":";
239  string sep_comment = "#";
240  string sep_elt = ",";
241 
242  // Check file
243  if (input_file)
244  {
245  while (!input_file.eof())
246  {
247  getline(input_file, line);
248 
249  //remove comment
250  if (line.find(sep_comment) != string::npos) line = line.substr(0, line.find_first_of(sep_comment));
251 
252  if (line.find(a_keyword) != string::npos)
253  //if (line.compare(a_keyword) == 0)
254  {
255  for (int l=0 ; l<a_nbLines ; l++)
256  {
257  getline(input_file, line);
258  //remove field in string
259  line = line.substr(line.find_first_of(sep)+1);
260 
261  //clear the space before the first element in the line string;
262  //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.
263 
264  // Erase all blank stuff before first character
265  line.erase(0, line.find_first_not_of(" !\t\r\n")); // Erase all blank stuff before first character
266  line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
267 
268  size_t pos = 0;
269  size_t pos2 = line.find_first_of(sep_elt, pos);
270 
271  // Check if separators were found
272  if (a_nbElts>1 && pos2 == string::npos)
273  {
274  Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
275  return 1;
276  }
277  else // Read one element, or several (a_nbElts) elements separated with ','
278  {
279  for (int i=0 ; i<a_nbElts ; i++)
280  {
281  // Check if we reach the end of the line before initializing all elements
282  // SS: corrected this incorrect line: if(pos<0)
283  if (pos==string::npos)
284  {
285  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
286  Cerr("***** Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
287  return 1;
288  }
289 
290  // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
291  string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
292 
293  if (ConvertFromString(elt, &ap_return[l*a_nbElts+i]))
294  {
295  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file " << a_file << endl);
296  return 1;
297  }
298 
299  //pos = pos2+1;
300  // return string::npos if pos2 not found, meaning we reach the end of the line
301  // SS: corrected this incorrect line pos = (pos2<0) ? -1 : pos2+1 ;
302  pos = (pos2==string::npos) ? string::npos : pos2+1;
303  pos2 = line.find_first_of(sep_elt, pos);
304  }
305  }
306  }
307  return 0;
308  }
309  }
310 
311  // Throw an error message if the tag is mandatory
312  if (a_mandatoryFlag == true)
313  {
314  Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
316  }
317  else
318  {
320  }
321  }
322  else
323  {
324  Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '" << a_file << "' !" << endl);
325  return 1;
326  }
327 }
328 
329 
330 
331 
332 // =====================================================================
333 // ---------------------------------------------------------------------
334 // ---------------------------------------------------------------------
335 // =====================================================================
336 /*
337  \fn ReadDataASCIIFile
338  \param a_file : string containing the path to the ASCII file
339  \param a_keyword : key related to the data we want to recover
340  \param a2p_return : 2D templated array in which the data will be returned
341  the recovered data will be converted to its type
342  its size should be equal [nb of lines][nb of elts to recover]
343  \param a_nbElts : number of elements to recover (on each line)
344  \param a_nbLines : number of lines to recover
345  \param a_mandatoryFlag : boolean indicating the data to recover is
346  mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
347  or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
348  \brief Look for "a_nbLines" lines of "a_nbElts" elts in the 'a_file' file matching the "a_keyword" string
349  passed as parameter and return the corresponding value(s) in the "a2p_return" 2D array.
350  The first and second dimensions of "a2p_return" correspond to the line and elements respectively
351  This function expects the following parsing :
352  KEY :
353  line1 : elt1,elt2,...,eltN
354  line2 : elt1,elt2,...,eltN
355  (...)
356  lineN : elt1,elt2,...,eltN
357  \details This function assumes the following separators :
358  ":" is used as separator between the keyworld and the value
359  "#" is used for comment. Every following characters will be discarded
360  "," is used to separate elements if more than one are required
361  \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
362 */
363 template<class T>
364 int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag)
365 {
366  ifstream input_file(a_file.c_str(), ios::in);
367  string line;
368  string sep = ":";
369  string sep_comment = "#";
370  string sep_elt = ",";
371 
372  // Check file
373  if (input_file)
374  {
375  while (!input_file.eof())
376  {
377  getline(input_file, line);
378 
379  //remove comment
380 
381  if (line.find(sep_comment) != string::npos) line = line.substr(0, line.find_first_of(sep_comment));
382 
383  if (line.find(a_keyword) != string::npos)
384  //if (line.compare(a_keyword) == 0)
385  {
386  for (int l=0 ; l<a_nbLines ; l++)
387  {
388  getline(input_file, line);
389 
390  //remove field in string
391  line = line.substr(line.find_first_of(sep)+1);
392 
393  //clear the space before the first element in the line string;
394  //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.
395 
396  // Erase all blank stuff before first character
397  line.erase(0, line.find_first_not_of(" !\t\r\n")); // Erase all blank stuff before first character
398  line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
399 
400  size_t pos = 0;
401  size_t pos2 = line.find_first_of(sep_elt, pos);
402 
403  // Check if separators were found
404  if (a_nbElts>1 && pos2 == string::npos)
405  {
406  Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
407  return 1;
408  }
409  else // Read one element, or several (a_nbElts) elements separated with ','
410  {
411  for (int i=0 ; i<a_nbElts ; i++)
412  {
413  // Check if we reach the end of the line before initializing all elements
414  // SS: corrected this incorrect line: if(pos<0)
415  if (pos==string::npos)
416  {
417  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
418  Cerr("***** Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
419  return 1;
420  }
421 
422  // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
423  string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
424 
425  if (ConvertFromString(elt, &a2p_return[l][i]))
426  {
427  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file " << a_file << endl);
428  return 1;
429  }
430 
431  //pos = pos2+1;
432  // return string::npos if pos2 not found, meaning we reach the end of the line
433  // SS: corrected this incorrect line pos = (pos2<0) ? -1 : pos2+1 ;
434  pos = (pos2==string::npos) ? string::npos : pos2+1;
435  pos2 = line.find_first_of(sep_elt, pos);
436  }
437  }
438  }
439  return 0;
440  }
441  }
442 
443  // Throw an error message if the tag is mandatory
444  if (a_mandatoryFlag == true )
445  {
446  Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
448  }
449  else
450  {
452  }
453  }
454  else
455  {
456  Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '" << a_file << "' !" << endl);
457  return 1;
458  }
459 }
460 
461 
462 
463 
464 // =====================================================================
465 // ---------------------------------------------------------------------
466 // ---------------------------------------------------------------------
467 // =====================================================================
468 
469 /*
470  \fn ReadDataASCIIFile
471  \param a_file : string containing the path to the ASCII file
472  \param a_keyword : key related to the data we want to recover
473  \param ap_return : templated array in which the data will be returned
474  the recovered data will be converted to its type
475  its size should be equal to the number of elts to recover
476  \param a_nbElts : number of elements to recover
477  \param a_mandatoryFlag : boolean indicating the data to recover is
478  mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
479  or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
480  \param a_firstTag : the requested key will be looked for after the first occurence of this string
481  \param a_lastTag : the requested key will be looked for before the first occurence of this string
482  \brief Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter
483  and return the corresponding value(s) in the "ap_return" templated array.
484  Additionnal two parameters allow to search within two specific tags
485  This function expects the following parsing :
486  FIRST_TAG
487  (...)
488  KEY : elt1,elt2,...,eltN
489  (...)
490  LAST_TAG
491  \details This function assumes the following separators :
492  ":" is used as separator between the keyworld and the value
493  "#" is used for comment. Every following characters will be discarded
494  "," is used to separate elements if more than one are required
495  \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
496 */
497 template<class T>
498 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)
499 {
500  ifstream input_file(a_file.c_str(), ios::in);
501  string line;
502  string sep = ":";
503  string sep_comment = "#";
504  string sep_elt = ",";
505  bool search_on = false;
506 
507  // Check file
508  if(input_file)
509  {
510  while(!input_file.eof())
511  {
512  getline(input_file, line);
513 
514  //remove comment
515  if (line.find(sep_comment) != string::npos) line = line.substr(0, line.find_first_of(sep_comment)) ;
516 
517  if( line.find(a_firstTag) != string::npos) search_on = true;
518  if( line.find(a_lastTag) != string::npos || line.find("eof") != string::npos ) search_on = false;
519 
520  if( search_on )
521  {
522  if (line.find(a_keyword) != string::npos)
523  //if (line.compare(a_keyword) == 0)
524  {
525  //remove field in string
526  line = line.substr(line.find_first_of(sep)+1);
527 
528  //clear the space before the first element in the line string;
529  //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.
530 
531  // Erase all blank stuff before first character
532  line.erase(0, line.find_first_not_of(" !\t\r\n")); // Erase all blank stuff before first character
533  line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
534 
535  size_t pos = 0;
536  size_t pos2 = line.find_first_of(sep_elt, pos);
537 
538  // Check if separators were found
539  if (a_nbElts>1 && pos2 == string::npos)
540  {
541  Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
542  return 1;
543  }
544  else // Read one element, or several (a_nbElts) elements separated with ','
545  {
546  for (int i=0 ; i<a_nbElts ; i++)
547  {
548 
549  // Check if we reach the end of the line before initializing all elements
550  // SS: corrected this incorrect line: if(pos<0)
551  if (pos==string::npos)
552  {
553  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
554  Cerr("***** Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
555  return 1;
556  }
557 
558  // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
559  string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
560 
561  if(ConvertFromString(elt, &ap_return[i]))
562  {
563  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
564  return 1;
565  }
566 
567  //pos = pos2+1;
568  // return string::npos if pos2 not found, meaning we reach the end of the line
569  // SS: corrected this incorrect line pos = (pos2<0) ? -1 : pos2+1 ;
570  pos = (pos2==string::npos) ? string::npos : pos2+1;
571  pos2 = line.find_first_of(sep_elt, pos);
572  }
573  }
574  return 0;
575  }
576  }
577 
578 
579 
580 
581 
582  }
583  // Throw an error message if the tag is mandatory
584  if(a_mandatoryFlag == true)
585  {
586  Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
588  }
589  else
590  {
592  }
593  }
594  else
595  {
596  Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '"<< a_file << "' !" << endl);
597  return 1;
598  }
599 }
600 
601 
602 
603 
604 // =====================================================================
605 // ---------------------------------------------------------------------
606 // ---------------------------------------------------------------------
607 // =====================================================================
608 /*
609  \fn ReadDataASCIIFile
610  \param a_file : string containing the path to the ASCII file
611  \param a_keyword : key related to the data we want to recover
612  \param a2p_return : 2D templated array in which the data will be returned
613  the recovered data will be converted to its type
614  its size should be equal [nb of lines][nb of elts to recover]
615  \param a_nbElts : number of elements to recover (on each line)
616  \param a_nbLines : number of lines to recover
617  \param a_mandatoryFlag : boolean indicating the data to recover is
618  mandatory (KEYWORD_MANDATORY) (error value (=1) will be returned if not found)
619  or optional (KEYWORD_OPTIONAL) (warning value (=2) will be returned if not found)
620  \param a_firstTag : the requested key will be looked for after the first occurence of this string
621  \param a_lastTag : the requested key will be looked for before the first occurence of this string
622  \brief Look for "a_nbLines" lines of "a_nbElts" elts in the "a_file" file matching the "a_keyword" string
623  passed as parameter and return the corresponding value(s) in the "a2p_return" templated 2D array.
624  The first and second dimensions of "a2p_return" correspond to the line and elements respectively
625  Additionnal two parameters allow to search within two specific tags
626  This function expects the following parsing :
627  KEY :
628  FIRST_TAG
629  (...)
630  line1 : elt1,elt2,...,eltN
631  line2 : elt1,elt2,...,eltN
632  (...)
633  lineN : elt1,elt2,...,eltN
634  (...)
635  LAST_TAG
636  \details This function assumes the following separators :
637  ":" is used as separator between the keyworld and the value
638  "#" is used for comment. Every following characters will be discarded
639  "," is used to separate elements if more than one are required
640  \return 0 if success, and positive value otherwise (1 if error, 2 if tag not found).
641 */
642 template<class T>
643 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)
644 {
645  ifstream input_file(a_file.c_str(), ios::in);
646  string line;
647  string sep = ":";
648  string sep_comment = "#";
649  string sep_elt = ",";
650  bool search_on = false;
651 
652  // Check file
653  if(input_file)
654  {
655  while(!input_file.eof())
656  {
657  getline(input_file, line);
658 
659  //remove comment
660  if (line.find(sep_comment) != string::npos) line = line.substr(0, line.find_first_of(sep_comment)) ;
661 
662  if( line.find(a_firstTag) != string::npos) search_on = true;
663  if( line.find(a_lastTag) != string::npos || line.find("eof") != string::npos ) search_on = false;
664 
665  if( search_on )
666  {
667  if (line.find(a_keyword) != string::npos)
668  {
669  for (int l=0 ; l<a_nbLines ; l++)
670  {
671  getline(input_file, line);
672 
673  //remove field in string
674  line = line.substr(line.find_first_of(sep)+1);
675 
676  //clear the space before the first element in the line string;
677  //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.
678 
679  // Erase all blank stuff before and after first character
680  line.erase(0, line.find_first_not_of(" !\t\r\n"));
681  line.erase(line.find_last_not_of(" \t\r\n")+1 , line.length());
682 
683  size_t pos = 0;
684  size_t pos2 = line.find_first_of(sep_elt, pos);
685 
686  // Check if separators were found
687  if (a_nbElts>1 && pos2 == string::npos)
688  {
689  Cerr("***** gOptions::ReadDataASCIIFile() -> The required separator : '" << sep_elt << "' not found for tag: " << a_keyword << endl);
690  return 1;
691  }
692  else // Read one element, or several (a_nbElts) elements separated with ','
693  {
694  for (int i=0 ; i<a_nbElts ; i++)
695  {
696  // Check if we reach the end of the line before initializing all elements
697  // SS: corrected this incorrect line: if(pos<0)
698  if (pos==string::npos)
699  {
700  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file '" << a_file << "'." << endl);
701  Cerr("***** Expected to read " << a_nbElts << " elements, but only " << i+1 << " were found." << endl);
702  return 1;
703  }
704 
705  // Parse the line only if more than 1 elt are requested. Just pick the line otherwise
706  string elt = (a_nbElts>1) ? line.substr(pos, pos2-pos) : line ;
707 
708  if (ConvertFromString(elt, &a2p_return[l][i]))
709  {
710  Cerr("***** gOptions::ReadDataASCIIFile() -> Exception when trying to read tag '" << a_keyword << "' in file " << a_file << endl);
711  return 1;
712  }
713 
714  //pos = pos2+1;
715  // return string::npos if pos2 not found, meaning we reach the end of the line
716  // SS: corrected this incorrect line pos = (pos2<0) ? -1 : pos2+1 ;
717  pos = (pos2==string::npos) ? string::npos : pos2+1;
718  pos2 = line.find_first_of(sep_elt, pos);
719  }
720  }
721  }
722  return 0;
723  }
724  }
725  }
726  // Throw an error message if the tag is mandatory
727  if(a_mandatoryFlag == true)
728  {
729  Cerr("***** gOptions::ReadDataASCIIFile() -> Error when reading file '" << a_file << "'. Tag '" << a_keyword << "' was not found." << endl);
731  }
732  else
733  {
735  }
736  }
737  else
738  {
739  Cerr("***** gOptions::ReadDataASCIIFile() -> Couldn't find or read data-file '"<< a_file << "' !" << endl);
740  return 1;
741  }
742 }
743 
744 
745 
746 
747 // =====================================================================
748 // ---------------------------------------------------------------------
749 // ---------------------------------------------------------------------
750 // =====================================================================
751 /*
752  \fn ConvertFromString
753  \param a_str : string to convert
754  \param a_result : variable which will recover the result
755  \brief Copy the 'a_str' string in the position pointed by 'a_result'
756  \details The only purposes of this function is to have an
757  unified templated conversion function for each type
758  \return 0 if success, and positive value otherwise
759 */
760 int ConvertFromString(const string& a_str, string* a_result)
761 {
762  *a_result = a_str.c_str();
763  return 0;
764 }
765 
766 
767 
768 
769 // =====================================================================
770 // ---------------------------------------------------------------------
771 // ---------------------------------------------------------------------
772 // =====================================================================
773 /*
774  \fn ConvertFromString
775  \param a_str : string to convert
776  \param a_result : variable which will recover the result
777  \brief Convert the 'a_str' string in float and copy the result in the variable pointed by 'a_result'
778  \details Uses strtod to check errors with str to float conversion
779  (implementation similar to c++11 std::stof() ).
780  \return 0 if success, and positive value otherwise
781 */
782 int ConvertFromString(const string& a_str, float* a_result)
783 {
784  const char* p = a_str.c_str();
785  char* end;
786  errno = 0;
787  double val = strtod(p, &end);
788 
789  if (p == end)
790  {
791  Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into float " << endl);
792  return 1;
793  }
794  if (errno == ERANGE)
795  {
796  Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into float " << endl);
797  return 1;
798  }
799 
800  *a_result = static_cast<float>(val);
801 
802  return 0;
803 }
804 
805 
806 
807 
808 // =====================================================================
809 // ---------------------------------------------------------------------
810 // ---------------------------------------------------------------------
811 // =====================================================================
812 /*
813  \fn ConvertFromString
814  \param a_str : string to convert
815  \param a_result : variable which will recover the result
816  \brief Convert the 'a_str' string in double and copy the result in the position pointed by 'a_result'
817  \details Uses strtod to check errors with str to double conversion
818  (implementation similar to c++11 std::stod() ).
819  \return 0 if success, and positive value otherwise
820 */
821 int ConvertFromString(const string& a_str, double* a_result)
822 {
823  const char* p = a_str.c_str();
824  char* end;
825  errno = 0;
826  double val = strtod(p, &end);
827 
828  if (p == end)
829  {
830  Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into double " << endl);
831  return 1;
832  }
833  if (errno == ERANGE)
834  {
835  Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into double " << endl);
836  return 1;
837  }
838 
839  *a_result = val;
840 
841  return 0;
842 }
843 
844 
845 
846 
847 // =====================================================================
848 // ---------------------------------------------------------------------
849 // ---------------------------------------------------------------------
850 // =====================================================================
851 /*
852  \fn ConvertFromString
853  \param a_str : string to convert
854  \param a_result : variable which will recover the result
855  \brief Convert the 'a_str' string in long double and copy the result in the position pointed by 'a_result'
856  \details Uses strtod to check errors with str to ldouble conversion
857  (implementation similar to c++11 std::stod() ).
858  \return 0 if success, and positive value otherwise
859 */
860 int ConvertFromString(const string& a_str, long double* a_result)
861 {
862  const char* p = a_str.c_str();
863  char* end;
864  errno = 0;
865  long double val = strtold(p, &end);
866 
867  if (p == end)
868  {
869  Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into double " << endl);
870  return 1;
871  }
872  if (errno == ERANGE)
873  {
874  Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into double " << endl);
875  return 1;
876  }
877 
878  *a_result = val;
879 
880  return 0;
881 }
882 
883 
884 
885 
886 // =====================================================================
887 // ---------------------------------------------------------------------
888 // ---------------------------------------------------------------------
889 // =====================================================================
890 /*
891  \fn ConvertFromString
892  \param a_str : string to convert
893  \param a_result : variable which will recover the result
894  \brief Convert the 'a_str' string in int and copy the result in the position pointed by 'a_result'
895  \details Uses strtol to check errors with str to int conversion
896  (implementation similar to c++11 std::stoi() ).
897  \return 0 if success, and positive value otherwise
898 */
899 int ConvertFromString(const string& a_str, int* a_result)
900 {
901  const char* p = a_str.c_str();
902  char* end;
903  errno = 0;
904  int64_t val = strtol(p, &end, 10);
905 
906  if (p == end)
907  {
908  Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into int " << endl);
909  return 1;
910  }
911  if (errno==ERANGE || val<INT_MIN || val>INT_MAX)
912  {
913  Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into int " << endl);
914  return 1;
915  }
916 
917  *a_result = static_cast<int>(val);
918 
919  return 0;
920 }
921 
922 
923 
924 
925 // =====================================================================
926 // ---------------------------------------------------------------------
927 // ---------------------------------------------------------------------
928 // =====================================================================
929 /*
930  \fn ConvertFromString
931  \param a_str : string to convert
932  \param a_result : variable which will recover the result
933  \brief Convert the 'a_str' string in int64_t and copy the result in the position pointed by 'a_result'
934  \details Uses strtol to check errors with str to lint conversion
935  (implementation similar to c++11 std::stol() ).
936  \return 0 if success, and positive value otherwise
937 */
938 int ConvertFromString(const string& a_str, int64_t* a_result)
939 {
940  const char* p = a_str.c_str();
941  char* end;
942  errno = 0;
943  int64_t val = strtol(p, &end, 10);
944 
945  if (p == end)
946  {
947  Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into int64_t " << endl);
948  return 1;
949  }
950  if (errno == ERANGE)
951  {
952  Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into int64_t " << endl);
953  return 1;
954  }
955 
956  *a_result = val;
957 
958  return 0;
959 }
960 
961 
962 
963 
964 // =====================================================================
965 // ---------------------------------------------------------------------
966 // ---------------------------------------------------------------------
967 // =====================================================================
968 /*
969  \fn ConvertFromString
970  \param a_str : string to convert
971  \param a_result : variable which will recover the result
972  \brief Convert the 'a_str' string in uint16_t and copy the result in the position pointed by 'a_result'
973  \details Uses strtol to check errors with str to uint8 conversion
974  (implementation similar to c++11 std::stoi() ).
975  \return 0 if success, and positive value otherwise
976 */
977 int ConvertFromString(const string& a_str, uint8_t* a_result)
978 {
979  const char* p = a_str.c_str();
980  char* end;
981  errno = 0;
982  int64_t val = strtol(p, &end, 10);
983 
984  if (p == end)
985  {
986  Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into uint16 " << endl);
987  return 1;
988  }
989  if (errno == ERANGE || val<0 || val>UCHAR_MAX)
990  {
991  Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into uint16 " << endl);
992  return 1;
993  }
994 
995  *a_result = val;
996 
997  return 0;
998 }
999 
1000 
1001 
1002 
1003 // =====================================================================
1004 // ---------------------------------------------------------------------
1005 // ---------------------------------------------------------------------
1006 // =====================================================================
1007 /*
1008  \fn ConvertFromString
1009  \param a_str : string to convert
1010  \param a_result : variable which will recover the result
1011  \brief Convert the 'a_str' string in uint16_t and copy the result in the position pointed by 'a_result'
1012  \details Uses strtol to check errors with str to uint16 conversion
1013  (implementation similar to c++11 std::stoi() ).
1014  \return 0 if success, and positive value otherwise
1015 */
1016 int ConvertFromString(const string& a_str, uint16_t* a_result)
1017 {
1018  const char* p = a_str.c_str();
1019  char* end;
1020  errno = 0;
1021  int64_t val = strtol(p, &end, 10);
1022 
1023  if (p == end)
1024  {
1025  Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into uint16 " << endl);
1026  return 1;
1027  }
1028  if (errno == ERANGE || val<0 || val>USHRT_MAX)
1029  {
1030  Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into uint16 " << endl);
1031  return 1;
1032  }
1033 
1034  *a_result = val;
1035 
1036  return 0;
1037 }
1038 
1039 
1040 
1041 
1042 // =====================================================================
1043 // ---------------------------------------------------------------------
1044 // ---------------------------------------------------------------------
1045 // =====================================================================
1046 /*
1047  \fn ConvertFromString
1048  \param a_str : string to convert
1049  \param a_result : variable which will recover the result
1050  \brief Convert the 'a_str' string in uint32_t and copy the result in the position pointed by 'a_result'
1051  \details Uses strtol to check errors with str to uint32 conversion
1052  (implementation similar to c++11 std::stoi() ).
1053  \return 0 if success, and positive value otherwise
1054 */
1055 int ConvertFromString(const string& a_str, uint32_t* a_result)
1056 {
1057  const char* p = a_str.c_str();
1058  char* end;
1059  errno = 0;
1060  int64_t val = strtol(p, &end, 10);
1061 
1062  if (p == end)
1063  {
1064  Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into uint32 " << endl);
1065  return 1;
1066  }
1067  if (errno == ERANGE || val<0 || val>UINT_MAX)
1068  {
1069  Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into uint32 " << endl);
1070  return 1;
1071  }
1072 
1073  *a_result = val;
1074 
1075  return 0;
1076 }
1077 
1078 
1079 
1080 
1081 // =====================================================================
1082 // ---------------------------------------------------------------------
1083 // ---------------------------------------------------------------------
1084 // =====================================================================
1085 /*
1086  \fn ConvertFromString
1087  \param a_str : string to convert
1088  \param a_result : variable which will recover the result
1089  \brief Convert the 'a_str' string in bool and copy the result in the position pointed by 'a_result'
1090  \details Uses strtol to check errors with str to bool conversion
1091  (implementation similar to c++11 std::stoi() ).
1092  \return 0 if success, and positive value otherwise
1093 */
1094 int ConvertFromString(const string& a_str, bool* a_result)
1095 {
1096  const char* p = a_str.c_str();
1097  char* end;
1098  errno = 0;
1099  int64_t val = strtol(p, &end, 10);
1100 
1101  if (p == end)
1102  {
1103  Cerr("***** gOptions::ConvertFromString() -> Invalid argument exception while trying to convert '" << a_str << "' into bool " << endl);
1104  return 1;
1105  }
1106  if (errno == ERANGE || val<0 || val>1)
1107  {
1108  Cerr("***** gOptions::ConvertFromString() -> Out of range exception while trying to convert '" << a_str << "' into bool " << endl);
1109  return 1;
1110  }
1111 
1112  *a_result = val;
1113 
1114  return 0;
1115 }
1116 
1117 
1118 
1119 
1120 // =====================================================================
1121 // ---------------------------------------------------------------------
1122 // ---------------------------------------------------------------------
1123 // =====================================================================
1124 /*
1125  \fn GetFileFromPath()
1126  \param a_pathToFile
1127  \brief Simply return the file from a path string passed in parameter
1128  \return The path.
1129 */
1130 string GetFileFromPath(const string& a_pathToFile)
1131 {
1132  string path = a_pathToFile;
1133 
1134  int pos = path.find_last_of(OS_SEP);
1135  if (path.find_last_of(OS_SEP) == string::npos)
1136  return path;
1137 
1138  path = path.substr(pos+1);
1139  return path;
1140 }
1141 
1142 
1143 
1144 
1145 // =====================================================================
1146 // ---------------------------------------------------------------------
1147 // ---------------------------------------------------------------------
1148 // =====================================================================
1149 /*
1150  \fn GetPathOfFile()
1151  \param a_pathToFile
1152  \brief Simply return the path to the directory of a file path string passed in parameter
1153  \return The path.
1154 */
1155 string GetPathOfFile(const string& a_pathToFile)
1156 {
1157  string path = a_pathToFile;
1158 
1159  int pos = path.find_last_of(OS_SEP);
1160  if (path.find_last_of(OS_SEP) == string::npos)
1161  return "";
1162 
1163  path = path.substr(0,pos+1);
1164 
1165  return path;
1166 }
1167 
1168 
1169 /*
1170  \fn string ConvertAllSlashOcurrencesToBackSlash()
1171  \param const string& a_path
1172  \brief Simply convert all occurrences of "/" to "\"
1173  \return A new converted string
1174 */
1175 string ConvertAllSlashOccurrencesToBackSlash(const string& a_path)
1176 {
1177  string result = a_path;
1178  size_t position;
1179  while ( (position = result.find_first_of("/")) != string::npos )
1180  {
1181  result.replace(position,1,"\\");
1182  }
1183  return result;
1184 }
1185 
1186 
1187 /*
1188  \fn bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps)
1189  \param a : 1st FLTNB nb to compare
1190  \param b : 2nd FLTNB nb to compare
1191  \param a_eps : epsilon for comparison
1192  \brief Comparison of FLTNB numbers
1193  \return true if equal according to the provided epsilon, false otherwise
1194 */
1195 bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps)
1196 {
1197  FLTNB absA = abs(a);
1198  FLTNB absB = abs(b);
1199  FLTNB diff = abs(a - b);
1200 
1201  if (a == b)
1202  {
1203  return true;
1204  }
1205  else if (a == 0 ||
1206  b == 0 ||
1207  diff < std::numeric_limits<FLTNB>::min())
1208  { // a or b is 0, or extremely close to it
1209  return diff < (a_eps * std::numeric_limits<FLTNB>::min() );
1210  }
1211  else
1212  { // relative error
1213  return diff / min((absA + absB), std::numeric_limits<FLTNB>::max()) < a_eps;
1214  }
1215 }
1216 
1217 
1218 // =====================================================================
1219 // ---------------------------------------------------------------------
1220 // ---------------------------------------------------------------------
1221 // =====================================================================
1222 // Explicit template instantiation
1223 // (that way no one would use the templated versions of these functions for not yet implemented type (long double, unsigned, ect..) )
1224 template int ReadStringOption<string>(const string& a_input, string* ap_return, int a_nbElts, const string& sep, const string& a_option);
1225 template int ReadStringOption<int>(const string& a_input, int* ap_return, int a_nbElts, const string& sep, const string& a_option);
1226 template int ReadStringOption<int64_t>(const string& a_input, int64_t* ap_return, int a_nbElts, const string& sep, const string& a_option);
1227 template int ReadStringOption<float>(const string& a_input, float* ap_return, int a_nbElts, const string& sep, const string& a_option);
1228 template int ReadStringOption<double>(const string& a_input, double* ap_return, int a_nbElts, const string& sep, const string& a_option);
1229 template int ReadStringOption<long double>(const string& a_input, long double* ap_return, int a_nbElts, const string& sep, const string& a_option);
1230 template int ReadStringOption<uint8_t>(const string& a_input, uint8_t* ap_return, int a_nbElts, const string& sep, const string& a_option);
1231 template int ReadStringOption<uint16_t>(const string& a_input, uint16_t* ap_return, int a_nbElts, const string& sep, const string& a_option);
1232 template int ReadStringOption<uint32_t>(const string& a_input, uint32_t* ap_return, int a_nbElts, const string& sep, const string& a_option);
1233 template int ReadStringOption<bool>(const string& a_input, bool* ap_return, int a_nbElts, const string& sep, const string& a_option);
1234 
1235 template int ReadDataASCIIFile<string>(const string& a_file, const string& a_keyword, string* ap_return, int a_nbElts, bool a_mandatoryFlag);
1236 template int ReadDataASCIIFile<int>(const string& a_file, const string& a_keyword, int* ap_return, int a_nbElts, bool a_mandatoryFlag);
1237 template int ReadDataASCIIFile<int64_t>(const string& a_file, const string& a_keyword, int64_t* ap_return, int a_nbElts, bool a_mandatoryFlag);
1238 template int ReadDataASCIIFile<float>(const string& a_file, const string& a_keyword, float* ap_return, int a_nbElts, bool a_mandatoryFlag);
1239 template int ReadDataASCIIFile<double>(const string& a_file, const string& a_keyword, double* ap_return, int a_nbElts, bool a_mandatoryFlag);
1240 template int ReadDataASCIIFile<long double>(const string& a_file, const string& a_keyword, long double* ap_return, int a_nbElts, bool a_mandatoryFlag);
1241 template int ReadDataASCIIFile<uint8_t>(const string& a_file, const string& a_keyword, uint8_t* ap_return, int a_nbElts, bool a_mandatoryFlag);
1242 template int ReadDataASCIIFile<uint16_t>(const string& a_file, const string& a_keyword, uint16_t* ap_return, int a_nbElts, bool a_mandatoryFlag);
1243 template int ReadDataASCIIFile<uint32_t>(const string& a_file, const string& a_keyword, uint32_t* ap_return, int a_nbElts, bool a_mandatoryFlag);
1244 template int ReadDataASCIIFile<bool>(const string& a_file, const string& a_keyword, bool* ap_return, int a_nbElts, bool a_mandatoryFlag);
1245 
1246 template int ReadDataASCIIFile<string>(const string& a_file, const string& a_keyword, string* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1247 template int ReadDataASCIIFile<int>(const string& a_file, const string& a_keyword, int* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1248 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);
1249 template int ReadDataASCIIFile<float>(const string& a_file, const string& a_keyword, float* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1250 template int ReadDataASCIIFile<double>(const string& a_file, const string& a_keyword, double* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1251 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);
1252 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);
1253 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);
1254 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);
1255 template int ReadDataASCIIFile<bool>(const string& a_file, const string& a_keyword, bool* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1256 
1257 template int ReadDataASCIIFile<string>(const string& a_file, const string& a_keyword, string** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1258 template int ReadDataASCIIFile<int>(const string& a_file, const string& a_keyword, int** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1259 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);
1260 template int ReadDataASCIIFile<float>(const string& a_file, const string& a_keyword, float** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1261 template int ReadDataASCIIFile<double>(const string& a_file, const string& a_keyword, double** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1262 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);
1263 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);
1264 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);
1265 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);
1266 template int ReadDataASCIIFile<bool>(const string& a_file, const string& a_keyword, bool** ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
1267 
1268 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);
1269 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);
1270 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);
1271 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);
1272 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);
1273 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);
1274 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);
1275 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);
1276 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);
1277 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);
1278 
1279 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);
1280 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);
1281 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);
1282 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);
1283 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);
1284 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);
1285 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);
1286 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);
1287 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);
1288 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);
string ConvertAllSlashOccurrencesToBackSlash(const string &a_path)
template int ReadStringOption< bool >(const string &a_input, bool *ap_return, int a_nbElts, const string &sep, const string &a_option)
#define Cerr(MESSAGE)
int ReadStringOption(const string &a_input, T *ap_return, int a_nbElts, const string &a_sep, const string &a_option)
Parse the &#39;a_input&#39; string corresponding to the &#39;a_option&#39; into &#39;a_nbElts&#39; elements, using the &#39;sep&#39; separator. The results are returned in the templated &#39;ap_return&#39; dynamic templated array. Call "ConvertFromString()" to perform the correct conversion depending on the type of the data to convert.
template int ReadDataASCIIFile< int >(const string &a_file, const string &a_keyword, int *ap_return, int a_nbElts, bool a_mandatoryFlag)
template int ReadStringOption< int >(const string &a_input, int *ap_return, int a_nbElts, const string &sep, const string &a_option)
template int ReadDataASCIIFile< uint32_t >(const string &a_file, const string &a_keyword, uint32_t *ap_return, int a_nbElts, bool a_mandatoryFlag)
template int ReadStringOption< uint16_t >(const string &a_input, uint16_t *ap_return, int a_nbElts, const string &sep, const string &a_option)
bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps)
Comparison of FLTNB numbers.
#define KEYWORD_MANDATORY_NOT_FOUND
template int ReadStringOption< string >(const string &a_input, string *ap_return, int a_nbElts, const string &sep, const string &a_option)
template int ReadDataASCIIFile< long double >(const string &a_file, const string &a_keyword, long double *ap_return, int a_nbElts, bool a_mandatoryFlag)
template int ReadDataASCIIFile< uint16_t >(const string &a_file, const string &a_keyword, uint16_t *ap_return, int a_nbElts, bool a_mandatoryFlag)
template int ReadDataASCIIFile< int64_t >(const string &a_file, const string &a_keyword, int64_t *ap_return, int a_nbElts, bool a_mandatoryFlag)
string GetPathOfFile(const string &a_pathToFile)
Simply return the path to the directory of a file path string passed in parameter.
template int ReadStringOption< int64_t >(const string &a_input, int64_t *ap_return, int a_nbElts, const string &sep, const string &a_option)
template int ReadStringOption< uint32_t >(const string &a_input, uint32_t *ap_return, int a_nbElts, const string &sep, const string &a_option)
template int ReadDataASCIIFile< double >(const string &a_file, const string &a_keyword, double *ap_return, int a_nbElts, bool a_mandatoryFlag)
template int ReadStringOption< uint8_t >(const string &a_input, uint8_t *ap_return, int a_nbElts, const string &sep, const string &a_option)
#define KEYWORD_OPTIONAL_NOT_FOUND
template int ReadStringOption< long double >(const string &a_input, long double *ap_return, int a_nbElts, const string &sep, const string &a_option)
int ReadDataASCIIFile(const string &a_file, const string &a_keyword, T *ap_return, int a_nbElts, bool a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter a...
template int ReadStringOption< float >(const string &a_input, float *ap_return, int a_nbElts, const string &sep, const string &a_option)
template int ReadDataASCIIFile< string >(const string &a_file, const string &a_keyword, string *ap_return, int a_nbElts, bool a_mandatoryFlag)
template int ReadStringOption< double >(const string &a_input, double *ap_return, int a_nbElts, const string &sep, const string &a_option)
string GetFileFromPath(const string &a_pathToFile)
Simply return the file from a path string passed in parameter.
template int ReadDataASCIIFile< bool >(const string &a_file, const string &a_keyword, bool *ap_return, int a_nbElts, bool a_mandatoryFlag)
template int ReadDataASCIIFile< uint8_t >(const string &a_file, const string &a_keyword, uint8_t *ap_return, int a_nbElts, bool a_mandatoryFlag)
int ConvertFromString(const string &a_str, string *a_result)
Copy the &#39;a_str&#39; string in the position pointed by &#39;a_result&#39;.
template int ReadDataASCIIFile< float >(const string &a_file, const string &a_keyword, float *ap_return, int a_nbElts, bool a_mandatoryFlag)