source: trunk/source/g3tog4/src/G3fillParams.cc.archive @ 1232

Last change on this file since 1232 was 965, checked in by garnier, 15 years ago

update g3tog4

File size: 2.1 KB
Line 
1// This code implementation is the intellectual property of
2// the GEANT4 collaboration.
3//
4// By copying, distributing or modifying the Program (or any work
5// based on the Program) you indicate your acceptance of this statement,
6// and all its terms.
7//
8// $Id: G3fillParams.cc.archive,v 1.2 2003/06/16 16:50:54 gunter Exp $
9// GEANT4 tag $Name: geant4-09-02-ref-02 $
10//
11// extracted from clparse.cc by I. Hrivnacova, 30.7.99
12
13#include "globals.hh"
14#include <fstream>
15
16ofstream ofile;
17
18G4int narray;
19G4int Ipar[1000];
20G4double Rpar[1000];
21G4String Spar[1000];
22
23void G3fillParams(G4String *tokens, char *ptypes)
24//
25// G3fillParams
26//
27// Interpret tokens to fill call parameters, based on parameter
28//   types ptypes
29//
30{
31    // loop over ptypes
32    G4int i =0, ipt = 0, k = 0;
33    G4int ni =0, nr = 0, ns = 0;
34    while (ptypes[i] != '\0')
35        {
36            switch (ptypes[i]) {
37            case 'i':
38                Ipar[ni] = atoi(tokens[ipt].data());
39                narray = Ipar[ni];
40                ni++; ipt++;
41                break;
42            case 'r':
43                Rpar[nr] = atof(tokens[ipt].data());
44                nr++; ipt++;
45                break;
46            case 's':
47                Spar[ns] = tokens[ipt];
48                ns++; ipt++;
49                break;
50            case 'I':
51                for (k=0; k < narray; k++)
52                    {
53                        Ipar[ni] = atoi(tokens[ipt].data());
54                        ni++; ipt++;
55                    }
56                break;
57            case 'R':
58                for (k=0; k < narray; k++)
59                    {
60                        Rpar[nr] = atof(tokens[ipt].data());
61                        nr++; ipt++;
62                    }
63                break;
64            case 'S':
65                for (k=0; k < narray; k++)
66                    {
67                        Spar[ns] = tokens[ipt];
68                        ns++; ipt++;
69                    }
70                break;
71            default:
72                ofile << "unidentified ptype '" << ptypes[i] << endl;
73            };
74            i++;
75        }
76}
Note: See TracBrowser for help on using the repository browser.