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