211 G4cout <<
"G4tgrUtils::GetDouble() - Processing: " 212 << str <<
" default unit " << unitval <<
G4endl;
215 if( str ==
"DBL_MAX" ) {
217 }
else if( str ==
"DBL_MIN" ) {
219 }
else if( str ==
"FLT_MAX" ) {
221 }
else if( str ==
"FLT_MIN" ) {
223 }
else if( str ==
"INT_MAX" ) {
225 }
else if( str ==
"INT_MIN" ) {
229 const char* cstr = str.c_str();
230 std::set<G4int> separators;
231 separators.insert(-1);
233 for(
G4int ii=0; ii<strlen; ii++)
236 if( cs ==
'*' || cs ==
'/' || cs ==
'(' || cs ==
')' )
238 separators.insert(ii);
240 else if( cs ==
'+' || cs ==
'-' )
245 || ( (cstr[ii-1] !=
'E') && (cstr[ii-1] !=
'e') )
248 separators.insert(ii);
252 separators.insert(strlen);
257 std::set<G4int>::const_iterator site, site2;
258 site = separators.begin();
259 site2 = site; site2++;
260 for( ; site2 != separators.end(); site++,site2++)
265 G4cout <<
" Loop to find word between " << *site
266 <<
" " << *site2 <<
G4endl;
270 if( *site != -1 ) { strnew += str.substr(*site,1); }
272 G4int wlen = (*site2)-(*site)-1;
276 word = str.substr((*site)+1,(*site2)-(*site)-1);
292 const char* cword = word.c_str();
293 if( cword[0] ==
'$' )
297 if( parstr.substr(0,1) ==
"-" )
302 if( parstr.substr(0,1) ==
"-" )
309 G4cout <<
" G4tgrutils::GetDouble() - Param found: " 310 << word <<
" in string " << str
311 <<
" , substituted by " << parstr <<
G4endl;
321 if( (*site != -1) && (cstr[*site] ==
')') )
323 G4String ErrMessage =
"There cannot be a ')' before a number: " 324 + word +
" in string: " + str;
325 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
329 if( (*site2 != strlen) && (cstr[*site2] ==
'(') )
331 G4String ErrMessage =
"There cannot be a '(' after a number: " 332 + word +
" in string: " + str;
333 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
343 if( isdigit(word[0]) )
345 G4String ErrMessage =
"String words cannot start with a digit: " 346 + word +
" in string: " + str;
347 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
356 if( (*site2 == strlen) || (cstr[*site2] !=
'(') )
358 G4String ErrMessage =
"There must be a '(' after a function: " 359 + word +
" in string: " + str;
360 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
371 || ( (cstr[*site] !=
'*') && (cstr[*site] !=
'/') ) )
373 G4String ErrMess =
"There must be a '*' before a unit definition: " 374 + word +
" in string " + str;
375 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
395 G4String ErrMess =
"String word is not a parameter, nor a unit\n";
396 +
G4String(
"definition nor a function: ") + word
398 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
409 G4String ErrMessage =
"Evaluator error: " + strnew;
410 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
414 if( nUnits == 0 ) { val *= unitval; }
419 G4cout <<
" G4tgrUtils::GetDouble() - RESULT= " << val <<
G4endl 420 <<
" from string: " << str <<
" converted to: " << strnew.c_str()
421 <<
" with unit val: " << unitval <<
G4endl;
G4String FindParameter(const G4String &name, G4bool exists=true)
void print_error(G4int status) const
static G4String ConvertToString(G4bool boolVal)
static G4bool IsNumber(const G4String &str)
static G4double GetValueOf(const G4String &)
G4GLOB_DLL std::ostream G4cout
static G4int GetVerboseLevel()
static G4tgrParameterMgr * GetInstance()
static G4bool IsFunction(const G4String &word)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4bool WordIsUnit(const G4String &word)
static G4ThreadLocal G4tgrEvaluator * theEvaluator