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

Method GetCommandTree

source/interfaces/core/src/G4VUIshell.cc:113–137  ·  view source on GitHub ↗

-------------------------------------------------------------------- G4command operations -------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

111// --------------------------------------------------------------------
112////////////////////////////////////////////////////////////////////////
113G4UIcommandTree* 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//////////////////////////////////////////////////////////////////////
140G4String G4VUIshell::GetAbsCommandDirPath(const G4String& apath) const

Callers

nothing calls this directly

Calls 5

substrMethod · 0.80
G4StringClass · 0.50
GetTreeMethod · 0.45
lengthMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected