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