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.5)


  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: G4tgrFileIn.cc,v 1.13 2010-12-15 11:29:54 arce Exp $
 29 // ------------------------------------------- <<  28 // GEANT4 tag $Name: not supported by cvs2svn $
                                                   >>  29 //
                                                   >>  30 //
                                                   >>  31 // class G4tgrFileIn
                                                   >>  32 
                                                   >>  33 // History:
                                                   >>  34 // - Created.                                 P.Arce, CIEMAT (November 2007)
                                                   >>  35 // -------------------------------------------------------------------------
 30                                                    36 
 31 #include "globals.hh"                              37 #include "globals.hh"
 32                                                    38 
 33 #include <iostream>                                39 #include <iostream>
 34 #include <fstream>                                 40 #include <fstream>
 35 #include <sstream>                                 41 #include <sstream>
 36                                                    42 
 37 #include "G4tgrFileIn.hh"                          43 #include "G4tgrFileIn.hh"
 38 #include "G4tgrMessenger.hh"                       44 #include "G4tgrMessenger.hh"
 39 #include "G4tgrUtils.hh"                           45 #include "G4tgrUtils.hh"
 40 #include "G4UIcommand.hh"                          46 #include "G4UIcommand.hh"
 41                                                    47 
 42 G4ThreadLocal std::vector<G4tgrFileIn*>* G4tgr <<  48 std::vector<G4tgrFileIn*> G4tgrFileIn::theInstances;
                                                   >>  49 
 43                                                    50 
 44 // ------------------------------------------- <<  51 //-----------------------------------------------------------------------
 45 G4tgrFileIn::G4tgrFileIn()                         52 G4tgrFileIn::G4tgrFileIn()
                                                   >>  53   : theCurrentFile(-1), theName("")
 46 {                                                  54 {
 47   if(theInstances == nullptr)                  << 
 48   {                                            << 
 49     theInstances = new std::vector<G4tgrFileIn << 
 50   }                                            << 
 51 }                                                  55 }
 52                                                    56 
 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                                                    57 
 67 // ------------------------------------------- <<  58 //-----------------------------------------------------------------------
 68 G4tgrFileIn& G4tgrFileIn::GetInstance(const G4 <<  59 G4tgrFileIn::~G4tgrFileIn()
 69 {                                                  60 {
 70   if(theInstances == nullptr)                  <<  61 /*
                                                   >>  62   std::vector<G4tgrFileIn*>::const_iterator vfcite;
                                                   >>  63   for( vfcite = theInstances.begin(); vfcite != theInstances.end(); vfcite++)
 71   {                                                64   {
 72     theInstances = new std::vector<G4tgrFileIn <<  65     delete *vfcite;
 73   }                                                66   }
                                                   >>  67 */
                                                   >>  68 }
                                                   >>  69 
 74                                                    70 
                                                   >>  71 //-----------------------------------------------------------------------
                                                   >>  72 G4tgrFileIn& G4tgrFileIn::GetInstance( const G4String& filename )
                                                   >>  73 {
 75   std::vector<G4tgrFileIn*>::const_iterator vf     74   std::vector<G4tgrFileIn*>::const_iterator vfcite;
 76   for(vfcite = theInstances->cbegin(); vfcite  <<  75   for( vfcite = theInstances.begin(); vfcite != theInstances.end(); vfcite++)
 77   {                                                76   {
 78     if((*vfcite)->GetName() == filename)       <<  77     if( (*vfcite)->GetName() == filename)
 79     {                                              78     {
 80       return *(*vfcite);                           79       return *(*vfcite);
 81     }                                              80     }
 82   }                                                81   }
 83                                                    82 
 84   G4tgrFileIn* instance = nullptr;             <<  83   G4tgrFileIn* instance = 0;
 85   if(vfcite == theInstances->cend())           <<  84   if( vfcite == theInstances.end() )
 86   {                                                85   {
 87     instance = new G4tgrFileIn(filename);      <<  86     instance = new G4tgrFileIn( filename );
 88                                                <<  87     
 89     instance->theCurrentFile = -1;                 88     instance->theCurrentFile = -1;
 90     instance->OpenNewFile(filename.c_str());   <<  89     instance->OpenNewFile( filename.c_str() );
 91                                                    90 
 92     theInstances->push_back(instance);         <<  91     theInstances.push_back( instance );
 93   }                                                92   }
 94                                                    93 
 95   return *instance;                                94   return *instance;
 96 }                                                  95 }
 97                                                    96 
 98 // ------------------------------------------- <<  97 
 99 void G4tgrFileIn::OpenNewFile(const char* file <<  98 //-----------------------------------------------------------------------
100 {                                              <<  99 void G4tgrFileIn::OpenNewFile( const char* filename )
101   ++theCurrentFile;                            << 100 { 
                                                   >> 101   theCurrentFile++;
102   std::ifstream* fin = new std::ifstream(filen    102   std::ifstream* fin = new std::ifstream(filename);
103   theFiles.push_back(fin);                        103   theFiles.push_back(fin);
104                                                   104 
105   theLineNo.push_back(0);                      << 105   theLineNo.push_back( 0 );
106                                                   106 
107   theNames.push_back(filename);                << 107   theNames.push_back( filename );
108                                                   108 
109 #ifndef OS_SUN_4_2                                109 #ifndef OS_SUN_4_2
110   if(!fin->is_open())                          << 110   if( !fin->is_open() )
111   {                                               111   {
112     G4String ErrMessage = "Input file does not    112     G4String ErrMessage = "Input file does not exist: " + G4String(filename);
113     G4Exception("G4tgrFileIn::OpenNewFile()",  << 113     G4Exception("G4tgrFileIn::OpenNewFile()",
114                 ErrMessage);                   << 114                 "InvalidInput", FatalException, ErrMessage);
115   }                                               115   }
116 #endif                                            116 #endif
117 }                                                 117 }
118                                                   118 
119 // ------------------------------------------- << 119 
120 G4tgrFileIn& G4tgrFileIn::GetInstanceOpened(co << 120 //-----------------------------------------------------------------------
                                                   >> 121 G4tgrFileIn& G4tgrFileIn::GetInstanceOpened( const G4String& filename )
121 {                                                 122 {
                                                   >> 123 
122   G4tgrFileIn& filein = G4tgrFileIn::GetInstan    124   G4tgrFileIn& filein = G4tgrFileIn::GetInstance(filename);
123   if(filein.GetName() != filename)             << 125   if (filein.GetName() != filename )
124   {                                               126   {
125     G4String ErrMessage = "File not opened yet    127     G4String ErrMessage = "File not opened yet: " + filename;
126     G4Exception("G4tgrFileIn::GetInstanceOpene << 128     G4Exception("G4tgrFileIn::GetInstanceOpened()",
127                 FatalException, ErrMessage);   << 129                 "InvalidInput", FatalException, ErrMessage);
128   }                                               130   }
129   else                                            131   else
130   {                                               132   {
131     return filein;                                133     return filein;
132   }                                               134   }
133   return filein;  // to avoid compilation warn << 135   return filein; // to avoid compilation warnings
134 }                                                 136 }
135                                                   137 
136 // ------------------------------------------- << 138 
137 G4int G4tgrFileIn::GetWordsInLine(std::vector< << 139 //----------------------------------------------------------------------- 
                                                   >> 140 G4int G4tgrFileIn::GetWordsInLine( std::vector<G4String>& wordlist)
138 {                                                 141 {
139   G4int isok = 1;                                 142   G4int isok = 1;
140                                                   143 
141   //---------- Read a line of file:               144   //---------- Read a line of file:
142   //           NOTE: cannot be read with a ist    145   //           NOTE: cannot be read with a istream_iterator,
143   //           because it uses G4cout, and the    146   //           because it uses G4cout, and then doesn't read '\n'
144   //----- Clear wordlist                          147   //----- Clear wordlist
145   G4int wsiz = (G4int)wordlist.size();         << 148   G4int wsiz = wordlist.size();
146   G4int ii;                                       149   G4int ii;
147   for(ii = 0; ii < wsiz; ++ii)                 << 150   for (ii = 0; ii < wsiz; ii++)
148   {                                               151   {
149     wordlist.pop_back();                          152     wordlist.pop_back();
150   }                                            << 153   } 
151                                                   154 
152   //---------- Loop lines while there is an en << 155   //---------- Loop lines while there is an ending '\' or line is blank   
153   const G4int NMAXLIN = 1000;                     156   const G4int NMAXLIN = 1000;
154   char ltemp[NMAXLIN];  // there won't be line << 157   char ltemp[NMAXLIN]; // there won't be lines longer than NMAXLIN characters
155   for(;;)                                      << 158   for (;;)
156   {                                               159   {
157     (theLineNo[theCurrentFile])++;                160     (theLineNo[theCurrentFile])++;
158     for(ii = 0; ii < NMAXLIN; ++ii)            << 161     for ( ii = 0; ii < NMAXLIN; ii++)  { ltemp[ii] = ' '; }
159     {                                          << 162     theFiles[theCurrentFile]->getline( ltemp, NMAXLIN ); 
160       ltemp[ii] = ' ';                         << 
161     }                                          << 
162     theFiles[theCurrentFile]->getline(ltemp, N << 
163                                                   163 
164     //---------- Check for lines longer than N    164     //---------- Check for lines longer than NMAXLIN character
165     for(ii = 0; ii < NMAXLIN; ++ii)            << 165     for ( ii=0; ii < NMAXLIN; ii++)
166     {                                             166     {
167       if(ltemp[ii] == '\0')                    << 167       if ( ltemp[ii] == '\0' )  { break; }
168       {                                        << 
169         break;                                 << 
170       }                                        << 
171     }                                             168     }
172     if(ii == NMAXLIN - 1)                      << 169     if ( ii == NMAXLIN-1 )
173     {                                             170     {
174       ErrorInLine();                              171       ErrorInLine();
175       G4String ErrMessage = "Too long line. Pl << 172       G4String ErrMessage = "Too long line. Please split it "
176                             G4String("putting  << 173                           + G4String("putting a '\\' at the end!");
177       G4Exception("G4tgrFileIn::GetWordsInLine    174       G4Exception("G4tgrFileIn::GetWordsInLine()", "InvalidInput",
178                   FatalException, ErrMessage);    175                   FatalException, ErrMessage);
179     }                                             176     }
180                                                << 177     
181     //---------- End of file                      178     //---------- End of file
182     if(EndOfFile())                            << 179     if ( EndOfFile() )
183     {                                             180     {
184       return 0;                                   181       return 0;
185     }                                             182     }
186                                                << 183     
187     //---------- Convert line read to istrstre << 184     //---------- Convert line read to istrstream to split it in words 
188     std::istringstream istr_line(ltemp);          185     std::istringstream istr_line(ltemp);
189                                                << 186      
190     //--------- Count how many words are there    187     //--------- Count how many words are there in ltemp
191     //          this shouln't be needed, but S    188     //          this shouln't be needed, but SUN compiler has problems...
192     G4int NoWords = 0;                            189     G4int NoWords = 0;
193     char* tt      = ltemp;                     << 190     char* tt = ltemp;
194                                                   191 
195     G4String stemp(ltemp);                        192     G4String stemp(ltemp);
196     do                                            193     do
197     {                                             194     {
198       if(*tt != ' ' && *(tt) != '\0')          << 195       if( *tt != ' ' && *(tt) != '\0' )
199       {                                           196       {
200         if(tt == ltemp)                        << 197         if( tt == ltemp)
201         {                                         198         {
202           ++NoWords;                           << 199           NoWords++;
203 #ifdef G4VERBOSE                                  200 #ifdef G4VERBOSE
204           if(G4tgrMessenger::GetVerboseLevel() << 201           if( G4tgrMessenger::GetVerboseLevel() >= 3 )
205           {                                       202           {
206             G4cout << "G4tgrFileIn::GetWordsIn << 203             G4cout << "G4tgrFileIn::GetWordsInLine() - NoWords"
207                    << ltemp << G4endl;         << 204                    << NoWords << ltemp << G4endl;
208           }                                       205           }
209 #endif                                            206 #endif
210         }                                         207         }
211         else if(*(tt - 1) == ' ' || *(tt - 1)  << 208         else if( *(tt-1) == ' ' ||  *(tt-1) == '\015' ||  *(tt-1) == '\t')
212         {                                         209         {
213           ++NoWords;                           << 210           NoWords++; 
214 #ifdef G4VERBOSE                                  211 #ifdef G4VERBOSE
215           if(G4tgrMessenger::GetVerboseLevel() << 212           if( G4tgrMessenger::GetVerboseLevel() >= 3 )
216           {                                       213           {
217             G4cout << "G4tgrFileIn::GetWordsIn << 214             G4cout << "G4tgrFileIn::GetWordsInLine() - NoWords"
218                    << ltemp << G4endl;         << 215                    << NoWords << ltemp << G4endl;
219           }                                       216           }
220 #endif                                            217 #endif
221         }                                         218         }
222       }                                           219       }
223       ++tt;                                    << 220       tt++;
224     } while((*tt != '\0') && (stemp.length() ! << 221     } while((*tt != '\0') && (stemp.length()!=0));
225                                                   222 
226     if(stemp.length() == 0)                    << 223     G4String stempt (ltemp);
227     {                                          << 224     if(stempt.length() == 0)  { NoWords = 0; }
228       NoWords = 0;                             << 
229     }                                          << 
230                                                   225 
231     //--------- Read words from istr_line and     226     //--------- Read words from istr_line and write them into wordlist
232     for(ii = 0; ii < NoWords; ++ii)            << 227     for( ii=0; ii < NoWords; ii++)
233     {                                             228     {
234       stemp = "";                              << 229       G4String stemp = "";
235       istr_line >> stemp;                         230       istr_line >> stemp;
236       if(stemp.length() == 0)                  << 231       if ( stemp.length() == 0 )  { break; }
237       {                                        << 232       G4int comment = stemp.find(G4String("//") );
238         break;                                 << 
239       }                                        << 
240       G4int comment = (G4int)stemp.find(G4Stri << 
241 #ifdef G4VERBOSE                                  233 #ifdef G4VERBOSE
242       if(G4tgrMessenger::GetVerboseLevel() >=  << 234       if( G4tgrMessenger::GetVerboseLevel() >= 3 )
243       {                                           235       {
244         G4cout << "!!!COMMENT" << comment << s    236         G4cout << "!!!COMMENT" << comment << stemp.c_str() << G4endl;
245       }                                           237       }
246 #endif                                            238 #endif
247       if(comment == 0)                         << 239       if ( comment == 0 )
248       {                                           240       {
249         break;                                 << 241         break; 
250       }                                           242       }
251       else if(comment > 0)                     << 243       else if ( comment > 0 )
252       {                                           244       {
253         stemp = stemp.substr(0, comment);      << 245         stemp = stemp.substr( 0, comment );
254         wordlist.push_back(std::move(stemp));  << 246         wordlist.push_back(stemp);
255         break;                                    247         break;
256       }                                        << 248       } 
257       wordlist.push_back(std::move(stemp));    << 249       wordlist.push_back(stemp);
258     }                                             250     }
259                                                << 251     
260     // These two algorithms should be the more    252     // These two algorithms should be the more STL-like way, but they don't
261     // work for files whose lines end without     253     // work for files whose lines end without '\015'=TAB (STL problem: doesn't
262     // find end of string??):                     254     // find end of string??):
263     // istream_iterator<G4String, ptrdiff_t> G    255     // istream_iterator<G4String, ptrdiff_t> G4String_iter(istr_line);
264     // istream_iterator<G4String, ptrdiff_t> e    256     // istream_iterator<G4String, ptrdiff_t> eosl;
265     // copy(G4String_iter, eosl, back_inserter    257     // copy(G4String_iter, eosl, back_inserter(wordlist));
266     // typedef istream_iterator<G4String, ptrd    258     // typedef istream_iterator<G4String, ptrdiff_t> G4String_iter;
267     // copy(G4String_iter(istr_line), G4String    259     // copy(G4String_iter(istr_line), G4String_iter(), back_inserter(wordlist));
268                                                << 260     
269     if(wordlist.size() != 0)                   << 261     if ( wordlist.size() != 0 )
270     {                                             262     {
271       if((*(wordlist.end() - 1)).compare("\\") << 263       if( (*(wordlist.end()-1)).compare("\\") == 0 )   // use '\' to mark
272       {                                        << 264       {                                                // continuing line
273         wordlist.pop_back();                      265         wordlist.pop_back();
274       }                                           266       }
275       else                                        267       else
276       {                                           268       {
277         break;                                    269         break;
278       }                                           270       }
279     }                                             271     }
280   }                                               272   }
281                                                << 273   
282   //--------- A pair of double quotes delimits    274   //--------- A pair of double quotes delimits a word, therefore, look for the
283   //          case where there is more than on    275   //          case where there is more than one word between two double quotes
284   std::vector<G4String> wordlist2;                276   std::vector<G4String> wordlist2;
285   G4String wordq      = "";                    << 277   G4String wordq = "";
286   unsigned int imerge = 0;                        278   unsigned int imerge = 0;
287   for(std::size_t jj = 0; jj < wordlist.size() << 279   for( size_t ii = 0; ii < wordlist.size(); ii++)
288   {                                               280   {
289     if(wordlist[jj].substr(0, 1) == "\"")      << 281     if( wordlist[ii].substr(0,1) == "\"" )
290     {                                             282     {
291       imerge = 1;                                 283       imerge = 1;
292     }                                          << 284     } 
293     if(wordlist[jj][G4int(wordlist[jj].size()  << 285     if( wordlist[ii][ wordlist[ii].size()-1 ] == '\"' )
294     {                                             286     {
295       if(imerge != 1)                          << 287       if( imerge != 1 )
296       {                                           288       {
297         const G4String& err1 = " word with tra << 289         G4String err1 = " word with trailing '\"' while there is no";
298         const G4String& err2 = " previous word << 290         G4String err2 = " previous word with leading '\"' in line ";
299         const G4String& err  = err1 + err2;    << 291         G4String err = err1 + err2;
300         DumpException(err);                       292         DumpException(err);
301       }                                           293       }
302       imerge = 2;                                 294       imerge = 2;
303     }                                             295     }
304     if(imerge == 0)                            << 296     if( imerge == 0 )
305     {                                             297     {
306       wordlist2.push_back(wordlist[jj]);       << 298       wordlist2.push_back( wordlist[ii] );
307     }                                             299     }
308     else if(imerge == 1)                       << 300     else if( imerge == 1 )
309     {                                             301     {
310       if(wordq == "")                          << 302       if( wordq == "" )
311       {                                           303       {
312         wordq.append(wordlist[jj].substr(1, wo << 304         wordq.append( wordlist[ii].substr(1,wordlist[ii].size()) );
313       }                                           305       }
314       else                                        306       else
315       {                                           307       {
316         wordq.append(wordlist[jj].substr(0, wo << 308         wordq.append( wordlist[ii].substr(0,wordlist[ii].size()) );
317       }                                           309       }
318       wordq.append(" ");                          310       wordq.append(" ");
319     }                                             311     }
320     else if(imerge == 2)                       << 312     else if( imerge == 2 )
321     {                                             313     {
322       if(wordq == "")                          << 314       if( wordq == "" )
323       {                                           315       {
324         wordq.append(wordlist[jj].substr(1, wo << 316         wordq.append( wordlist[ii].substr(1,wordlist[ii].size()-2));
325       }                                           317       }
326       else                                        318       else
327       {                                           319       {
328         wordq.append(wordlist[jj].substr(0, wo << 320         wordq.append( wordlist[ii].substr(0,wordlist[ii].size()-1) );
329       }                                        << 321       } 
330       wordlist2.push_back(wordq);              << 322       wordlist2.push_back( wordq );
331       wordq  = "";                             << 323       wordq = "";
332       imerge = 0;                                 324       imerge = 0;
333     }                                             325     }
334   }                                               326   }
335   if(imerge == 1)                              << 327   if( imerge == 1 )
336   {                                               328   {
337     const G4String& err1 = " word with leading << 329     G4String err1 = " word with leading '\"' in line while there is no";
338     const G4String& err2 = " later word with t << 330     G4String err2 = " later word with trailing '\"' in line ";
339     const G4String& err  = err1 + err2;        << 331     G4String err = err1 + err2;
340     DumpException(err);                           332     DumpException(err);
341   }                                               333   }
342                                                   334 
343   wordlist = std::move(wordlist2);             << 335   wordlist = wordlist2;
344                                                   336 
345   // Or why not like this (?):                    337   // Or why not like this (?):
346   // typedef std::istream_iterator<G4String, p    338   // typedef std::istream_iterator<G4String, ptrdiff_t> string_iter;
347   // std::copy(string_iter(istr_line), string_    339   // std::copy(string_iter(istr_line), string_iter(), back_inserter(wordlist));
348                                                << 340   
349   // check if including a new file                341   // check if including a new file
350   if(wordlist[0] == "#include")                << 342   if( wordlist[0] == "#include" )
351   {                                               343   {
352     if(wordlist.size() != 2)                   << 344     if( wordlist.size() != 2 )
353     {                                             345     {
354       ErrorInLine();                              346       ErrorInLine();
355       G4String ErrMessage =                    << 347       G4String ErrMessage
356         "'#include' should have as second argu << 348                = "'#include' should have as second argument, the filename !";
357       G4Exception("G4tgrFileIn::GetWordsInLine    349       G4Exception("G4tgrFileIn::GetWordsInLine()", "InvalidInput",
358                   FatalException, ErrMessage);    350                   FatalException, ErrMessage);
359     }                                             351     }
360                                                   352 
361 #ifdef G4VERBOSE                                  353 #ifdef G4VERBOSE
362     if(G4tgrMessenger::GetVerboseLevel() >= 3) << 354     if( G4tgrMessenger::GetVerboseLevel() >= 3 )
363     {                                             355     {
364       G4cout << " G4tgrFileIn::GetWordsInLine(    356       G4cout << " G4tgrFileIn::GetWordsInLine() - Include found !" << G4endl;
365     }                                             357     }
366 #endif                                            358 #endif
367     OpenNewFile(wordlist[1].c_str());          << 359     OpenNewFile( wordlist[1].c_str() );
368     isok = GetWordsInLine(wordlist);           << 360     isok = GetWordsInLine( wordlist);
369   }                                               361   }
370                                                   362 
371   return isok;                                    363   return isok;
372 }                                                 364 }
373                                                   365 
374 // ------------------------------------------- << 366 
                                                   >> 367 //-----------------------------------------------------------------------
375 void G4tgrFileIn::ErrorInLine()                   368 void G4tgrFileIn::ErrorInLine()
376 {                                                 369 {
377   G4cerr << "!! EXITING: ERROR IN LINE No " << << 370   G4cerr << "!! EXITING: ERROR IN LINE No "
378          << " file: " << theNames[theCurrentFi << 371          << theLineNo[theCurrentFile] << " file: "
                                                   >> 372          << theNames[theCurrentFile] << " : ";
379 }                                                 373 }
380                                                   374 
381 // ------------------------------------------- << 375 
                                                   >> 376 //-----------------------------------------------------------------------
382 G4bool G4tgrFileIn::EndOfFile()                   377 G4bool G4tgrFileIn::EndOfFile()
383 {                                                 378 {
384   G4bool isok = theFiles[theCurrentFile]->eof(    379   G4bool isok = theFiles[theCurrentFile]->eof();
385   if(isok)                                     << 380   if( isok )
386   {                                               381   {
387 #ifdef G4VERBOSE                                  382 #ifdef G4VERBOSE
388     if(G4tgrMessenger::GetVerboseLevel() >= 3) << 383     if( G4tgrMessenger::GetVerboseLevel() >= 3 )
389     {                                             384     {
390       G4cout << " G4tgrFileIn::EndOfFile() - E << 385       G4cout << " G4tgrFileIn::EndOfFile() - EOF: "
                                                   >> 386              << theCurrentFile << G4endl;
391     }                                             387     }
392 #endif                                            388 #endif
393     --theCurrentFile;                          << 389     theCurrentFile--;
394     if(theCurrentFile != -1)  // Last file wil << 390     if( theCurrentFile != -1 )   // Last file will be closed by the user
395     {                                             391     {
396       Close();                                    392       Close();
397     }                                             393     }
398   }                                               394   }
399                                                   395 
400   // Only real closing if all files are closed    396   // Only real closing if all files are closed
401 #ifdef G4VERBOSE                                  397 #ifdef G4VERBOSE
402   if(G4tgrMessenger::GetVerboseLevel() >= 3)   << 398   if( G4tgrMessenger::GetVerboseLevel() >= 3 )
403   {                                               399   {
404     G4cout << " G4tgrFileIn::EndOfFile() - EOF << 400     G4cout << " G4tgrFileIn::EndOfFile() - EOF: "
405            << theCurrentFile << G4endl;        << 401            << isok << " " << theCurrentFile << G4endl;
406   }                                               402   }
407 #endif                                            403 #endif
408   if(theCurrentFile != -1)                     << 404   if( theCurrentFile != -1 )
409   {                                            << 405   { 
410     return false;                              << 406     return 0;
411   }                                               407   }
412   else                                            408   else
413   {                                               409   {
414     return isok;                                  410     return isok;
415   }                                               411   }
416 }                                                 412 }
417                                                   413 
418 // ------------------------------------------- << 414 
                                                   >> 415 //-----------------------------------------------------------------------
419 void G4tgrFileIn::Close()                         416 void G4tgrFileIn::Close()
420 {                                                 417 {
421 #ifdef G4VERBOSE                                  418 #ifdef G4VERBOSE
422   if(G4tgrMessenger::GetVerboseLevel() >= 3)   << 419   if( G4tgrMessenger::GetVerboseLevel() >= 3 )
423   {                                               420   {
424     G4cout << "G4tgrFileIn::Close() - " << the << 421     G4cout << "G4tgrFileIn::Close() - "
425            << theFiles.size() << G4endl;       << 422            << theCurrentFile << ", size " << theFiles.size() << G4endl;
426   }                                               423   }
427 #endif                                            424 #endif
428                                                   425 
429   theFiles[theCurrentFile + 1]->close();       << 426   theFiles[theCurrentFile+1]->close();
430   theFiles.pop_back();                            427   theFiles.pop_back();
431 }                                                 428 }
432                                                   429 
433 // ------------------------------------------- << 430 
434 void G4tgrFileIn::DumpException(const G4String << 431 //-----------------------------------------------------------------------
                                                   >> 432 void G4tgrFileIn::DumpException( const G4String& sent )
435 {                                                 433 {
436   const G4String& Err1 = sent + " in file " +  << 434   G4String Err1 = sent + " in file " + theName;
437   const G4String& Err2 =                       << 435   G4String Err2 = " line No: "
438     ", line No: " + G4UIcommand::ConvertToStri << 436                 + G4UIcommand::ConvertToString(theLineNo[theCurrentFile]);
439   const G4String& ErrMessage = Err1 + Err2;    << 437   G4String ErrMessage = Err1;
440   G4Exception("G4tgrFileIn::DumpException()",     438   G4Exception("G4tgrFileIn::DumpException()", "FileError",
441               FatalException, ErrMessage);     << 439               FatalException, ErrMessage);  
442 }                                                 440 }
                                                   >> 441 
443                                                   442