Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/argcv is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_argcv
0005 #define tools_argcv
0006 
0007 #include <vector>
0008 #include <string>
0009 #include "cstr"
0010 
0011 namespace tools {
0012 
0013 inline void new_argcv(const std::vector<std::string>& a_args,int& a_argc,char**& a_argv){
0014   // delete with delete_argcv
0015   a_argc = (int)a_args.size();
0016   if(a_argc<=0) {
0017     a_argc = 0;
0018     a_argv = 0;
0019     return;
0020   }
0021   typedef char* cstring;
0022   a_argv = new cstring[a_argc];
0023   for(int index=0;index<a_argc;index++) {
0024     const std::string& arg = a_args[index];
0025     a_argv[index] = new char[arg.size()+1];
0026     ::strcpy(a_argv[index],arg.c_str());
0027   }
0028 }
0029 
0030 inline void delete_argcv(int& a_argc,char**& a_argv) {
0031   for(int index=0;index<a_argc;index++) delete [] a_argv[index];
0032   delete [] a_argv;
0033   a_argc = 0;
0034   a_argv = 0;
0035 }
0036 
0037 }
0038 
0039 #endif