70 if(theInstances ==
nullptr)
72 theInstances =
new std::vector<G4tgrFileIn*>;
75 std::vector<G4tgrFileIn*>::const_iterator vfcite;
76 for(vfcite = theInstances->cbegin(); vfcite != theInstances->cend(); ++vfcite)
78 if((*vfcite)->GetName() == filename)
85 if(vfcite == theInstances->cend())
89 instance->theCurrentFile = -1;
92 theInstances->push_back(instance);
147 for(ii = 0; ii < wsiz; ++ii)
153 const G4int NMAXLIN = 1000;
157 (theLineNo[theCurrentFile])++;
158 for(ii = 0; ii < NMAXLIN; ++ii)
162 theFiles[theCurrentFile]->getline(ltemp, NMAXLIN);
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][
G4int(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;