MCPcopy Create free account
hub / github.com/Geant4/geant4 / GetCommandLineString

Method GetCommandLineString

source/interfaces/core/src/G4UIcsh.cc:41–70  ·  view source on GitHub ↗

//////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

39
40///////////////////////////////////////////////////////
41G4String G4UIcsh::GetCommandLineString(const char* msg)
42///////////////////////////////////////////////////////
43{
44 MakePrompt(msg);
45 G4cout << promptString << std::flush;
46
47 G4String newCommand;
48 G4StrUtil::readline(G4cin, newCommand, false);
49 if (! G4cin.good()) {
50 G4cin.clear();
51 newCommand = "exit";
52 return newCommand;
53 }
54 G4StrUtil::rstrip(newCommand, '\r'); // fix for odd behavior on Windows
55
56 // multi-line
57 while ((newCommand.length() > 0) && (newCommand[G4int(newCommand.length() - 1)] == '_')) {
58 G4String newLine;
59 newCommand.erase(newCommand.length() - 1);
60 G4StrUtil::readline(G4cin, newLine, false);
61 if (! G4cin.good()) {
62 G4cin.clear();
63 newCommand = "exit";
64 return newCommand;
65 }
66 newCommand.append(newLine);
67 }
68
69 return newCommand;
70}

Callers 1

GetCommandMethod · 0.45

Calls 3

clearMethod · 0.45
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected