39 const char* delimiter =
" ";
41 G4String::size_type pos0 = str.find_first_not_of(delimiter);
42 G4String::size_type
pos = str.find_first_of(delimiter, pos0);
44 while(
pos != G4String::npos || pos0 != G4String::npos)
48 pos = str.find_first_of(
"\"", pos0 + 1);
49 if(
pos != G4String::npos)
54 pos = str.find_first_of(
"\'", pos0 + 1);
55 if(
pos != G4String::npos)
59 tokens.push_back(str.substr(pos0,
pos - pos0));
60 pos0 = str.find_first_not_of(delimiter,
pos);
61 pos = str.find_first_of(delimiter, pos0);
68 , previousSession(prevSession)
73 G4cerr <<
"ERROR: Can not open a macro file <" << fileName
74 <<
">. Set macro path with \"/control/macroPath\" if needed."
103 const char ctrM = 0x0d;
106 G4bool qcontinued =
false;
114 G4String::size_type nb = 0;
115 while((nb = cmdline.find(
'\t', nb)) != G4String::npos)
117 cmdline.replace(nb, 1,
" ");
125 if(!qcontinued && cmdline.size() == 0)
129 if(cmdline[(std::size_t) 0] ==
'#')
133 std::vector<G4String> tokens;
136 for(
G4int i = 0; i <
G4int(tokens.size()); ++i)
139 if(tokens[i][(std::size_t) 0] ==
'#')
142 if(tokens[i] ==
"\\" || tokens[i] ==
"_")
146 if(i !=
G4int(tokens.size()) - 1)
149 "unexpected character after line continuation character");
153 cmdtotal += tokens[i];
160 if(cmdtotal.size() != 0)
189 G4cerr <<
"***** COMMAND NOT FOUND <" << command <<
"> *****" <<
G4endl;
192 G4cerr <<
"***** Illegal application state <" << command <<
"> *****"
197 G4cerr <<
"***** Illegal parameter (" <<
pn <<
") <" << command
214 if(newCommand ==
"exit")
220 if(newCommand[(std::size_t) 0] ==
'#')
245 G4cout <<
"Pause session <" << Prompt <<
"> start." <<
G4endl;
249 G4cout <<
"Pause session <" << Prompt <<
"> Terminate." <<
G4endl;
static const G4double pos
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static void Tokenize(const G4String &str, std::vector< G4String > &tokens)
@ fIllegalApplicationState
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
virtual G4UIsession * SessionStart()
G4UIsession * previousSession
std::ifstream macroStream
G4int ExecCommand(const G4String &command)
G4UIbatch(const char *fileName, G4UIsession *prevSession=nullptr)
virtual void PauseSessionStart(const G4String &Prompt)
G4int ApplyCommand(const char *aCommand)
static G4UImanager * GetUIpointer()
void SetSession(G4UIsession *const value)
void strip(G4String &str, char c=' ')
Remove leading and trailing characters from string.
void rstrip(G4String &str, char c=' ')
Remove trailing characters from string.