Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Tokenizer Class Reference

#include <G4Tokenizer.hh>

Public Member Functions

 G4Tokenizer (const G4String &stn)
 
G4String operator() (const char *str=" \t\n", std::size_t l=0)
 

Detailed Description

Definition at line 41 of file G4Tokenizer.hh.

Constructor & Destructor Documentation

◆ G4Tokenizer()

G4Tokenizer::G4Tokenizer ( const G4String stn)
inline

Definition at line 44 of file G4Tokenizer.hh.

45 : string2tokenize(stn)
46 , actual(0)
47 {}

Member Function Documentation

◆ operator()()

G4String G4Tokenizer::operator() ( const char *  str = " \t\n",
std::size_t  l = 0 
)
inline

Definition at line 49 of file G4Tokenizer.hh.

50 {
51 std::size_t i, j, tmp;
52 G4bool hasws = false;
53 if(l == 0)
54 l = strlen(str);
55
56 // Skip leading delimeters
57 while(actual < string2tokenize.size())
58 {
59 for(i = 0; i < l; ++i)
60 {
61 if(string2tokenize[(G4int)actual] == str[i])
62 hasws = true;
63 }
64 if(hasws)
65 {
66 ++actual;
67 hasws = false;
68 }
69 else
70 break;
71 }
72
73 for(j = actual; j < string2tokenize.size(); ++j)
74 {
75 for(i = 0; i < l; ++i)
76 if(string2tokenize[(G4int)j] == str[i])
77 break;
78 if(i < l)
79 break;
80 }
81 if(j != string2tokenize.size())
82 {
83 tmp = actual;
84 actual = j + 1;
85 return string2tokenize.substr(tmp, j - tmp);
86 }
87 else
88 {
89 tmp = actual;
90 actual = j;
91 return string2tokenize.substr(tmp, j - tmp);
92 }
93 }
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85

The documentation for this class was generated from the following file: