41 const char* delimiter=
" ";
43 G4String::size_type pos0= str.find_first_not_of(delimiter);
44 G4String::size_type
pos = str.find_first_of(delimiter, pos0);
46 while (pos != G4String::npos || pos0 != G4String::npos) {
47 if (str[pos0] ==
'\"') {
48 pos = str.find_first_of(
"\"", pos0+1);
49 if(pos != G4String::npos) pos++;
51 if (str[pos0] ==
'\'') {
52 pos = str.find_first_of(
"\'", pos0+1);
53 if(pos != G4String::npos) pos++;
56 tokens.push_back(str.substr(pos0, pos-pos0));
57 pos0 = str.find_first_not_of(delimiter, pos);
58 pos = str.find_first_of(delimiter, pos0);
71 previousSession(prevSession), isOpened(false)
74 macroStream.open(fileName, std::ios::in);
75 if(macroStream.fail()) {
76 G4cerr <<
"ERROR: Can not open a macro file <"
77 << fileName <<
">. Set macro path with \"/control/macroPath\" if needed."
91 if(isOpened) macroStream.close();
101 const char ctrM = 0x0d;
105 while(macroStream.good()) {
106 macroStream.getline(linebuf,
BUFSIZE);
112 while ((nb= cmdline.find(
'\t',nb)) != G4String::npos) {
113 cmdline.replace(nb, 1,
" ");
121 if(!qcontinued && cmdline.size()==0)
continue;
124 if(cmdline[(
size_t)0]==
'#')
return cmdline;
127 std::vector<G4String> tokens;
130 for (
G4int i=0; i<
G4int(tokens.size()); i++) {
132 if(tokens[i][(
size_t)0] ==
'#' )
break;
134 if(tokens[i] ==
'\\' || tokens[i] ==
'_' ) {
137 if( i !=
G4int(tokens.size())-1) {
140 "unexpected character after line continuation character");
144 cmdtotal+= tokens[i];
148 if(qcontinued)
continue;
150 if(cmdtotal.size() != 0)
break;
151 if(macroStream.eof())
break;
158 if(macroStream.eof() && cmdtotal.size()==0) {
171 G4int rc= UI-> ApplyCommand(command);
177 G4cerr <<
"***** COMMAND NOT FOUND <"
178 << command <<
"> *****" <<
G4endl;
181 G4cerr <<
"***** Illegal application state <"
182 << command <<
"> *****" <<
G4endl;
186 G4cerr <<
"***** Illegal parameter (" << pn <<
") <"
187 << command <<
"> *****" <<
G4endl;
198 if(!isOpened)
return previousSession;
201 G4String newCommand = ReadCommand();
203 if(newCommand ==
"exit") {
208 if( newCommand[(
size_t)0] ==
'#') {
216 G4int rc= ExecCommand(newCommand);
223 return previousSession;
231 G4cout <<
"Pause session <" << Prompt <<
"> start." <<
G4endl;
235 G4cout <<
"Pause session <" << Prompt <<
"> Terminate." <<
G4endl;
G4String strip(G4int strip_Type=trailing, char c=' ')
virtual G4UIsession * SessionStart()
static void Tokenize(const G4String &str, std::vector< G4String > &tokens)
std::string::size_type str_size
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4UIbatch(const char *fileName, G4UIsession *prevSession=0)
virtual void PauseSessionStart(const G4String &Prompt)
static const G4double pos
G4GLOB_DLL std::ostream G4cerr