--------------------------------------------------------------------
| 244 | |
| 245 | // -------------------------------------------------------------------- |
| 246 | G4UIcommandTree* G4UIcommandTree::FindCommandTree(const char* commandPath) |
| 247 | { |
| 248 | // Try to match a command or a path with the one given. |
| 249 | // @commandPath : command or path to match |
| 250 | // @return the commandTree found or nullptr if not |
| 251 | |
| 252 | G4String remainingPath = commandPath; |
| 253 | if (remainingPath.find(pathName) == std::string::npos) { |
| 254 | return nullptr; |
| 255 | } |
| 256 | remainingPath.erase(0, pathName.length()); |
| 257 | std::size_t i = remainingPath.find('/'); |
| 258 | if (i != std::string::npos) { |
| 259 | // Find path |
| 260 | G4String nextPath = pathName; |
| 261 | nextPath.append(remainingPath.substr(0, i + 1)); |
| 262 | std::size_t n_treeEntry = tree.size(); |
| 263 | for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) { |
| 264 | if (tree[i_thTree]->GetPathName() == commandPath) { |
| 265 | return tree[i_thTree]; |
| 266 | } |
| 267 | if (nextPath == tree[i_thTree]->GetPathName()) { |
| 268 | return tree[i_thTree]->FindCommandTree(commandPath); |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | else { |
| 273 | return this; |
| 274 | } |
| 275 | return nullptr; |
| 276 | } |
| 277 | |
| 278 | // -------------------------------------------------------------------- |
| 279 | G4String G4UIcommandTree::CompleteCommandPath(const G4String& aCommandPath) |
no test coverage detected