- Timestamp:
- Dec 25, 2009, 1:18:03 PM (15 years ago)
- Location:
- code/branches/pickup2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup2
- Property svn:mergeinfo changed
-
code/branches/pickup2/src/libraries/core/CommandExecutor.cc
r5929 r6412 59 59 if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end()) 60 60 { 61 COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << "."<< std::endl;61 COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << '.' << std::endl; 62 62 } 63 63 … … 82 82 std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name); 83 83 if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end()) 84 return (*it).second;84 return it->second; 85 85 else 86 86 return 0; … … 96 96 std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name); 97 97 if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end()) 98 return (*it).second;98 return it->second; 99 99 else 100 100 return 0; … … 215 215 CommandExecutor::getEvaluation().state_ = CommandState::Error; 216 216 AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname"); 217 CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".";217 CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + ' ' + GetLocalisation("commandexecutorunknownfirstargument") + '.'; 218 218 return; 219 219 } … … 231 231 { 232 232 // It's a shortcut 233 std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;233 const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first; 234 234 CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname); 235 235 if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(0))) … … 243 243 if (CommandExecutor::getEvaluation().function_->getParamCount() > 0) 244 244 { 245 CommandExecutor::getEvaluation().command_ += " ";245 CommandExecutor::getEvaluation().command_ += ' '; 246 246 CommandExecutor::getEvaluation().bCommandChanged_ = true; 247 247 } … … 251 251 { 252 252 // It's a classname 253 std::string classname = *(*CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()).first;253 const std::string& classname = *CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()->first; 254 254 CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(classname); 255 255 if (getLowercase(classname) != getLowercase(CommandExecutor::getArgument(0))) … … 260 260 CommandExecutor::getEvaluation().state_ = CommandState::Function; 261 261 CommandExecutor::getEvaluation().function_ = 0; 262 CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " ";262 CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' '; 263 263 // Move on to next case 264 264 } … … 268 268 CommandExecutor::getEvaluation().state_ = CommandState::Error; 269 269 AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with"); 270 CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + " " + CommandExecutor::getArgument(0) + ".";270 CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + ' ' + CommandExecutor::getArgument(0) + '.'; 271 271 return; 272 272 } … … 319 319 { 320 320 // It's a function 321 std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;321 const std::string& functionname = *CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()->first; 322 322 CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname, CommandExecutor::getEvaluation().functionclass_); 323 323 if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(1))) … … 327 327 } 328 328 CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation; 329 CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " "+ CommandExecutor::getEvaluation().function_->getName();329 CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getEvaluation().function_->getName(); 330 330 if (CommandExecutor::getEvaluation().function_->getParamCount() > 0) 331 331 { 332 CommandExecutor::getEvaluation().command_ += " ";332 CommandExecutor::getEvaluation().command_ += ' '; 333 333 CommandExecutor::getEvaluation().bCommandChanged_ = true; 334 334 } … … 340 340 CommandExecutor::getEvaluation().state_ = CommandState::Error; 341 341 AddLanguageEntry("commandexecutorunknownsecondargumentstart", "has no function starting with"); 342 CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + " " + GetLocalisation("commandexecutorunknownsecondargumentstart") + " " + CommandExecutor::getArgument(1) + ".";342 CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + GetLocalisation("commandexecutorunknownsecondargumentstart") + ' ' + CommandExecutor::getArgument(1) + '.'; 343 343 return; 344 344 } … … 346 346 { 347 347 // There are several possibilities 348 CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " "+ CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);348 CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + ' ' + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_); 349 349 CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_); 350 350 CommandExecutor::getEvaluation().bCommandChanged_ = true; … … 386 386 { 387 387 // There is exactly one possible argument 388 CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();389 CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();388 CommandExecutor::getEvaluation().argument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString(); 389 CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()->getString(); 390 390 CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation; 391 391 return; … … 451 451 } 452 452 453 std::stringCommandExecutor::getArgument(unsigned int index)453 const std::string& CommandExecutor::getArgument(unsigned int index) 454 454 { 455 455 if (index < (CommandExecutor::getEvaluation().commandTokens_.size())) 456 456 return CommandExecutor::getEvaluation().commandTokens_[index]; 457 457 else 458 return "";459 } 460 461 std::stringCommandExecutor::getLastArgument()458 return BLANKSTRING; 459 } 460 461 const std::string& CommandExecutor::getLastArgument() 462 462 { 463 463 return CommandExecutor::getArgument(CommandExecutor::argumentsGiven() - 1); … … 467 467 { 468 468 CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear(); 469 std::stringlowercase = getLowercase(fragment);469 const std::string& lowercase = getLowercase(fragment); 470 470 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapBegin(); it != Identifier::getLowercaseStringIdentifierMapEnd(); ++it) 471 if ( (*it).second->hasConsoleCommands())472 if ( (*it).first.find(lowercase) == 0 || fragment == "")473 CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(& (*it).first, &(*it).second->getName()));471 if (it->second->hasConsoleCommands()) 472 if (it->first.find(lowercase) == 0 || fragment.empty()) 473 CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName())); 474 474 } 475 475 … … 477 477 { 478 478 CommandExecutor::getEvaluation().listOfPossibleFunctions_.clear(); 479 std::stringlowercase = getLowercase(fragment);479 const std::string& lowercase = getLowercase(fragment); 480 480 if (!identifier) 481 481 { 482 482 for (std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it) 483 if ( (*it).first.find(lowercase) == 0 || fragment == "")484 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(& (*it).first, &(*it).second->getName()));483 if (it->first.find(lowercase) == 0 || fragment.empty()) 484 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName())); 485 485 } 486 486 else 487 487 { 488 488 for (std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it) 489 if ( (*it).first.find(lowercase) == 0 || fragment == "")490 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(& (*it).first, &(*it).second->getName()));489 if (it->first.find(lowercase) == 0 || fragment.empty()) 490 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&it->first, &it->second->getName())); 491 491 } 492 492 } … … 497 497 498 498 CommandExecutor::getEvaluation().listOfPossibleArguments_.clear(); 499 std::stringlowercase = getLowercase(fragment);499 const std::string& lowercase = getLowercase(fragment); 500 500 for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it) 501 501 { 502 if ( (*it).lowercaseComparison())503 { 504 if ( (*it).getComparable().find(lowercase) == 0 || fragment == "")502 if (it->lowercaseComparison()) 503 { 504 if (it->getComparable().find(lowercase) == 0 || fragment.empty()) 505 505 CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it); 506 506 } 507 507 else 508 508 { 509 if ( (*it).getComparable().find(fragment) == 0 || fragment == "")509 if (it->getComparable().find(fragment) == 0 || fragment.empty()) 510 510 CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it); 511 511 } … … 515 515 Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name) 516 516 { 517 std::stringlowercase = getLowercase(name);517 const std::string& lowercase = getLowercase(name); 518 518 std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase); 519 if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && (*it).second->hasConsoleCommands())520 return (*it).second;519 if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && it->second->hasConsoleCommands()) 520 return it->second; 521 521 522 522 return 0; … … 525 525 ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier) 526 526 { 527 std::stringlowercase = getLowercase(name);527 const std::string& lowercase = getLowercase(name); 528 528 if (!identifier) 529 529 { 530 530 std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase); 531 531 if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd()) 532 return (*it).second;532 return it->second; 533 533 } 534 534 else … … 536 536 std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase); 537 537 if (it != identifier->getLowercaseConsoleCommandMapEnd()) 538 return (*it).second;538 return it->second; 539 539 } 540 540 return 0; 541 541 } 542 542 543 std::stringCommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)543 const std::string& CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param) 544 544 { 545 545 CommandExecutor::createArgumentCompletionList(command, param); 546 546 547 std::stringlowercase = getLowercase(name);547 const std::string& lowercase = getLowercase(name); 548 548 for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it) 549 549 { 550 if ( (*it).lowercaseComparison())551 { 552 if ( (*it).getComparable() == lowercase)553 return (*it).getString();550 if (it->lowercaseComparison()) 551 { 552 if (it->getComparable() == lowercase) 553 return it->getString(); 554 554 } 555 555 else 556 556 { 557 if ( (*it).getComparable() == name)558 return (*it).getString();559 } 560 } 561 562 return "";557 if (it->getComparable() == name) 558 return it->getString(); 559 } 560 } 561 562 return BLANKSTRING; 563 563 } 564 564 … … 589 589 else if (list.size() == 1) 590 590 { 591 return ((* (*list.begin()).first) + " ");592 } 593 else 594 { 595 std::string output = "";591 return ((*list.begin()->first) + ' '); 592 } 593 else 594 { 595 std::string output; 596 596 for (unsigned int i = 0; true; i++) 597 597 { … … 599 599 for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it) 600 600 { 601 if ( (*(*it).first).size() > i)601 if (it->first->size() > i) 602 602 { 603 603 if (it == list.begin()) 604 604 { 605 temp = (* (*it).first)[i];605 temp = (*it->first)[i]; 606 606 } 607 607 else 608 608 { 609 if (temp != (* (*it).first)[i])609 if (temp != (*it->first)[i]) 610 610 return output; 611 611 } … … 630 630 else if (list.size() == 1) 631 631 { 632 return ( (*list.begin()).getComparable() + " ");633 } 634 else 635 { 636 std::string output = "";632 return (list.begin()->getComparable() + ' '); 633 } 634 else 635 { 636 std::string output; 637 637 for (unsigned int i = 0; true; i++) 638 638 { 639 char tempComparable = 0; 639 640 char temp = 0; 640 641 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 641 642 { 642 std::string argument = (*it).getComparable(); 643 const std::string& argumentComparable = it->getComparable(); 644 const std::string& argument = it->getString(); 643 645 if (argument.size() > i) 644 646 { 645 647 if (it == list.begin()) 646 648 { 649 tempComparable = argumentComparable[i]; 647 650 temp = argument[i]; 648 651 } 649 652 else 650 653 { 651 if (temp != argument[i])654 if (tempComparable != argumentComparable[i]) 652 655 return output; 656 else if (temp != argument[i]) 657 temp = tempComparable; 653 658 } 654 659 }
Note: See TracChangeset
for help on using the changeset viewer.