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)
76 G4cerr <<
"ERROR: Can not open a macro file <"
77 << fileName <<
">. Set macro path with \"/control/macroPath\" if needed."
99 enum { BUFSIZE= 4096 };
100 static G4ThreadLocal char *linebuf = 0 ;
if (!linebuf) linebuf =
new char [BUFSIZE];
101 const char ctrM = 0x0d;
112 while ((nb= cmdline.find(
'\t',nb)) != G4String::npos) {
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;
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;
203 if(newCommand ==
"exit") {
208 if( newCommand[(
size_t)0] ==
'#') {
231 G4cout <<
"Pause session <" << Prompt <<
"> start." <<
G4endl;
235 G4cout <<
"Pause session <" << Prompt <<
"> Terminate." <<
G4endl;
virtual void PauseSessionStart(const G4String &Prompt)
G4int ExecCommand(const G4String &command)
static const G4double pos
G4String & replace(unsigned int, unsigned int, const char *, unsigned int)
static G4UImanager * GetUIpointer()
virtual G4UIsession * SessionStart()
G4String strip(G4int strip_Type=trailing, char c=' ')
G4GLOB_DLL std::ostream G4cerr
static void Tokenize(const G4String &str, std::vector< G4String > &tokens)
std::string::size_type str_size
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
G4UIsession * previousSession
G4UIbatch(const char *fileName, G4UIsession *prevSession=0)
std::ifstream macroStream