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);
70 : previousSession(prevSession), isOpened(false)
75 G4cerr <<
"ERROR: Can not open a macro file <"
76 << fileName <<
">. Set macro path with \"/control/macroPath\" if needed."
98 enum { BUFSIZE= 4096 };
99 static G4ThreadLocal char *linebuf = 0 ;
if (!linebuf) linebuf =
new char [BUFSIZE];
100 const char ctrM = 0x0d;
111 while ((nb= cmdline.find(
'\t',nb)) != G4String::npos) {
120 if(!qcontinued && cmdline.size()==0)
continue;
123 if(cmdline[(
size_t)0]==
'#')
return cmdline;
126 std::vector<G4String> tokens;
129 for (
G4int i=0; i<
G4int(tokens.size()); i++) {
131 if(tokens[i][(
size_t)0] ==
'#' )
break;
133 if(tokens[i] ==
'\\' || tokens[i] ==
'_' ) {
136 if( i !=
G4int(tokens.size())-1) {
139 "unexpected character after line continuation character");
143 cmdtotal+= tokens[i];
147 if(qcontinued)
continue;
149 if(cmdtotal.size() != 0)
break;
170 G4int rc= UI-> ApplyCommand(command);
176 G4cerr <<
"***** COMMAND NOT FOUND <"
177 << command <<
"> *****" <<
G4endl;
180 G4cerr <<
"***** Illegal application state <"
181 << command <<
"> *****" <<
G4endl;
185 G4cerr <<
"***** Illegal parameter (" << pn <<
") <"
186 << command <<
"> *****" <<
G4endl;
202 if(newCommand ==
"exit") {
207 if( newCommand[(
size_t)0] ==
'#') {
230 G4cout <<
"Pause session <" << Prompt <<
"> start." <<
G4endl;
234 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
G4String & replace(unsigned int, unsigned int, const char *, unsigned int)
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cout
G4int ExecCommand(const G4String &command)
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)
std::ifstream macroStream
G4UIsession * previousSession
static const G4double pos
G4GLOB_DLL std::ostream G4cerr