Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // G4tgrFileIn implementation 26 // G4tgrFileIn implementation 27 // 27 // 28 // Author: P.Arce, CIEMAT (November 2007) 28 // Author: P.Arce, CIEMAT (November 2007) 29 // ------------------------------------------- 29 // -------------------------------------------------------------------- 30 30 31 #include "globals.hh" 31 #include "globals.hh" 32 32 33 #include <iostream> 33 #include <iostream> 34 #include <fstream> 34 #include <fstream> 35 #include <sstream> 35 #include <sstream> 36 36 37 #include "G4tgrFileIn.hh" 37 #include "G4tgrFileIn.hh" 38 #include "G4tgrMessenger.hh" 38 #include "G4tgrMessenger.hh" 39 #include "G4tgrUtils.hh" 39 #include "G4tgrUtils.hh" 40 #include "G4UIcommand.hh" 40 #include "G4UIcommand.hh" 41 41 42 G4ThreadLocal std::vector<G4tgrFileIn*>* G4tgr 42 G4ThreadLocal std::vector<G4tgrFileIn*>* G4tgrFileIn::theInstances = nullptr; 43 43 44 // ------------------------------------------- 44 // -------------------------------------------------------------------- 45 G4tgrFileIn::G4tgrFileIn() 45 G4tgrFileIn::G4tgrFileIn() 46 { 46 { 47 if(theInstances == nullptr) 47 if(theInstances == nullptr) 48 { 48 { 49 theInstances = new std::vector<G4tgrFileIn 49 theInstances = new std::vector<G4tgrFileIn*>; 50 } 50 } 51 } 51 } 52 52 53 // ------------------------------------------- 53 // -------------------------------------------------------------------- 54 G4tgrFileIn::~G4tgrFileIn() 54 G4tgrFileIn::~G4tgrFileIn() 55 { 55 { 56 delete theInstances; 56 delete theInstances; 57 theInstances = nullptr; 57 theInstances = nullptr; 58 /* 58 /* 59 for( auto vfcite = theInstances->cbegin(); 59 for( auto vfcite = theInstances->cbegin(); 60 vfcite != theInstances->cend(); 60 vfcite != theInstances->cend(); ++vfcite) 61 { 61 { 62 delete *vfcite; 62 delete *vfcite; 63 } 63 } 64 */ 64 */ 65 } 65 } 66 66 67 // ------------------------------------------- 67 // -------------------------------------------------------------------- 68 G4tgrFileIn& G4tgrFileIn::GetInstance(const G4 68 G4tgrFileIn& G4tgrFileIn::GetInstance(const G4String& filename) 69 { 69 { 70 if(theInstances == nullptr) 70 if(theInstances == nullptr) 71 { 71 { 72 theInstances = new std::vector<G4tgrFileIn 72 theInstances = new std::vector<G4tgrFileIn*>; 73 } 73 } 74 74 75 std::vector<G4tgrFileIn*>::const_iterator vf 75 std::vector<G4tgrFileIn*>::const_iterator vfcite; 76 for(vfcite = theInstances->cbegin(); vfcite 76 for(vfcite = theInstances->cbegin(); vfcite != theInstances->cend(); ++vfcite) 77 { 77 { 78 if((*vfcite)->GetName() == filename) 78 if((*vfcite)->GetName() == filename) 79 { 79 { 80 return *(*vfcite); 80 return *(*vfcite); 81 } 81 } 82 } 82 } 83 83 84 G4tgrFileIn* instance = nullptr; 84 G4tgrFileIn* instance = nullptr; 85 if(vfcite == theInstances->cend()) 85 if(vfcite == theInstances->cend()) 86 { 86 { 87 instance = new G4tgrFileIn(filename); 87 instance = new G4tgrFileIn(filename); 88 88 89 instance->theCurrentFile = -1; 89 instance->theCurrentFile = -1; 90 instance->OpenNewFile(filename.c_str()); 90 instance->OpenNewFile(filename.c_str()); 91 91 92 theInstances->push_back(instance); 92 theInstances->push_back(instance); 93 } 93 } 94 94 95 return *instance; 95 return *instance; 96 } 96 } 97 97 98 // ------------------------------------------- 98 // -------------------------------------------------------------------- 99 void G4tgrFileIn::OpenNewFile(const char* file 99 void G4tgrFileIn::OpenNewFile(const char* filename) 100 { 100 { 101 ++theCurrentFile; 101 ++theCurrentFile; 102 std::ifstream* fin = new std::ifstream(filen 102 std::ifstream* fin = new std::ifstream(filename); 103 theFiles.push_back(fin); 103 theFiles.push_back(fin); 104 104 105 theLineNo.push_back(0); 105 theLineNo.push_back(0); 106 106 107 theNames.push_back(filename); 107 theNames.push_back(filename); 108 108 109 #ifndef OS_SUN_4_2 109 #ifndef OS_SUN_4_2 110 if(!fin->is_open()) 110 if(!fin->is_open()) 111 { 111 { 112 G4String ErrMessage = "Input file does not 112 G4String ErrMessage = "Input file does not exist: " + G4String(filename); 113 G4Exception("G4tgrFileIn::OpenNewFile()", 113 G4Exception("G4tgrFileIn::OpenNewFile()", "InvalidInput", FatalException, 114 ErrMessage); 114 ErrMessage); 115 } 115 } 116 #endif 116 #endif 117 } 117 } 118 118 119 // ------------------------------------------- 119 // -------------------------------------------------------------------- 120 G4tgrFileIn& G4tgrFileIn::GetInstanceOpened(co 120 G4tgrFileIn& G4tgrFileIn::GetInstanceOpened(const G4String& filename) 121 { 121 { 122 G4tgrFileIn& filein = G4tgrFileIn::GetInstan 122 G4tgrFileIn& filein = G4tgrFileIn::GetInstance(filename); 123 if(filein.GetName() != filename) 123 if(filein.GetName() != filename) 124 { 124 { 125 G4String ErrMessage = "File not opened yet 125 G4String ErrMessage = "File not opened yet: " + filename; 126 G4Exception("G4tgrFileIn::GetInstanceOpene 126 G4Exception("G4tgrFileIn::GetInstanceOpened()", "InvalidInput", 127 FatalException, ErrMessage); 127 FatalException, ErrMessage); 128 } 128 } 129 else 129 else 130 { 130 { 131 return filein; 131 return filein; 132 } 132 } 133 return filein; // to avoid compilation warn 133 return filein; // to avoid compilation warnings 134 } 134 } 135 135 136 // ------------------------------------------- 136 // -------------------------------------------------------------------- 137 G4int G4tgrFileIn::GetWordsInLine(std::vector< 137 G4int G4tgrFileIn::GetWordsInLine(std::vector<G4String>& wordlist) 138 { 138 { 139 G4int isok = 1; 139 G4int isok = 1; 140 140 141 //---------- Read a line of file: 141 //---------- Read a line of file: 142 // NOTE: cannot be read with a ist 142 // NOTE: cannot be read with a istream_iterator, 143 // because it uses G4cout, and the 143 // because it uses G4cout, and then doesn't read '\n' 144 //----- Clear wordlist 144 //----- Clear wordlist 145 G4int wsiz = (G4int)wordlist.size(); << 145 G4int wsiz = wordlist.size(); 146 G4int ii; 146 G4int ii; 147 for(ii = 0; ii < wsiz; ++ii) 147 for(ii = 0; ii < wsiz; ++ii) 148 { 148 { 149 wordlist.pop_back(); 149 wordlist.pop_back(); 150 } 150 } 151 151 152 //---------- Loop lines while there is an en 152 //---------- Loop lines while there is an ending '\' or line is blank 153 const G4int NMAXLIN = 1000; 153 const G4int NMAXLIN = 1000; 154 char ltemp[NMAXLIN]; // there won't be line 154 char ltemp[NMAXLIN]; // there won't be lines longer than NMAXLIN characters 155 for(;;) 155 for(;;) 156 { 156 { 157 (theLineNo[theCurrentFile])++; 157 (theLineNo[theCurrentFile])++; 158 for(ii = 0; ii < NMAXLIN; ++ii) 158 for(ii = 0; ii < NMAXLIN; ++ii) 159 { 159 { 160 ltemp[ii] = ' '; 160 ltemp[ii] = ' '; 161 } 161 } 162 theFiles[theCurrentFile]->getline(ltemp, N 162 theFiles[theCurrentFile]->getline(ltemp, NMAXLIN); 163 163 164 //---------- Check for lines longer than N 164 //---------- Check for lines longer than NMAXLIN character 165 for(ii = 0; ii < NMAXLIN; ++ii) 165 for(ii = 0; ii < NMAXLIN; ++ii) 166 { 166 { 167 if(ltemp[ii] == '\0') 167 if(ltemp[ii] == '\0') 168 { 168 { 169 break; 169 break; 170 } 170 } 171 } 171 } 172 if(ii == NMAXLIN - 1) 172 if(ii == NMAXLIN - 1) 173 { 173 { 174 ErrorInLine(); 174 ErrorInLine(); 175 G4String ErrMessage = "Too long line. Pl 175 G4String ErrMessage = "Too long line. Please split it " + 176 G4String("putting 176 G4String("putting a '\\' at the end!"); 177 G4Exception("G4tgrFileIn::GetWordsInLine 177 G4Exception("G4tgrFileIn::GetWordsInLine()", "InvalidInput", 178 FatalException, ErrMessage); 178 FatalException, ErrMessage); 179 } 179 } 180 180 181 //---------- End of file 181 //---------- End of file 182 if(EndOfFile()) 182 if(EndOfFile()) 183 { 183 { 184 return 0; 184 return 0; 185 } 185 } 186 186 187 //---------- Convert line read to istrstre 187 //---------- Convert line read to istrstream to split it in words 188 std::istringstream istr_line(ltemp); 188 std::istringstream istr_line(ltemp); 189 189 190 //--------- Count how many words are there 190 //--------- Count how many words are there in ltemp 191 // this shouln't be needed, but S 191 // this shouln't be needed, but SUN compiler has problems... 192 G4int NoWords = 0; 192 G4int NoWords = 0; 193 char* tt = ltemp; 193 char* tt = ltemp; 194 194 195 G4String stemp(ltemp); 195 G4String stemp(ltemp); 196 do 196 do 197 { 197 { 198 if(*tt != ' ' && *(tt) != '\0') 198 if(*tt != ' ' && *(tt) != '\0') 199 { 199 { 200 if(tt == ltemp) 200 if(tt == ltemp) 201 { 201 { 202 ++NoWords; 202 ++NoWords; 203 #ifdef G4VERBOSE 203 #ifdef G4VERBOSE 204 if(G4tgrMessenger::GetVerboseLevel() 204 if(G4tgrMessenger::GetVerboseLevel() >= 3) 205 { 205 { 206 G4cout << "G4tgrFileIn::GetWordsIn 206 G4cout << "G4tgrFileIn::GetWordsInLine() - NoWords" << NoWords 207 << ltemp << G4endl; 207 << ltemp << G4endl; 208 } 208 } 209 #endif 209 #endif 210 } 210 } 211 else if(*(tt - 1) == ' ' || *(tt - 1) 211 else if(*(tt - 1) == ' ' || *(tt - 1) == '\015' || *(tt - 1) == '\t') 212 { 212 { 213 ++NoWords; 213 ++NoWords; 214 #ifdef G4VERBOSE 214 #ifdef G4VERBOSE 215 if(G4tgrMessenger::GetVerboseLevel() 215 if(G4tgrMessenger::GetVerboseLevel() >= 3) 216 { 216 { 217 G4cout << "G4tgrFileIn::GetWordsIn 217 G4cout << "G4tgrFileIn::GetWordsInLine() - NoWords" << NoWords 218 << ltemp << G4endl; 218 << ltemp << G4endl; 219 } 219 } 220 #endif 220 #endif 221 } 221 } 222 } 222 } 223 ++tt; 223 ++tt; 224 } while((*tt != '\0') && (stemp.length() ! 224 } while((*tt != '\0') && (stemp.length() != 0)); 225 225 226 if(stemp.length() == 0) 226 if(stemp.length() == 0) 227 { 227 { 228 NoWords = 0; 228 NoWords = 0; 229 } 229 } 230 230 231 //--------- Read words from istr_line and 231 //--------- Read words from istr_line and write them into wordlist 232 for(ii = 0; ii < NoWords; ++ii) 232 for(ii = 0; ii < NoWords; ++ii) 233 { 233 { 234 stemp = ""; 234 stemp = ""; 235 istr_line >> stemp; 235 istr_line >> stemp; 236 if(stemp.length() == 0) 236 if(stemp.length() == 0) 237 { 237 { 238 break; 238 break; 239 } 239 } 240 G4int comment = (G4int)stemp.find(G4Stri << 240 G4int comment = stemp.find(G4String("//")); 241 #ifdef G4VERBOSE 241 #ifdef G4VERBOSE 242 if(G4tgrMessenger::GetVerboseLevel() >= 242 if(G4tgrMessenger::GetVerboseLevel() >= 3) 243 { 243 { 244 G4cout << "!!!COMMENT" << comment << s 244 G4cout << "!!!COMMENT" << comment << stemp.c_str() << G4endl; 245 } 245 } 246 #endif 246 #endif 247 if(comment == 0) 247 if(comment == 0) 248 { 248 { 249 break; 249 break; 250 } 250 } 251 else if(comment > 0) 251 else if(comment > 0) 252 { 252 { 253 stemp = stemp.substr(0, comment); 253 stemp = stemp.substr(0, comment); 254 wordlist.push_back(std::move(stemp)); << 254 wordlist.push_back(stemp); 255 break; 255 break; 256 } 256 } 257 wordlist.push_back(std::move(stemp)); << 257 wordlist.push_back(stemp); 258 } 258 } 259 259 260 // These two algorithms should be the more 260 // These two algorithms should be the more STL-like way, but they don't 261 // work for files whose lines end without 261 // work for files whose lines end without '\015'=TAB (STL problem: doesn't 262 // find end of string??): 262 // find end of string??): 263 // istream_iterator<G4String, ptrdiff_t> G 263 // istream_iterator<G4String, ptrdiff_t> G4String_iter(istr_line); 264 // istream_iterator<G4String, ptrdiff_t> e 264 // istream_iterator<G4String, ptrdiff_t> eosl; 265 // copy(G4String_iter, eosl, back_inserter 265 // copy(G4String_iter, eosl, back_inserter(wordlist)); 266 // typedef istream_iterator<G4String, ptrd 266 // typedef istream_iterator<G4String, ptrdiff_t> G4String_iter; 267 // copy(G4String_iter(istr_line), G4String 267 // copy(G4String_iter(istr_line), G4String_iter(), back_inserter(wordlist)); 268 268 269 if(wordlist.size() != 0) 269 if(wordlist.size() != 0) 270 { 270 { 271 if((*(wordlist.end() - 1)).compare("\\") 271 if((*(wordlist.end() - 1)).compare("\\") == 0) // use '\' to mark 272 { 272 { // continuing line 273 wordlist.pop_back(); 273 wordlist.pop_back(); 274 } 274 } 275 else 275 else 276 { 276 { 277 break; 277 break; 278 } 278 } 279 } 279 } 280 } 280 } 281 281 282 //--------- A pair of double quotes delimits 282 //--------- A pair of double quotes delimits a word, therefore, look for the 283 // case where there is more than on 283 // case where there is more than one word between two double quotes 284 std::vector<G4String> wordlist2; 284 std::vector<G4String> wordlist2; 285 G4String wordq = ""; 285 G4String wordq = ""; 286 unsigned int imerge = 0; 286 unsigned int imerge = 0; 287 for(std::size_t jj = 0; jj < wordlist.size() 287 for(std::size_t jj = 0; jj < wordlist.size(); ++jj) 288 { 288 { 289 if(wordlist[jj].substr(0, 1) == "\"") 289 if(wordlist[jj].substr(0, 1) == "\"") 290 { 290 { 291 imerge = 1; 291 imerge = 1; 292 } 292 } 293 if(wordlist[jj][G4int(wordlist[jj].size() << 293 if(wordlist[jj][wordlist[jj].size() - 1] == '\"') 294 { 294 { 295 if(imerge != 1) 295 if(imerge != 1) 296 { 296 { 297 const G4String& err1 = " word with tra << 297 G4String err1 = " word with trailing '\"' while there is no"; 298 const G4String& err2 = " previous word << 298 G4String err2 = " previous word with leading '\"' in line "; 299 const G4String& err = err1 + err2; << 299 G4String err = err1 + err2; 300 DumpException(err); 300 DumpException(err); 301 } 301 } 302 imerge = 2; 302 imerge = 2; 303 } 303 } 304 if(imerge == 0) 304 if(imerge == 0) 305 { 305 { 306 wordlist2.push_back(wordlist[jj]); 306 wordlist2.push_back(wordlist[jj]); 307 } 307 } 308 else if(imerge == 1) 308 else if(imerge == 1) 309 { 309 { 310 if(wordq == "") 310 if(wordq == "") 311 { 311 { 312 wordq.append(wordlist[jj].substr(1, wo 312 wordq.append(wordlist[jj].substr(1, wordlist[jj].size())); 313 } 313 } 314 else 314 else 315 { 315 { 316 wordq.append(wordlist[jj].substr(0, wo 316 wordq.append(wordlist[jj].substr(0, wordlist[jj].size())); 317 } 317 } 318 wordq.append(" "); 318 wordq.append(" "); 319 } 319 } 320 else if(imerge == 2) 320 else if(imerge == 2) 321 { 321 { 322 if(wordq == "") 322 if(wordq == "") 323 { 323 { 324 wordq.append(wordlist[jj].substr(1, wo 324 wordq.append(wordlist[jj].substr(1, wordlist[jj].size() - 2)); 325 } 325 } 326 else 326 else 327 { 327 { 328 wordq.append(wordlist[jj].substr(0, wo 328 wordq.append(wordlist[jj].substr(0, wordlist[jj].size() - 1)); 329 } 329 } 330 wordlist2.push_back(wordq); 330 wordlist2.push_back(wordq); 331 wordq = ""; 331 wordq = ""; 332 imerge = 0; 332 imerge = 0; 333 } 333 } 334 } 334 } 335 if(imerge == 1) 335 if(imerge == 1) 336 { 336 { 337 const G4String& err1 = " word with leading << 337 G4String err1 = " word with leading '\"' in line while there is no"; 338 const G4String& err2 = " later word with t << 338 G4String err2 = " later word with trailing '\"' in line "; 339 const G4String& err = err1 + err2; << 339 G4String err = err1 + err2; 340 DumpException(err); 340 DumpException(err); 341 } 341 } 342 342 343 wordlist = std::move(wordlist2); << 343 wordlist = wordlist2; 344 344 345 // Or why not like this (?): 345 // Or why not like this (?): 346 // typedef std::istream_iterator<G4String, p 346 // typedef std::istream_iterator<G4String, ptrdiff_t> string_iter; 347 // std::copy(string_iter(istr_line), string_ 347 // std::copy(string_iter(istr_line), string_iter(), back_inserter(wordlist)); 348 348 349 // check if including a new file 349 // check if including a new file 350 if(wordlist[0] == "#include") 350 if(wordlist[0] == "#include") 351 { 351 { 352 if(wordlist.size() != 2) 352 if(wordlist.size() != 2) 353 { 353 { 354 ErrorInLine(); 354 ErrorInLine(); 355 G4String ErrMessage = 355 G4String ErrMessage = 356 "'#include' should have as second argu 356 "'#include' should have as second argument, the filename !"; 357 G4Exception("G4tgrFileIn::GetWordsInLine 357 G4Exception("G4tgrFileIn::GetWordsInLine()", "InvalidInput", 358 FatalException, ErrMessage); 358 FatalException, ErrMessage); 359 } 359 } 360 360 361 #ifdef G4VERBOSE 361 #ifdef G4VERBOSE 362 if(G4tgrMessenger::GetVerboseLevel() >= 3) 362 if(G4tgrMessenger::GetVerboseLevel() >= 3) 363 { 363 { 364 G4cout << " G4tgrFileIn::GetWordsInLine( 364 G4cout << " G4tgrFileIn::GetWordsInLine() - Include found !" << G4endl; 365 } 365 } 366 #endif 366 #endif 367 OpenNewFile(wordlist[1].c_str()); 367 OpenNewFile(wordlist[1].c_str()); 368 isok = GetWordsInLine(wordlist); 368 isok = GetWordsInLine(wordlist); 369 } 369 } 370 370 371 return isok; 371 return isok; 372 } 372 } 373 373 374 // ------------------------------------------- 374 // -------------------------------------------------------------------- 375 void G4tgrFileIn::ErrorInLine() 375 void G4tgrFileIn::ErrorInLine() 376 { 376 { 377 G4cerr << "!! EXITING: ERROR IN LINE No " << 377 G4cerr << "!! EXITING: ERROR IN LINE No " << theLineNo[theCurrentFile] 378 << " file: " << theNames[theCurrentFi 378 << " file: " << theNames[theCurrentFile] << " : "; 379 } 379 } 380 380 381 // ------------------------------------------- 381 // -------------------------------------------------------------------- 382 G4bool G4tgrFileIn::EndOfFile() 382 G4bool G4tgrFileIn::EndOfFile() 383 { 383 { 384 G4bool isok = theFiles[theCurrentFile]->eof( 384 G4bool isok = theFiles[theCurrentFile]->eof(); 385 if(isok) 385 if(isok) 386 { 386 { 387 #ifdef G4VERBOSE 387 #ifdef G4VERBOSE 388 if(G4tgrMessenger::GetVerboseLevel() >= 3) 388 if(G4tgrMessenger::GetVerboseLevel() >= 3) 389 { 389 { 390 G4cout << " G4tgrFileIn::EndOfFile() - E 390 G4cout << " G4tgrFileIn::EndOfFile() - EOF: " << theCurrentFile << G4endl; 391 } 391 } 392 #endif 392 #endif 393 --theCurrentFile; 393 --theCurrentFile; 394 if(theCurrentFile != -1) // Last file wil 394 if(theCurrentFile != -1) // Last file will be closed by the user 395 { 395 { 396 Close(); 396 Close(); 397 } 397 } 398 } 398 } 399 399 400 // Only real closing if all files are closed 400 // Only real closing if all files are closed 401 #ifdef G4VERBOSE 401 #ifdef G4VERBOSE 402 if(G4tgrMessenger::GetVerboseLevel() >= 3) 402 if(G4tgrMessenger::GetVerboseLevel() >= 3) 403 { 403 { 404 G4cout << " G4tgrFileIn::EndOfFile() - EOF 404 G4cout << " G4tgrFileIn::EndOfFile() - EOF: " << isok << " " 405 << theCurrentFile << G4endl; 405 << theCurrentFile << G4endl; 406 } 406 } 407 #endif 407 #endif 408 if(theCurrentFile != -1) 408 if(theCurrentFile != -1) 409 { 409 { 410 return false; 410 return false; 411 } 411 } 412 else 412 else 413 { 413 { 414 return isok; 414 return isok; 415 } 415 } 416 } 416 } 417 417 418 // ------------------------------------------- 418 // -------------------------------------------------------------------- 419 void G4tgrFileIn::Close() 419 void G4tgrFileIn::Close() 420 { 420 { 421 #ifdef G4VERBOSE 421 #ifdef G4VERBOSE 422 if(G4tgrMessenger::GetVerboseLevel() >= 3) 422 if(G4tgrMessenger::GetVerboseLevel() >= 3) 423 { 423 { 424 G4cout << "G4tgrFileIn::Close() - " << the 424 G4cout << "G4tgrFileIn::Close() - " << theCurrentFile << ", size " 425 << theFiles.size() << G4endl; 425 << theFiles.size() << G4endl; 426 } 426 } 427 #endif 427 #endif 428 428 429 theFiles[theCurrentFile + 1]->close(); 429 theFiles[theCurrentFile + 1]->close(); 430 theFiles.pop_back(); 430 theFiles.pop_back(); 431 } 431 } 432 432 433 // ------------------------------------------- 433 // -------------------------------------------------------------------- 434 void G4tgrFileIn::DumpException(const G4String 434 void G4tgrFileIn::DumpException(const G4String& sent) 435 { 435 { 436 const G4String& Err1 = sent + " in file " + << 436 G4String Err1 = sent + " in file " + theName; 437 const G4String& Err2 = << 437 G4String Err2 = 438 ", line No: " + G4UIcommand::ConvertToStri << 438 " line No: " + G4UIcommand::ConvertToString(theLineNo[theCurrentFile]); 439 const G4String& ErrMessage = Err1 + Err2; << 439 G4String ErrMessage = Err1; 440 G4Exception("G4tgrFileIn::DumpException()", << 440 G4Exception("G4tgrFileIn::DumpException()", "FileError", FatalException, 441 FatalException, ErrMessage); << 441 ErrMessage); 442 } 442 } 443 443