Geant4-11
Public Member Functions | Private Attributes
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)
 

Private Attributes

std::size_t actual
 
G4String string2tokenize
 

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 {}
std::size_t actual
Definition: G4Tokenizer.hh:97
G4String string2tokenize
Definition: G4Tokenizer.hh:96

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[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[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

References actual, and string2tokenize.

Field Documentation

◆ actual

std::size_t G4Tokenizer::actual
private

Definition at line 97 of file G4Tokenizer.hh.

Referenced by operator()().

◆ string2tokenize

G4String G4Tokenizer::string2tokenize
private

Definition at line 96 of file G4Tokenizer.hh.

Referenced by operator()().


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