Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/persistency/ascii/src/G4tgrFileIn.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /persistency/ascii/src/G4tgrFileIn.cc (Version 11.3.0) and /persistency/ascii/src/G4tgrFileIn.cc (Version 9.6.p1)


  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$
 29 // ------------------------------------------- <<  28 //
                                                   >>  29 //
                                                   >>  30 // class G4tgrFileIn
                                                   >>  31 
                                                   >>  32 // History:
                                                   >>  33 // - Created.                                 P.Arce, CIEMAT (November 2007)
                                                   >>  34 // -------------------------------------------------------------------------
 30                                                    35 
 31 #include "globals.hh"                              36 #include "globals.hh"
 32                                                    37 
 33 #include <iostream>                                38 #include <iostream>
 34 #include <fstream>                                 39 #include <fstream>
 35 #include <sstream>                                 40 #include <sstream>
 36                                                    41 
 37 #include "G4tgrFileIn.hh"                          42 #include "G4tgrFileIn.hh"
 38 #include "G4tgrMessenger.hh"                       43 #include "G4tgrMessenger.hh"
 39 #include "G4tgrUtils.hh"                           44 #include "G4tgrUtils.hh"
 40 #include "G4UIcommand.hh"                          45 #include "G4UIcommand.hh"
 41                                                    46 
 42 G4ThreadLocal std::vector<G4tgrFileIn*>* G4tgr <<  47 std::vector<G4tgrFileIn*> G4tgrFileIn::theInstances;
                                                   >>  48 
 43                                                    49 
 44 // ------------------------------------------- <<  50 //-----------------------------------------------------------------------
 45 G4tgrFileIn::G4tgrFileIn()                         51 G4tgrFileIn::G4tgrFileIn()
                                                   >>  52   : theCurrentFile(-1), theName("")
 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 /*
                                                   >>  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 }
                                                   >>  68 
 74                                                    69 
                                                   >>  70 //-----------------------------------------------------------------------
                                                   >>  71 G4tgrFileIn& G4tgrFileIn::GetInstance( const G4String& filename )
                                                   >>  72 {
 75   std::vector<G4tgrFileIn*>::const_iterator vf     73   std::vector<G4tgrFileIn*>::const_iterator vfcite;
 76   for(vfcite = theInstances->cbegin(); vfcite  <<  74   for( vfcite = theInstances.begin(); vfcite != theInstances.end(); vfcite++)
 77   {                                                75   {
 78     if((*vfcite)->GetName() == filename)       <<  76     if( (*vfcite)->GetName() == filename)
 79     {                                              77     {
 80       return *(*vfcite);                           78       return *(*vfcite);
 81     }                                              79     }
 82   }                                                80   }
 83                                                    81 
 84   G4tgrFileIn* instance = nullptr;             <<  82   G4tgrFileIn* instance = 0;
 85   if(vfcite == theInstances->cend())           <<  83   if( vfcite == theInstances.end() )
 86   {                                                84   {
 87     instance = new G4tgrFileIn(filename);      <<  85     instance = new G4tgrFileIn( filename );
 88                                                <<  86     
 89     instance->theCurrentFile = -1;                 87     instance->theCurrentFile = -1;
 90     instance->OpenNewFile(filename.c_str());   <<  88     instance->OpenNewFile( filename.c_str() );
 91                                                    89 
 92     theInstances->push_back(instance);         <<  90     theInstances.push_back( instance );
 93   }                                                91   }
 94                                                    92 
 95   return *instance;                                93   return *instance;
 96 }                                                  94 }
 97                                                    95 
 98 // ------------------------------------------- <<  96 
 99 void G4tgrFileIn::OpenNewFile(const char* file <<  97 //-----------------------------------------------------------------------
100 {                                              <<  98 void G4tgrFileIn::OpenNewFile( const char* filename )
101   ++theCurrentFile;                            <<  99 { 
                                                   >> 100   theCurrentFile++;
102   std::ifstream* fin = new std::ifstream(filen    101   std::ifstream* fin = new std::ifstream(filename);
103   theFiles.push_back(fin);                        102   theFiles.push_back(fin);
104                                                   103 
105   theLineNo.push_back(0);                      << 104   theLineNo.push_back( 0 );
106                                                   105 
107   theNames.push_back(filename);                << 106   theNames.push_back( filename );
108                                                   107 
109 #ifndef OS_SUN_4_2                                108 #ifndef OS_SUN_4_2
110   if(!fin->is_open())                          << 109   if( !fin->is_open() )
111   {                                               110   {
112     G4String ErrMessage = "Input file does not    111     G4String ErrMessage = "Input file does not exist: " + G4String(filename);
113     G4Exception("G4tgrFileIn::OpenNewFile()",  << 112     G4Exception("G4tgrFileIn::OpenNewFile()",
114                 ErrMessage);                   << 113                 "InvalidInput", FatalException, ErrMessage);
115   }                                               114   }
116 #endif                                            115 #endif
117 }                                                 116 }
118                                                   117 
119 // ------------------------------------------- << 118 
120 G4tgrFileIn& G4tgrFileIn::GetInstanceOpened(co << 119 //-----------------------------------------------------------------------
                                                   >> 120 G4tgrFileIn& G4tgrFileIn::GetInstanceOpened( const G4String& filename )
121 {                                                 121 {
                                                   >> 122 
122   G4tgrFileIn& filein = G4tgrFileIn::GetInstan    123   G4tgrFileIn& filein = G4tgrFileIn::GetInstance(filename);
123   if(filein.GetName() != filename)             << 124   if (filein.GetName() != filename )
124   {                                               125   {
125     G4String ErrMessage = "File not opened yet    126     G4String ErrMessage = "File not opened yet: " + filename;
126     G4Exception("G4tgrFileIn::GetInstanceOpene << 127     G4Exception("G4tgrFileIn::GetInstanceOpened()",
127                 FatalException, ErrMessage);   << 128                 "InvalidInput", FatalException, ErrMessage);
128   }                                               129   }
129   else                                            130   else
130   {                                               131   {
131     return filein;                                132     return filein;
132   }                                               133   }
133   return filein;  // to avoid compilation warn << 134   return filein; // to avoid compilation warnings
134 }                                                 135 }
135                                                   136 
136 // ------------------------------------------- << 137 
137 G4int G4tgrFileIn::GetWordsInLine(std::vector< << 138 //----------------------------------------------------------------------- 
                                                   >> 139 G4int G4tgrFileIn::GetWordsInLine( std::vector<G4String>& wordlist)
138 {                                                 140 {
139   G4int isok = 1;                                 141   G4int isok = 1;
140                                                   142 
141   //---------- Read a line of file:               143   //---------- Read a line of file:
142   //           NOTE: cannot be read with a ist    144   //           NOTE: cannot be read with a istream_iterator,
143   //           because it uses G4cout, and the    145   //           because it uses G4cout, and then doesn't read '\n'
144   //----- Clear wordlist                          146   //----- Clear wordlist
145   G4int wsiz = (G4int)wordlist.size();         << 147   G4int wsiz = wordlist.size();
146   G4int ii;                                       148   G4int ii;
147   for(ii = 0; ii < wsiz; ++ii)                 << 149   for (ii = 0; ii < wsiz; ii++)
148   {                                               150   {
149     wordlist.pop_back();                          151     wordlist.pop_back();
150   }                                            << 152   } 
151                                                   153 
152   //---------- Loop lines while there is an en << 154   //---------- Loop lines while there is an ending '\' or line is blank   
153   const G4int NMAXLIN = 1000;                     155   const G4int NMAXLIN = 1000;
154   char ltemp[NMAXLIN];  // there won't be line << 156   char ltemp[NMAXLIN]; // there won't be lines longer than NMAXLIN characters
155   for(;;)                                      << 157   for (;;)
156   {                                               158   {
157     (theLineNo[theCurrentFile])++;                159     (theLineNo[theCurrentFile])++;
158     for(ii = 0; ii < NMAXLIN; ++ii)            << 160     for ( ii = 0; ii < NMAXLIN; ii++)  { ltemp[ii] = ' '; }
159     {                                          << 161     theFiles[theCurrentFile]->getline( ltemp, NMAXLIN ); 
160       ltemp[ii] = ' ';                         << 
161     }                                          << 
162     theFiles[theCurrentFile]->getline(ltemp, N << 
163                                                   162 
164     //---------- Check for lines longer than N    163     //---------- Check for lines longer than NMAXLIN character
165     for(ii = 0; ii < NMAXLIN; ++ii)            << 164     for ( ii=0; ii < NMAXLIN; ii++)
166     {                                             165     {
167       if(ltemp[ii] == '\0')                    << 166       if ( ltemp[ii] == '\0' )  { break; }
168       {                                        << 
169         break;                                 << 
170       }                                        << 
171     }                                             167     }
172     if(ii == NMAXLIN - 1)                      << 168     if ( ii == NMAXLIN-1 )
173     {                                             169     {
174       ErrorInLine();                              170       ErrorInLine();
175       G4String ErrMessage = "Too long line. Pl << 171       G4String ErrMessage = "Too long line. Please split it "
176                             G4String("putting  << 172                           + G4String("putting a '\\' at the end!");
177       G4Exception("G4tgrFileIn::GetWordsInLine    173       G4Exception("G4tgrFileIn::GetWordsInLine()", "InvalidInput",
178                   FatalException, ErrMessage);    174                   FatalException, ErrMessage);
179     }                                             175     }
180                                                << 176     
181     //---------- End of file                      177     //---------- End of file
182     if(EndOfFile())                            << 178     if ( EndOfFile() )
183     {                                             179     {
184       return 0;                                   180       return 0;
185     }                                             181     }
186                                                << 182     
187     //---------- Convert line read to istrstre << 183     //---------- Convert line read to istrstream to split it in words 
188     std::istringstream istr_line(ltemp);          184     std::istringstream istr_line(ltemp);
189                                                << 185      
190     //--------- Count how many words are there    186     //--------- Count how many words are there in ltemp
191     //          this shouln't be needed, but S    187     //          this shouln't be needed, but SUN compiler has problems...
192     G4int NoWords = 0;                            188     G4int NoWords = 0;
193     char* tt      = ltemp;                     << 189     char* tt = ltemp;
194                                                   190 
195     G4String stemp(ltemp);                        191     G4String stemp(ltemp);
196     do                                            192     do
197     {                                             193     {
198       if(*tt != ' ' && *(tt) != '\0')          << 194       if( *tt != ' ' && *(tt) != '\0' )
199       {                                           195       {
200         if(tt == ltemp)                        << 196         if( tt == ltemp)
201         {                                         197         {
202           ++NoWords;                           << 198           NoWords++;
203 #ifdef G4VERBOSE                                  199 #ifdef G4VERBOSE
204           if(G4tgrMessenger::GetVerboseLevel() << 200           if( G4tgrMessenger::GetVerboseLevel() >= 3 )
205           {                                       201           {
206             G4cout << "G4tgrFileIn::GetWordsIn << 202             G4cout << "G4tgrFileIn::GetWordsInLine() - NoWords"
207                    << ltemp << G4endl;         << 203                    << NoWords << ltemp << G4endl;
208           }                                       204           }
209 #endif                                            205 #endif
210         }                                         206         }
211         else if(*(tt - 1) == ' ' || *(tt - 1)  << 207         else if( *(tt-1) == ' ' ||  *(tt-1) == '\015' ||  *(tt-1) == '\t')
212         {                                         208         {
213           ++NoWords;                           << 209           NoWords++; 
214 #ifdef G4VERBOSE                                  210 #ifdef G4VERBOSE
215           if(G4tgrMessenger::GetVerboseLevel() << 211           if( G4tgrMessenger::GetVerboseLevel() >= 3 )
216           {                                       212           {
217             G4cout << "G4tgrFileIn::GetWordsIn << 213             G4cout << "G4tgrFileIn::GetWordsInLine() - NoWords"
218                    << ltemp << G4endl;         << 214                    << NoWords << ltemp << G4endl;
219           }                                       215           }
220 #endif                                            216 #endif
221         }                                         217         }
222       }                                           218       }
223       ++tt;                                    << 219       tt++;
224     } while((*tt != '\0') && (stemp.length() ! << 220     } while((*tt != '\0') && (stemp.length()!=0));
225                                                   221 
226     if(stemp.length() == 0)                    << 222     if(stemp.length() == 0)  { NoWords = 0; }
227     {                                          << 
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       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 jj = 0; jj < wordlist.size(); jj++)
288   {                                               278   {
289     if(wordlist[jj].substr(0, 1) == "\"")      << 279     if( wordlist[jj].substr(0,1) == "\"" )
290     {                                             280     {
291       imerge = 1;                                 281       imerge = 1;
292     }                                          << 282     } 
293     if(wordlist[jj][G4int(wordlist[jj].size()  << 283     if( wordlist[jj][ wordlist[jj].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[jj] );
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[jj].substr(1,wordlist[jj].size()) );
313       }                                           303       }
314       else                                        304       else
315       {                                           305       {
316         wordq.append(wordlist[jj].substr(0, wo << 306         wordq.append( wordlist[jj].substr(0,wordlist[jj].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[jj].substr(1,wordlist[jj].size()-2));
325       }                                           315       }
326       else                                        316       else
327       {                                           317       {
328         wordq.append(wordlist[jj].substr(0, wo << 318         wordq.append( wordlist[jj].substr(0,wordlist[jj].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