-------------------------------------------------------------------- G4command operations -------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////
| 111 | // -------------------------------------------------------------------- |
| 112 | //////////////////////////////////////////////////////////////////////// |
| 113 | G4UIcommandTree* G4VUIshell::GetCommandTree(const G4String& input) const |
| 114 | //////////////////////////////////////////////////////////////////////// |
| 115 | { |
| 116 | G4UImanager* UI = G4UImanager::GetUIpointer(); |
| 117 | |
| 118 | G4UIcommandTree* cmdTree = UI->GetTree(); // root tree |
| 119 | |
| 120 | G4String absPath = GetAbsCommandDirPath(G4StrUtil::strip_copy(input)); |
| 121 | |
| 122 | // parsing absolute path ... |
| 123 | if (absPath.length() == 0) return nullptr; |
| 124 | if (absPath[G4int(absPath.length() - 1)] != '/') return nullptr; // error?? |
| 125 | if (absPath == "/") return cmdTree; |
| 126 | |
| 127 | for (std::size_t indx = 1; indx < absPath.length() - 1;) { |
| 128 | std::size_t jslash = absPath.find('/', indx); // search index begin with "/" |
| 129 | if (jslash != G4String::npos) { |
| 130 | if (cmdTree != nullptr) cmdTree = cmdTree->GetTree(G4String(absPath.substr(0, jslash + 1))); |
| 131 | } |
| 132 | indx = jslash + 1; |
| 133 | } |
| 134 | |
| 135 | if (cmdTree == nullptr) return nullptr; |
| 136 | return cmdTree; |
| 137 | } |
| 138 | |
| 139 | ////////////////////////////////////////////////////////////////////// |
| 140 | G4String G4VUIshell::GetAbsCommandDirPath(const G4String& apath) const |