51 : theCurrentFile(-1), theName(
"")
76 std::vector<G4tgrFileIn*>::const_iterator vfcite;
79 if( (*vfcite)->GetName() == filename)
104 std::ifstream*
fin =
new std::ifstream(filename);
112 if( !fin->is_open() )
126 if (filein.
GetName() != filename )
128 G4String ErrMessage =
"File not opened yet: " + filename;
149 G4int wsiz = wordlist.size();
151 for (ii = 0; ii < wsiz; ii++)
157 const G4int NMAXLIN = 1000;
162 for ( ii = 0; ii < NMAXLIN; ii++) { ltemp[ii] =
' '; }
166 for ( ii=0; ii < NMAXLIN; ii++)
168 if ( ltemp[ii] ==
'\0' ) {
break; }
170 if ( ii == NMAXLIN-1 )
173 G4String ErrMessage =
"Too long line. Please split it "
174 +
G4String(
"putting a '\\' at the end!");
175 G4Exception(
"G4tgrFileIn::GetWordsInLine()",
"InvalidInput",
186 std::istringstream istr_line(ltemp);
196 if( *tt !=
' ' && *(tt) !=
'\0' )
204 G4cout <<
"G4tgrFileIn::GetWordsInLine() - NoWords"
205 << NoWords << ltemp <<
G4endl;
209 else if( *(tt-1) ==
' ' || *(tt-1) ==
'\015' || *(tt-1) ==
'\t')
215 G4cout <<
"G4tgrFileIn::GetWordsInLine() - NoWords"
216 << NoWords << ltemp <<
G4endl;
222 }
while((*tt !=
'\0') && (stemp.length()!=0));
224 if(stemp.length() == 0) { NoWords = 0; }
227 for( ii=0; ii < NoWords; ii++)
231 if ( stemp.length() == 0 ) {
break; }
236 G4cout <<
"!!!COMMENT" << comment << stemp.c_str() <<
G4endl;
243 else if ( comment > 0 )
245 stemp = stemp.substr( 0, comment );
246 wordlist.push_back(stemp);
249 wordlist.push_back(stemp);
261 if ( wordlist.size() != 0 )
263 if( (*(wordlist.end()-1)).compare(
"\\") == 0 )
276 std::vector<G4String> wordlist2;
278 unsigned int imerge = 0;
279 for(
size_t jj = 0; jj < wordlist.size(); jj++)
281 if( wordlist[jj].substr(0,1) ==
"\"" )
285 if( wordlist[jj][ wordlist[jj].size()-1 ] ==
'\"' )
289 G4String err1 =
" word with trailing '\"' while there is no";
290 G4String err2 =
" previous word with leading '\"' in line ";
298 wordlist2.push_back( wordlist[jj] );
300 else if( imerge == 1 )
304 wordq.
append( wordlist[jj].substr(1,wordlist[jj].size()) );
308 wordq.
append( wordlist[jj].substr(0,wordlist[jj].size()) );
312 else if( imerge == 2 )
316 wordq.
append( wordlist[jj].substr(1,wordlist[jj].size()-2));
320 wordq.
append( wordlist[jj].substr(0,wordlist[jj].size()-1) );
322 wordlist2.push_back( wordq );
329 G4String err1 =
" word with leading '\"' in line while there is no";
330 G4String err2 =
" later word with trailing '\"' in line ";
335 wordlist = wordlist2;
342 if( wordlist[0] ==
"#include" )
344 if( wordlist.size() != 2 )
348 =
"'#include' should have as second argument, the filename !";
349 G4Exception(
"G4tgrFileIn::GetWordsInLine()",
"InvalidInput",
356 G4cout <<
" G4tgrFileIn::GetWordsInLine() - Include found !" <<
G4endl;
370 G4cerr <<
"!! EXITING: ERROR IN LINE No "
385 G4cout <<
" G4tgrFileIn::EndOfFile() - EOF: "
400 G4cout <<
" G4tgrFileIn::EndOfFile() - EOF: "
421 G4cout <<
"G4tgrFileIn::Close() - "
438 G4Exception(
"G4tgrFileIn::DumpException()",
"FileError",
std::vector< G4String > theNames
static G4tgrFileIn & GetInstanceOpened(const G4String &name)
static G4int GetVerboseLevel()
static G4ThreadLocal std::vector< G4tgrFileIn * > * theInstances
const G4String & GetName()
std::vector< std::ifstream * > theFiles
void DumpException(const G4String &sent)
static G4tgrFileIn & GetInstance(const G4String &name)
std::vector< G4int > theLineNo
G4GLOB_DLL std::ostream G4cerr
void OpenNewFile(const char *filename)
static G4String ConvertToString(G4bool boolVal)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static MCTruthManager * instance
G4GLOB_DLL std::ostream G4cout
G4String & append(const G4String &)
G4int GetWordsInLine(std::vector< G4String > &wl)