--------------------------------------------------------------------
| 402 | |
| 403 | // -------------------------------------------------------------------- |
| 404 | G4String G4UImanager::SolveAlias(const char* aCmd) |
| 405 | { |
| 406 | G4String aCommand = aCmd; |
| 407 | std::size_t ia = aCommand.find('{'); |
| 408 | std::size_t iz = aCommand.find('#'); |
| 409 | while ((ia != std::string::npos) && ((iz == std::string::npos) || (ia < iz))) { |
| 410 | G4int ibx = -1; |
| 411 | while (ibx < 0) { |
| 412 | std::size_t ib = aCommand.find('}'); |
| 413 | if (ib == std::string::npos) { |
| 414 | G4cerr << aCommand << G4endl; |
| 415 | for (std::size_t i = 0; i < ia; ++i) { |
| 416 | G4cerr << " "; |
| 417 | } |
| 418 | G4cerr << "^" << G4endl; |
| 419 | G4cerr << "Unmatched alias parenthesis -- command ignored" << G4endl; |
| 420 | G4String nullStr; |
| 421 | return nullStr; |
| 422 | } |
| 423 | G4String ps = aCommand.substr(ia + 1, aCommand.length() - (ia + 1)); |
| 424 | std::size_t ic = ps.find('{'); |
| 425 | std::size_t id = ps.find('}'); |
| 426 | if (ic != std::string::npos && ic < id) { |
| 427 | ia += ic + 1; |
| 428 | } |
| 429 | else { |
| 430 | ibx = (G4int)ib; |
| 431 | } |
| 432 | } |
| 433 | //--- Here ia represents the position of innermost "{" |
| 434 | //--- and ibx represents corresponding "}" |
| 435 | G4String subs; |
| 436 | if (ia > 0) { |
| 437 | subs = aCommand.substr(0, ia); |
| 438 | } |
| 439 | G4String alis = aCommand.substr(ia + 1, ibx - ia - 1); |
| 440 | G4String rems = aCommand.substr(ibx + 1, aCommand.length() - ibx); |
| 441 | const G4String* alVal = aliasList->FindAlias(alis); |
| 442 | if (alVal == nullptr) { |
| 443 | G4cerr << "Alias <" << alis << "> not found -- command ignored" << G4endl; |
| 444 | G4String nullStr; |
| 445 | return nullStr; |
| 446 | } |
| 447 | aCommand = subs + (*alVal) + rems; |
| 448 | ia = aCommand.find('{'); |
| 449 | } |
| 450 | return aCommand; |
| 451 | } |
| 452 | |
| 453 | // -------------------------------------------------------------------- |
| 454 | G4int G4UImanager::ApplyCommand(const G4String& aCmd) |
no test coverage detected