75 std::vector<G4tgrFileIn*>::const_iterator vfcite;
78 if((*vfcite)->GetName() == filename)
102 std::ifstream* fin =
new std::ifstream(filename);
123 if(filein.
GetName() != filename)
125 G4String ErrMessage =
"File not opened yet: " + filename;
126 G4Exception(
"G4tgrFileIn::GetInstanceOpened()",
"InvalidInput",
145 G4int wsiz = wordlist.size();
147 for(ii = 0; ii < wsiz; ++ii)
153 const G4int NMAXLIN = 1000;
158 for(ii = 0; ii < NMAXLIN; ++ii)
165 for(ii = 0; ii < NMAXLIN; ++ii)
167 if(ltemp[ii] ==
'\0')
172 if(ii == NMAXLIN - 1)
175 G4String ErrMessage =
"Too long line. Please split it " +
176 G4String(
"putting a '\\' at the end!");
177 G4Exception(
"G4tgrFileIn::GetWordsInLine()",
"InvalidInput",
188 std::istringstream istr_line(ltemp);
198 if(*tt !=
' ' && *(tt) !=
'\0')
206 G4cout <<
"G4tgrFileIn::GetWordsInLine() - NoWords" << NoWords
211 else if(*(tt - 1) ==
' ' || *(tt - 1) ==
'\015' || *(tt - 1) ==
'\t')
217 G4cout <<
"G4tgrFileIn::GetWordsInLine() - NoWords" << NoWords
224 }
while((*tt !=
'\0') && (stemp.length() != 0));
226 if(stemp.length() == 0)
232 for(ii = 0; ii < NoWords; ++ii)
236 if(stemp.length() == 0)
244 G4cout <<
"!!!COMMENT" << comment << stemp.c_str() <<
G4endl;
253 stemp = stemp.substr(0, comment);
254 wordlist.push_back(stemp);
257 wordlist.push_back(stemp);
269 if(wordlist.size() != 0)
271 if((*(wordlist.end() - 1)).compare(
"\\") == 0)
284 std::vector<G4String> wordlist2;
286 unsigned int imerge = 0;
287 for(std::size_t jj = 0; jj < wordlist.size(); ++jj)
289 if(wordlist[jj].substr(0, 1) ==
"\"")
293 if(wordlist[jj][wordlist[jj].size() - 1] ==
'\"')
297 G4String err1 =
" word with trailing '\"' while there is no";
298 G4String err2 =
" previous word with leading '\"' in line ";
306 wordlist2.push_back(wordlist[jj]);
312 wordq.append(wordlist[jj].substr(1, wordlist[jj].size()));
316 wordq.append(wordlist[jj].substr(0, wordlist[jj].size()));
324 wordq.append(wordlist[jj].substr(1, wordlist[jj].size() - 2));
328 wordq.append(wordlist[jj].substr(0, wordlist[jj].size() - 1));
330 wordlist2.push_back(wordq);
337 G4String err1 =
" word with leading '\"' in line while there is no";
338 G4String err2 =
" later word with trailing '\"' in line ";
343 wordlist = wordlist2;
350 if(wordlist[0] ==
"#include")
352 if(wordlist.size() != 2)
356 "'#include' should have as second argument, the filename !";
357 G4Exception(
"G4tgrFileIn::GetWordsInLine()",
"InvalidInput",
364 G4cout <<
" G4tgrFileIn::GetWordsInLine() - Include found !" <<
G4endl;
404 G4cout <<
" G4tgrFileIn::EndOfFile() - EOF: " << isok <<
" "
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
static G4String ConvertToString(G4bool boolVal)
void OpenNewFile(const char *filename)
std::vector< G4int > theLineNo
const G4String & GetName()
static G4ThreadLocal std::vector< G4tgrFileIn * > * theInstances
G4int GetWordsInLine(std::vector< G4String > &wl)
static G4tgrFileIn & GetInstanceOpened(const G4String &name)
static G4tgrFileIn & GetInstance(const G4String &name)
std::vector< G4String > theNames
void DumpException(const G4String &sent)
std::vector< std::ifstream * > theFiles
static G4int GetVerboseLevel()