CASToR  3.0
Tomographic Reconstruction (PET/SPECT/CT)
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-2019 all CASToR contributors listed below:
18 
19  --> Didier BENOIT, Claude COMTAT, Marina FILIPOVIC, Thibaut MERLIN, Mael MILLARDET, Simon STUTE, Valentin VIELZEUF
20 
21 This is CASToR version 3.0.
22 */
23 
31 #ifndef GOPTIONS_HH
32 #define GOPTIONS_HH 1
33 
34 // =====================================================================
35 // ---------------------------------------------------------------------
36 // ---------------------------------------------------------------------
37 // =====================================================================
47 #define KEYWORD_MANDATORY true
48 
49 #define KEYWORD_OPTIONAL false
50 
51 #define KEYWORD_MANDATORY_NOT_FOUND 1
52 
53 #define KEYWORD_OPTIONAL_SUCCESS 0
54 
55 #define KEYWORD_OPTIONAL_ERROR 1
56 
57 #define KEYWORD_OPTIONAL_NOT_FOUND 2
58 
60 // =====================================================================
61 // ---------------------------------------------------------------------
62 // ---------------------------------------------------------------------
63 // =====================================================================
64 // Functions for command line parameters reading
65 // Functions parsing a string composed of several numbers separated by commas.
78 template<typename T> int ReadStringOption(const string& a_input, T* ap_return, int a_nbElts, const string& sep, const string& a_option);
79 
80 // =====================================================================
81 // ---------------------------------------------------------------------
82 // ---------------------------------------------------------------------
83 // =====================================================================
84 // Functions for ASCII file input reading
105 template<typename T> int ReadDataASCIIFile(const string& a_file, const string& a_keyword, T* ap_return, int a_nbElts, bool a_mandatoryFlag);
106 
133 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);
134 
162 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);
163 
192 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);
193 
228 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);
229 
230 // =====================================================================
231 // ---------------------------------------------------------------------
232 // ---------------------------------------------------------------------
233 // =====================================================================
234 // Functions for data conversion
243 int ConvertFromString(const string& a_str, string* a_result);
244 
254 int ConvertFromString(const string& a_str, float* a_result);
255 
265 int ConvertFromString(const string& a_str, double* a_result);
266 
276 int ConvertFromString(const string& a_str, long double* a_result);
277 
287 int ConvertFromString(const string& a_str, int* a_result);
288 
298 int ConvertFromString(const string& a_str, int64_t* a_result);
299 
309 int ConvertFromString(const string& a_str, uint8_t* a_result);
310 
320 int ConvertFromString(const string& a_str, uint16_t* a_result);
321 
331 int ConvertFromString(const string& a_str, uint32_t* a_result);
332 
342 int ConvertFromString(const string& a_str, bool* a_result);
343 
344 
353 bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps);
354 
355 
362 string GetFileFromPath(const string& a_pathToFile);
363 
370 string GetPathOfFile(const string& a_pathToFile);
371 
378 string ConvertAllSlashOccurrencesToBackSlash(const string& a_path);
379 
380 #endif
string ConvertAllSlashOccurrencesToBackSlash(const string &a_path)
Definition: gOptions.cc:1197
#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:1152
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;.
Definition: gOptions.cc:782
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:129
string GetPathOfFile(const string &a_pathToFile)
Simply return the path to the directory of a file path string passed in parameter.
Definition: gOptions.cc:1177
int ReadStringOption(const string &a_input, T *ap_return, int a_nbElts, const string &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.
Definition: gOptions.cc:50
bool FLTNBIsEqual(FLTNB a, FLTNB b, FLTNB a_eps)
Comparison of FLTNB numbers.
Definition: gOptions.cc:1217