50 : theCurrentFile(-1), theName(
"")
75 std::vector<G4tgrFileIn*>::const_iterator vfcite;
78 if( (*vfcite)->GetName() ==
filename)
103 std::ifstream*
fin =
new std::ifstream(filename);
111 if( !fin->is_open() )
148 G4int wsiz = wordlist.size();
150 for (ii = 0; ii < wsiz; ii++)
156 const G4int NMAXLIN = 1000;
161 for ( ii = 0; ii < NMAXLIN; ii++) { ltemp[ii] =
' '; }
165 for ( ii=0; ii < NMAXLIN; ii++)
167 if ( ltemp[ii] ==
'\0' ) {
break; }
169 if ( ii == NMAXLIN-1 )
172 G4String ErrMessage =
"Too long line. Please split it "
173 +
G4String(
"putting a '\\' at the end!");
174 G4Exception(
"G4tgrFileIn::GetWordsInLine()",
"InvalidInput",
185 std::istringstream istr_line(ltemp);
195 if( *tt !=
' ' && *(tt) !=
'\0' )
203 G4cout <<
"G4tgrFileIn::GetWordsInLine() - NoWords"
204 << NoWords << ltemp <<
G4endl;
208 else if( *(tt-1) ==
' ' || *(tt-1) ==
'\015' || *(tt-1) ==
'\t')
214 G4cout <<
"G4tgrFileIn::GetWordsInLine() - NoWords"
215 << NoWords << ltemp <<
G4endl;
221 }
while((*tt !=
'\0') && (stemp.length()!=0));
223 if(stemp.length() == 0) { NoWords = 0; }
226 for( ii=0; ii < NoWords; ii++)
230 if ( stemp.length() == 0 ) {
break; }
235 G4cout <<
"!!!COMMENT" << comment << stemp.c_str() <<
G4endl;
242 else if ( comment > 0 )
244 stemp = stemp.substr( 0, comment );
245 wordlist.push_back(stemp);
248 wordlist.push_back(stemp);
260 if ( wordlist.size() != 0 )
262 if( (*(wordlist.end()-1)).compare(
"\\") == 0 )
275 std::vector<G4String> wordlist2;
277 unsigned int imerge = 0;
278 for(
size_t jj = 0; jj < wordlist.size(); jj++)
280 if( wordlist[jj].substr(0,1) ==
"\"" )
284 if( wordlist[jj][ wordlist[jj].size()-1 ] ==
'\"' )
288 G4String err1 =
" word with trailing '\"' while there is no";
289 G4String err2 =
" previous word with leading '\"' in line ";
297 wordlist2.push_back( wordlist[jj] );
299 else if( imerge == 1 )
303 wordq.
append( wordlist[jj].substr(1,wordlist[jj].size()) );
307 wordq.
append( wordlist[jj].substr(0,wordlist[jj].size()) );
311 else if( imerge == 2 )
315 wordq.
append( wordlist[jj].substr(1,wordlist[jj].size()-2));
319 wordq.
append( wordlist[jj].substr(0,wordlist[jj].size()-1) );
321 wordlist2.push_back( wordq );
328 G4String err1 =
" word with leading '\"' in line while there is no";
329 G4String err2 =
" later word with trailing '\"' in line ";
334 wordlist = wordlist2;
341 if( wordlist[0] ==
"#include" )
343 if( wordlist.size() != 2 )
347 =
"'#include' should have as second argument, the filename !";
348 G4Exception(
"G4tgrFileIn::GetWordsInLine()",
"InvalidInput",
355 G4cout <<
" G4tgrFileIn::GetWordsInLine() - Include found !" <<
G4endl;
369 G4cerr <<
"!! EXITING: ERROR IN LINE No "
384 G4cout <<
" G4tgrFileIn::EndOfFile() - EOF: "
399 G4cout <<
" G4tgrFileIn::EndOfFile() - EOF: "
420 G4cout <<
"G4tgrFileIn::Close() - "
437 G4Exception(
"G4tgrFileIn::DumpException()",
"FileError",