Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/medical/dna/chem3/src/CommandLineParser.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 /examples/extended/medical/dna/chem3/src/CommandLineParser.cc (Version 11.3.0) and /examples/extended/medical/dna/chem3/src/CommandLineParser.cc (Version 10.6.p3)


  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 // This example is provided by the Geant4-DNA      26 // This example is provided by the Geant4-DNA collaboration
 27 // Any report or published results obtained us     27 // Any report or published results obtained using the Geant4-DNA software
 28 // shall cite the following Geant4-DNA collabo     28 // shall cite the following Geant4-DNA collaboration publication:
 29 // Med. Phys. 37 (2010) 4692-4708                  29 // Med. Phys. 37 (2010) 4692-4708
 30 // J. Comput. Phys. 274 (2014) 841-882             30 // J. Comput. Phys. 274 (2014) 841-882
 31 // The Geant4-DNA web site is available at htt     31 // The Geant4-DNA web site is available at http://geant4-dna.org
 32 //                                                 32 //
 33 // Author: Mathieu Karamitros                      33 // Author: Mathieu Karamitros
 34 //                                                 34 //
 35 //                                                 35 //
 36 /// \file CommandLineParser.cc                     36 /// \file CommandLineParser.cc
 37 /// \brief Implementation of the CommandLinePa     37 /// \brief Implementation of the CommandLineParser class
 38                                                    38 
 39 #include "CommandLineParser.hh"                << 
 40                                                << 
 41 #include <iomanip>                                 39 #include <iomanip>
                                                   >>  40 #include "CommandLineParser.hh"
 42                                                    41 
 43 using namespace std;                               42 using namespace std;
 44 using namespace G4DNAPARSER;                       43 using namespace G4DNAPARSER;
 45                                                    44 
 46 CommandLineParser* CommandLineParser::fpInstan     45 CommandLineParser* CommandLineParser::fpInstance(0);
 47 G4String Command::fNoOption = "NoOption";          46 G4String Command::fNoOption = "NoOption";
 48                                                    47 
                                                   >>  48 
 49 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 50                                                    50 
 51 inline bool MATCH(const char* a, const char* b <<  51 inline bool MATCH(const char *a, const char *b)
 52 {                                                  52 {
 53   return strcmp(a, b) == 0;                        53   return strcmp(a, b) == 0;
 54 }                                                  54 }
 55                                                    55 
 56 //....oooOO0OOooo........oooOO0OOooo........oo     56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 57                                                    57 
 58 CommandLineParser::CommandLineParser()             58 CommandLineParser::CommandLineParser()
 59 {                                                  59 {
 60   // G4cout << "############ NEW PARSE #######     60   // G4cout << "############ NEW PARSE ##########" << G4endl;
 61   fpInstance = this;                               61   fpInstance = this;
 62   fOptionsWereSetup = false;                       62   fOptionsWereSetup = false;
 63   fMaxMarkerLength = 0;                            63   fMaxMarkerLength = 0;
 64   fMaxOptionNameLength = 0;                        64   fMaxOptionNameLength = 0;
 65   AddCommand("--help", Command::WithoutOption,     65   AddCommand("--help", Command::WithoutOption, "Print this help");
 66   AddCommand("-h", Command::WithoutOption, "Pr     66   AddCommand("-h", Command::WithoutOption, "Print this help");
 67   AddCommand("&", Command::WithoutOption);         67   AddCommand("&", Command::WithoutOption);
 68                                                    68 
 69   fVerbose = 0;                                    69   fVerbose = 0;
 70 }                                                  70 }
 71                                                    71 
 72 //....oooOO0OOooo........oooOO0OOooo........oo     72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 73                                                    73 
 74 CommandLineParser* CommandLineParser::GetParse     74 CommandLineParser* CommandLineParser::GetParser()
 75 {                                                  75 {
 76   if (!fpInstance) new CommandLineParser;          76   if (!fpInstance) new CommandLineParser;
 77   return fpInstance;                               77   return fpInstance;
 78 }                                                  78 }
 79                                                    79 
 80 //....oooOO0OOooo........oooOO0OOooo........oo     80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 81                                                    81 
 82 CommandLineParser::~CommandLineParser()            82 CommandLineParser::~CommandLineParser()
 83 {                                                  83 {
 84   std::map<G4String, Command*>::iterator it =      84   std::map<G4String, Command*>::iterator it = fCommandMap.begin();
 85   for (; it != fCommandMap.end(); it++) {      <<  85   for (; it != fCommandMap.end(); it++)
                                                   >>  86   {
 86     if (it->second) delete it->second;             87     if (it->second) delete it->second;
 87   }                                                88   }
 88 }                                                  89 }
 89                                                    90 
 90 //....oooOO0OOooo........oooOO0OOooo........oo     91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 91                                                    92 
 92 void CommandLineParser::DeleteInstance()           93 void CommandLineParser::DeleteInstance()
 93 {                                                  94 {
 94   if (fpInstance) {                            <<  95   if (fpInstance)
                                                   >>  96   {
 95     delete fpInstance;                             97     delete fpInstance;
 96     fpInstance = 0;                                98     fpInstance = 0;
 97   }                                                99   }
 98 }                                                 100 }
 99                                                   101 
100 //....oooOO0OOooo........oooOO0OOooo........oo    102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101                                                   103 
102 Command::Command(Command::Type commandType, co << 104 Command::Command(Command::Type commandType,
                                                   >> 105                  const G4String& description)
103 {                                                 106 {
104   fType = commandType;                            107   fType = commandType;
105   fDescription = description;                     108   fDescription = description;
106   fActive = false;                                109   fActive = false;
107 }                                                 110 }
108                                                   111 
109 CommandWithOption::CommandWithOption(Command:: << 112 CommandWithOption::CommandWithOption(Command::Type commandType,
110                                      const G4S << 113                  const G4String& description,
111   : Command(commandType, description)          << 114                  const G4String& defaultOption,
                                                   >> 115                  const G4String& optionName) : 
                                                   >> 116 Command(commandType, description)
112 {                                                 117 {
113   fDefaultOption = defaultOption;                 118   fDefaultOption = defaultOption;
114   fOptionName = optionName;                       119   fOptionName = optionName;
115   fOption = "";                                   120   fOption = "";
116 }                                                 121 }
117                                                   122 
                                                   >> 123 
118 //....oooOO0OOooo........oooOO0OOooo........oo    124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119                                                   125 
120 int CommandLineParser::Parse(int& argc, char** << 126 int CommandLineParser::Parse(int& argc, char **argv)
121 {                                                 127 {
122   //    G4cout << "Parse " << G4endl;             128   //    G4cout << "Parse " << G4endl;
123   static char null[1] = {""};                  << 129   static char null[1] = { "" };
124   int firstArgc = argc;                           130   int firstArgc = argc;
125                                                   131 
126   for (int i = 1; i < firstArgc; i++) {        << 132   for (int i = 1; i < firstArgc; i++)
                                                   >> 133   {
127     Command* command = FindCommand(argv[i]);      134     Command* command = FindCommand(argv[i]);
128     if (command == 0) continue;                   135     if (command == 0) continue;
129                                                   136 
130     if (fVerbose) G4cout << "Command : " << ar    137     if (fVerbose) G4cout << "Command : " << argv[i] << G4endl;
131                                                   138 
132     fOptionsWereSetup = true;                     139     fOptionsWereSetup = true;
133     command->fActive = true;                      140     command->fActive = true;
134                                                   141 
135     G4String marker(argv[i]);                     142     G4String marker(argv[i]);
136                                                   143 
137     if (strcmp(argv[i], "-h") != 0 && strcmp(a << 144     if (strcmp(argv[i], "-h") != 0 && strcmp(argv[i], "--help") != 0)
                                                   >> 145     {
138       argv[i] = null;                             146       argv[i] = null;
139     }                                             147     }
140                                                   148 
141     if (command->fType == Command::WithOption) << 149     if (command->fType == Command::WithOption)
                                                   >> 150     {
142       if (fVerbose) G4cout << "WithOption" <<     151       if (fVerbose) G4cout << "WithOption" << G4endl;
143                                                   152 
144       if (i + 1 > firstArgc || argv[i + 1] ==  << 153       if(i+1 > firstArgc || argv[i+1]==0 || argv[i+1][0]=='-')
145         G4cerr << "An command line option is m << 154       {
                                                   >> 155         G4cerr << "An command line option is missing for "
                                                   >> 156                << marker << G4endl;
146         abort();                                  157         abort();
147       }                                           158       }
148                                                   159 
149       command->SetOption((const char*)strdup(a << 160       command->SetOption( (const char*) strdup(argv[i+1]) );
150       argv[i + 1] = null;                      << 161       argv[i+1] = null;
151       i++;                                        162       i++;
152     }                                             163     }
153     else if (command->fType == Command::Option << 164     else if(command->fType == Command::OptionNotCompulsory)
154       if (fVerbose) G4cout << "OptionNotCompul << 165     {
155                                                << 166       if(fVerbose)
156       if (i + 1 < firstArgc) {                 << 167       G4cout <<"OptionNotCompulsory"<<G4endl;
157         G4String buffer = (const char*)strdup( << 
158                                                   168 
159         if (buffer.empty() == false) {         << 169       if(i+1 < firstArgc)
160           if (buffer.at(0) != '-' && buffer.at << 170       {
161               && buffer.at(0) != '|')          << 171         G4String buffer = (const char*) strdup(argv[i+1]);
                                                   >> 172 
                                                   >> 173         if(buffer.empty() == false)
                                                   >> 174         {
                                                   >> 175           if(buffer.at(0) != '-'
                                                   >> 176              && buffer.at(0) != '&'
                                                   >> 177              && buffer.at(0) != '>'
                                                   >> 178              && buffer.at(0) != '|')
162           {                                       179           {
163             if (fVerbose) {                    << 180             if(fVerbose)
                                                   >> 181             {
164               G4cout << "facultative option is    182               G4cout << "facultative option is : " << buffer << G4endl;
165             }                                     183             }
166                                                   184 
167             command->SetOption((const char*)st << 185             command->SetOption( (const char*) strdup(argv[i+1]) );
168             argv[i + 1] = null;                << 186             argv[i+1] = null;
169             i++;                                  187             i++;
170             continue;                             188             continue;
171           }                                       189           }
172         }                                         190         }
173       }                                           191       }
174                                                   192 
175       if (fVerbose) G4cout << "Option not set" << 193       if(fVerbose)
                                                   >> 194       G4cout << "Option not set" << G4endl;
176                                                   195 
177       command->SetOption("");                     196       command->SetOption("");
178     }                                             197     }
179   }                                               198   }
180   CorrectRemainingOptions(argc, argv);            199   CorrectRemainingOptions(argc, argv);
181                                                   200 
182   Command* commandLine(0);                        201   Command* commandLine(0);
183   if ((commandLine = GetCommandIfActive("--hel << 202   if ((commandLine = GetCommandIfActive("--help")) || (commandLine =
                                                   >> 203       GetCommandIfActive("-h")))
                                                   >> 204   {
184     G4cout << "Usage : " << argv[0] << " [OPTI    205     G4cout << "Usage : " << argv[0] << " [OPTIONS]" << G4endl;
185     PrintHelp();                                  206     PrintHelp();
186     return 1;                                     207     return 1;
187   }                                               208   }
188                                                   209 
189   return 0;                                       210   return 0;
190 }                                                 211 }
191                                                   212 
192 //....oooOO0OOooo........oooOO0OOooo........oo    213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
193                                                   214 
194 void CommandLineParser::PrintHelp()               215 void CommandLineParser::PrintHelp()
195 {                                                 216 {
196   std::map<G4String, Command*>::iterator it;      217   std::map<G4String, Command*>::iterator it;
197                                                   218 
198   int maxFieldLength = fMaxMarkerLength + fMax    219   int maxFieldLength = fMaxMarkerLength + fMaxOptionNameLength + 4;
199                                                   220 
200   G4cout << "Options: " << G4endl;                221   G4cout << "Options: " << G4endl;
201                                                   222 
202   for (it = fCommandMap.begin(); it != fComman << 223   for (it = fCommandMap.begin(); it != fCommandMap.end(); it++)
                                                   >> 224   {
203     Command* command = it->second;                225     Command* command = it->second;
204     if (command) {                             << 226     if (command)
                                                   >> 227     {
205       G4cout << setw(maxFieldLength) << left;     228       G4cout << setw(maxFieldLength) << left;
206                                                   229 
207       G4String toPrint = it->first;               230       G4String toPrint = it->first;
208                                                   231 
209       if (toPrint == "&") {                    << 232       if (toPrint == "&")
                                                   >> 233       {
210         continue;                                 234         continue;
211       }                                           235       }
212       else if (toPrint == "-h")                << 236       else if (toPrint == "-h") continue;
213         continue;                              << 237       else if (toPrint == "--help")
214       else if (toPrint == "--help") {          << 238       {
215         toPrint += ", -h";                        239         toPrint += ", -h";
216       }                                           240       }
217                                                   241 
218       if (command->GetType() != Command::Witho << 242       if(command->GetType() != Command::WithoutOption)
219         if (command->GetDefaultOption() != "") << 243       {
                                                   >> 244         if (command->GetDefaultOption() != "")
                                                   >> 245         {
220           toPrint += " \"" + command->GetDefau    246           toPrint += " \"" + command->GetDefaultOption() + "\"";
221         }                                         247         }
222       }                                           248       }
223       G4cout << toPrint;                          249       G4cout << toPrint;
224                                                   250 
225       G4cout << command->GetDescription() << G    251       G4cout << command->GetDescription() << G4endl;
226     }                                             252     }
227   }                                               253   }
228 }                                                 254 }
229                                                   255 
230 //....oooOO0OOooo........oooOO0OOooo........oo    256 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
231                                                   257 
232 void CommandLineParser::CorrectRemainingOption << 258 void CommandLineParser::CorrectRemainingOptions(int& argc, char **argv)
233 {                                                 259 {
234   // remove handled arguments from argument ar    260   // remove handled arguments from argument array
235   int j = 0;                                      261   int j = 0;
236   for (int i = 0; i < argc; i++) {             << 262   for (int i = 0; i < argc; i++)
237     if (strcmp(argv[i], "")) {                 << 263   {
                                                   >> 264     if (strcmp(argv[i], ""))
                                                   >> 265     {
238       argv[j] = argv[i];                          266       argv[j] = argv[i];
239       j++;                                        267       j++;
240     }                                             268     }
241   }                                               269   }
242   argc = j;                                       270   argc = j;
243 }                                                 271 }
244                                                   272 
245 //....oooOO0OOooo........oooOO0OOooo........oo    273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
246                                                   274 
247 void CommandLineParser::AddCommand(const G4Str << 275 void CommandLineParser::AddCommand(const G4String& marker,
248                                    const G4Str << 276                                    Command::Type type,
                                                   >> 277                                    const G4String& description,
                                                   >> 278                                    const G4String& defaultOption,
249                                    const G4Str    279                                    const G4String& optionName)
250 {                                                 280 {
251   // G4cout << "Add command : "<< marker << G4    281   // G4cout << "Add command : "<< marker << G4endl;
252                                                << 282   
253   Command* command = 0;                           283   Command* command = 0;
254   switch (type) {                              << 284   switch(type)
255     case Command::WithoutOption:               << 285   {
256       command = new Command(type, description) << 286  case Command::WithoutOption:
257       break;                                   << 287         command = new Command(type, description);
258                                                << 288         break;
259     default:                                   << 289         
260       command = new CommandWithOption(type, de << 290         default:
261       if ((int)defaultOption.length() > fMaxOp << 291         command = new CommandWithOption(type, 
262         fMaxOptionNameLength = defaultOption.l << 292                                         description, 
263       break;                                   << 293                                         defaultOption, 
                                                   >> 294                                         optionName);
                                                   >> 295         if ((int) defaultOption.length() > fMaxOptionNameLength)
                                                   >> 296           fMaxOptionNameLength = defaultOption.length();
                                                   >> 297         break;
264   }                                               298   }
265                                                   299 
266   if ((int)marker.length() > fMaxMarkerLength) << 300   if ((int) marker.length() > fMaxMarkerLength) fMaxMarkerLength =
                                                   >> 301       marker.length();
267   fCommandMap.insert(make_pair(marker, command    302   fCommandMap.insert(make_pair(marker, command));
268 }                                                 303 }
269                                                   304 
270 /*                                                305 /*
271 // Add one command but multiple markers           306 // Add one command but multiple markers
272 void Parser::AddCommand(vector<G4String> marke    307 void Parser::AddCommand(vector<G4String> markers,
273                         CommandType type,         308                         CommandType type,
274                         const G4String& descri    309                         const G4String& description,
275                         const G4String& option    310                         const G4String& optionName)
276 {                                                 311 {
277   // G4cout << "Add command : "<< marker << G4    312   // G4cout << "Add command : "<< marker << G4endl;
278   Command* command = new Command(type, descrip    313   Command* command = new Command(type, description, optionName);
279                                                   314 
280   for (size_t i = 0; i < markers.size; i++)       315   for (size_t i = 0; i < markers.size; i++)
281   {                                               316   {
282     G4String marker = markers[i];                 317     G4String marker = markers[i];
283     if ((int) marker.length() > fMaxMarkerLeng    318     if ((int) marker.length() > fMaxMarkerLength)
284     {                                             319     {
285       fMaxMarkerLength = marker.length();         320       fMaxMarkerLength = marker.length();
286     }                                             321     }
287     if ((int) optionName.length() > fMaxOption    322     if ((int) optionName.length() > fMaxOptionNameLength)
288     {                                             323     {
289       fMaxOptionNameLength = optionName.length    324       fMaxOptionNameLength = optionName.length();
290     }                                             325     }
291     fCommandMap.insert(make_pair(marker, comma    326     fCommandMap.insert(make_pair(marker, command));
292   }                                               327   }
293 }                                                 328 }
294 */                                                329 */
295                                                   330 
296 //....oooOO0OOooo........oooOO0OOooo........oo    331 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
297                                                   332 
298 Command* CommandLineParser::FindCommand(const     333 Command* CommandLineParser::FindCommand(const G4String& marker)
299 {                                                 334 {
300   std::map<G4String, Command*>::iterator it =     335   std::map<G4String, Command*>::iterator it = fCommandMap.find(marker);
301   if (it == fCommandMap.end()) {               << 336   if (it == fCommandMap.end())
                                                   >> 337   {
302     // G4cerr << "command not found" << G4endl    338     // G4cerr << "command not found" << G4endl;
303     return 0;                                     339     return 0;
304   }                                               340   }
305   return it->second;                              341   return it->second;
306 }                                                 342 }
307                                                   343 
308 //....oooOO0OOooo........oooOO0OOooo........oo    344 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
309                                                   345 
310 Command* CommandLineParser::GetCommandIfActive << 346 Command* CommandLineParser::GetCommandIfActive(const G4String &marker)
311 {                                                 347 {
312   Command* command = FindCommand(marker);         348   Command* command = FindCommand(marker);
313   if (command) {                               << 349   if (command)
                                                   >> 350   {
314     // G4cout << "Command found : "<< marker <    351     // G4cout << "Command found : "<< marker << G4endl;
315                                                   352 
316     if (command->fActive) {                    << 353     if (command->fActive)
                                                   >> 354     {
317       // G4cout << "Command Active" << G4endl;    355       // G4cout << "Command Active" << G4endl;
318       return command;                             356       return command;
319     }                                             357     }
320     // else                                       358     // else
321     //  G4cout <<"Command not active" << G4end    359     //  G4cout <<"Command not active" << G4endl;
322   }                                               360   }
323   else {                                       << 361   else
                                                   >> 362   {
324     G4ExceptionDescription description;           363     G4ExceptionDescription description;
325     description << "You try to retrieve a comm << 364     description << "You try to retrieve a command that was not registered : "
326     G4Exception("CommandLineParser::GetCommand << 365            << marker << G4endl;
327                 description, "");              << 366     G4Exception("CommandLineParser::GetCommandIfActive",
                                                   >> 367                 "COMMAND LINE NOT DEFINED", FatalException, description, "");
328     // If you are using this class outside of     368     // If you are using this class outside of Geant4, use exit(-1) instead
329     // exit(-1);                               << 369     //exit(-1);
330   }                                               370   }
331   return 0;                                       371   return 0;
332 }                                                 372 }
333                                                   373 
334 //....oooOO0OOooo........oooOO0OOooo........oo    374 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
335                                                   375 
336 bool CommandLineParser::CheckIfNotHandledOptio    376 bool CommandLineParser::CheckIfNotHandledOptionsExists(int& argc, char** argv)
337 {                                                 377 {
338   if (argc > 0) {                              << 378   if (argc > 0)
                                                   >> 379   {
339     G4bool kill = false;                          380     G4bool kill = false;
340     for (G4int i = 1; i < argc; i++) {         << 381     for (G4int i = 1; i < argc; i++)
341       if (strcmp(argv[i], "")) {               << 382     {
                                                   >> 383       if (strcmp(argv[i], ""))
                                                   >> 384       {
342         kill = true;                              385         kill = true;
343         G4cerr << "Unknown argument : " << arg    386         G4cerr << "Unknown argument : " << argv[i] << "\n";
344       }                                           387       }
345     }                                             388     }
346     if (kill) {                                << 389     if (kill)
347       G4cerr << "The option " << argv[0] << "  << 390     {
                                                   >> 391       G4cerr << "The option " << argv[0]
                                                   >> 392              << " is not handled this programme." << G4endl;
348       G4cout << "Usage : " << argv[0] << " [OP    393       G4cout << "Usage : " << argv[0] << " [OPTIONS]" << G4endl;
349       PrintHelp();                                394       PrintHelp();
350       return true;  // KILL APPLICATION        << 395       return true; // KILL APPLICATION
351     }                                             396     }
352   }                                               397   }
353   return false;                                   398   return false;
354 }                                                 399 }
355                                                   400