--------------------------------------------------------------------
| 210 | |
| 211 | // -------------------------------------------------------------------- |
| 212 | G4UIcommand* G4UIcommandTree::FindPath(const char* commandPath) const |
| 213 | { |
| 214 | // This function tries to match a command name |
| 215 | |
| 216 | G4String remainingPath = commandPath; |
| 217 | if (remainingPath.find(pathName) == std::string::npos) { |
| 218 | return nullptr; |
| 219 | } |
| 220 | remainingPath.erase(0, pathName.length()); |
| 221 | std::size_t i = remainingPath.find('/'); |
| 222 | if (i == std::string::npos) { |
| 223 | // Find command |
| 224 | std::size_t n_commandEntry = command.size(); |
| 225 | for (std::size_t i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand) { |
| 226 | if (remainingPath == command[i_thCommand]->GetCommandName()) { |
| 227 | return command[i_thCommand]; |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | else { |
| 232 | // Find path |
| 233 | G4String nextPath = pathName; |
| 234 | nextPath.append(remainingPath.substr(0, i + 1)); |
| 235 | std::size_t n_treeEntry = tree.size(); |
| 236 | for (std::size_t i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree) { |
| 237 | if (nextPath == tree[i_thTree]->GetPathName()) { |
| 238 | return tree[i_thTree]->FindPath(commandPath); |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | return nullptr; |
| 243 | } |
| 244 | |
| 245 | // -------------------------------------------------------------------- |
| 246 | G4UIcommandTree* G4UIcommandTree::FindCommandTree(const char* commandPath) |
no test coverage detected