CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gOptions.hh
Go to the documentation of this file.
1 /*
2 This file is part of CASToR.
3 
4  CASToR is free software: you can redistribute it and/or modify it under the
5  terms of the GNU General Public License as published by the Free Software
6  Foundation, either version 3 of the License, or (at your option) any later
7  version.
8 
9  CASToR is distributed in the hope that it will be useful, but WITHOUT ANY
10  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  details.
13 
14  You should have received a copy of the GNU General Public License along with
15  CASToR (in file GNU_GPL.TXT). If not, see <http://www.gnu.org/licenses/>.
16 
17 Copyright 2017-2018 all CASToR contributors listed below:
18 
19  --> current contributors: Thibaut MERLIN, Simon STUTE, Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Mael MILLARDET
20  --> past contributors: Valentin VIELZEUF
21 
22 This is CASToR version 2.0.
23 */
24 
32 #ifndef GOPTIONS_HH
33 #define GOPTIONS_HH 1
34 
35 // =====================================================================
36 // ---------------------------------------------------------------------
37 // ---------------------------------------------------------------------
38 // =====================================================================
48 #define KEYWORD_MANDATORY true
49 
50 #define KEYWORD_OPTIONAL false
51 
52 #define KEYWORD_MANDATORY_NOT_FOUND 1
53 
54 #define KEYWORD_OPTIONAL_SUCCESS 0
55 
56 #define KEYWORD_OPTIONAL_ERROR 1
57 
58 #define KEYWORD_OPTIONAL_NOT_FOUND 2
59 
61 // =====================================================================
62 // ---------------------------------------------------------------------
63 // ---------------------------------------------------------------------
64 // =====================================================================
65 // Functions for command line parameters reading
66 // Functions parsing a string composed of several numbers separated by commas.
79 template<typename T> int ReadStringOption(const string& a_input, T* ap_return, int a_nbElts, const string& sep, const string& a_option);
80 
81 // =====================================================================
82 // ---------------------------------------------------------------------
83 // ---------------------------------------------------------------------
84 // =====================================================================
85 // Functions for ASCII file input reading
106 template<typename T> int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T* ap_return, int a_nbElts, bool a_mandatoryFlag);
107 
134 template<typename T> int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T* ap_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
135 
163 template<typename T> int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T** a2p_return, int a_nbElts, int a_nbLines, bool a_mandatoryFlag);
164 
193 template<typename T> 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);
194 
229 template<typename T> 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);
230 
231 // =====================================================================
232 // ---------------------------------------------------------------------
233 // ---------------------------------------------------------------------
234 // =====================================================================
235 // Functions for data conversion
244 int ConvertFromString(const string& a_str, string* a_result);
245 
255 int ConvertFromString(const string& a_str, float* a_result);
256 
266 int ConvertFromString(const string& a_str, double* a_result);
267 
277 int ConvertFromString(const string& a_str, long double* a_result);
278 
288 int ConvertFromString(const string& a_str, int* a_result);
289 
299 int ConvertFromString(const string& a_str, int64_t* a_result);
300 
310 int ConvertFromString(const string& a_str, uint8_t* a_result);
311 
321 int ConvertFromString(const string& a_str, uint16_t* a_result);
322 
332 int ConvertFromString(const string& a_str, uint32_t* a_result);
333 
343 int ConvertFromString(const string& a_str, bool* a_result);
344 
345 
354 bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps);
355 
356 
363 string GetFileFromPath(const string& a_pathToFile);
364 
371 string GetPathOfFile(const string& a_pathToFile);
372 
379 string ConvertAllSlashOccurrencesToBackSlash(const string& a_path);
380 
381 #endif
string ConvertAllSlashOccurrencesToBackSlash(const string &a_path)
Definition: gOptions.cc:1186
#define FLTNB
Definition: gVariables.hh:81
string GetFileFromPath(const string &a_pathToFile)
Simply return the file from a path string passed in parameter.
Definition: gOptions.cc:1141
int ConvertFromString(const string &a_str, string *a_result)
Copy the 'a_str' string in the position pointed by 'a_result'.
Definition: gOptions.cc:771
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:123
string GetPathOfFile(const string &a_pathToFile)
Simply return the path to the directory of a file path string passed in parameter.
Definition: gOptions.cc:1166
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:62
bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps)
Comparison of FLTNB numbers.
Definition: gOptions.cc:1206