- Timestamp:
- May 27, 2008, 6:29:08 PM (17 years ago)
- Location:
- code/branches/console/src/core
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/ArgumentCompleter.h
r1436 r1441 30 30 #define _ArgumentCompleter_H__ 31 31 32 #include <list>33 #include <string>34 35 32 #include "CorePrereqs.h" 33 #include "ArgumentCompletionListElement.h" 36 34 37 35 namespace orxonox … … 40 38 { 41 39 public: 42 ArgumentCompleter( std::list<std::pair<std::string, std::string> >(*function) (void)) : paramCount_(0), function_0_(function) {}43 ArgumentCompleter( std::list<std::pair<std::string, std::string> >(*function) (const std::string& param1)) : paramCount_(1), function_1_(function) {}44 ArgumentCompleter( std::list<std::pair<std::string, std::string> >(*function) (const std::string& param1, const std::string& param2)) : paramCount_(2), function_2_(function) {}45 ArgumentCompleter( std::list<std::pair<std::string, std::string> >(*function) (const std::string& param1, const std::string& param2, const std::string& param3)) : paramCount_(3), function_3_(function) {}46 ArgumentCompleter( std::list<std::pair<std::string, std::string> >(*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4)) : paramCount_(4), function_4_(function) {}47 ArgumentCompleter( std::list<std::pair<std::string, std::string> >(*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5)) : paramCount_(5), function_5_(function) {}40 ArgumentCompleter(ArgumentCompletionList (*function) (void)) : paramCount_(0), function_0_(function) {} 41 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1)) : paramCount_(1), function_1_(function) {} 42 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2)) : paramCount_(2), function_2_(function) {} 43 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3)) : paramCount_(3), function_3_(function) {} 44 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4)) : paramCount_(4), function_4_(function) {} 45 ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5)) : paramCount_(5), function_5_(function) {} 48 46 49 std::list<std::pair<std::string, std::string> >operator()(const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "")47 ArgumentCompletionList operator()(const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "") 50 48 { 51 49 switch (this->paramCount_) … … 64 62 return (*this->function_5_)(param1, param2, param3, param4, param5); 65 63 default: 66 return std::list<std::pair<std::string, std::string> >();64 return ArgumentCompletionList(); 67 65 } 68 66 } … … 70 68 private: 71 69 unsigned char paramCount_; 72 std::list<std::pair<std::string, std::string> >(*function_0_) (void);73 std::list<std::pair<std::string, std::string> >(*function_1_) (const std::string& param1);74 std::list<std::pair<std::string, std::string> >(*function_2_) (const std::string& param1, const std::string& param2);75 std::list<std::pair<std::string, std::string> >(*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3);76 std::list<std::pair<std::string, std::string> >(*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4);77 std::list<std::pair<std::string, std::string> >(*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5);70 ArgumentCompletionList (*function_0_) (void); 71 ArgumentCompletionList (*function_1_) (const std::string& param1); 72 ArgumentCompletionList (*function_2_) (const std::string& param1, const std::string& param2); 73 ArgumentCompletionList (*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3); 74 ArgumentCompletionList (*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4); 75 ArgumentCompletionList (*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5); 78 76 }; 79 77 } -
code/branches/console/src/core/ArgumentCompletionFunctions.cc
r1439 r1441 30 30 #include <map> 31 31 32 //#include <stdio.h>33 //#include <stdlib.h>34 //#include <errno.h>35 //#include <sys/types.h>36 //#include <sys/stat.h>37 32 #include <dirent.h> 38 33 … … 42 37 #include "ConfigValueContainer.h" 43 38 #include "TclThreadManager.h" 39 #include "util/Convert.h" 44 40 #include "util/String.h" 45 41 #include "util/SubString.h" … … 51 47 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(fallback)() 52 48 { 53 return std::list<std::pair<std::string, std::string> >();49 return ArgumentCompletionList(); 54 50 } 55 51 56 52 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(files)(const std::string& fragment) 57 53 { 58 std::list<std::pair<std::string, std::string> >dirlist;59 std::list<std::pair<std::string, std::string> >filelist;54 ArgumentCompletionList dirlist; 55 ArgumentCompletionList filelist; 60 56 61 57 SubString tokens(fragment, "/", "", false, '\0', false, '\0', false, '\0', '\0', false, '\0'); … … 86 82 87 83 if (S_ISREG(fileInfo.st_mode)) // normal file 88 filelist.push_back( std::pair<std::string, std::string>(getLowercase(path), path));84 filelist.push_back(ArgumentCompletionListElement(path, getLowercase(path), currentFile->d_name)); 89 85 else if (S_ISDIR(fileInfo.st_mode)) // directory 90 dirlist.push_back( std::pair<std::string, std::string>(getLowercase(path) + "/", path+ "/"));86 dirlist.push_back(ArgumentCompletionListElement(path + "/", getLowercase(path) + "/", std::string(currentFile->d_name) + "/")); 91 87 else // special file 92 filelist.push_back( std::pair<std::string, std::string>(getLowercase(path), path));88 filelist.push_back(ArgumentCompletionListElement(path, getLowercase(path), currentFile->d_name)); 93 89 } 94 90 } … … 103 99 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalueclasses)() 104 100 { 105 std::list<std::pair<std::string, std::string> >classlist;101 ArgumentCompletionList classlist; 106 102 107 103 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it) 108 104 if ((*it).second->hasConfigValues()) 109 classlist.push_back( std::pair<std::string, std::string>(getLowercase((*it).first), (*it).second->getName()));105 classlist.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first))); 110 106 111 107 return classlist; … … 114 110 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& fragment, const std::string& classname) 115 111 { 116 std::list<std::pair<std::string, std::string> >configvalues;112 ArgumentCompletionList configvalues; 117 113 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getIdentifierMap().find(classname); 118 114 … … 120 116 { 121 117 for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it) 122 configvalues.push_back( std::pair<std::string, std::string>(getLowercase((*it).first), (*it).second->getName()));118 configvalues.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first))); 123 119 } 124 120 … … 128 124 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname) 129 125 { 130 std::list<std::pair<std::string, std::string> >oldvalue;126 ArgumentCompletionList oldvalue; 131 127 std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname)); 132 128 if (identifier != Identifier::getLowercaseIdentifierMapEnd()) … … 136 132 { 137 133 std::string valuestring = (*variable).second->toString(); 138 oldvalue.push_back( std::pair<std::string, std::string>(valuestring,valuestring));134 oldvalue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring)); 139 135 } 140 136 } … … 144 140 ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(tclthreads)() 145 141 { 146 return TclThreadManager::getInstance().getThreadList(); 142 std::list<unsigned int> threadnumbers = TclThreadManager::getInstance().getThreadList(); 143 ArgumentCompletionList threads; 144 145 for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it) 146 threads.push_back(ArgumentCompletionListElement(getConvertedValue<unsigned int, std::string>(*it))); 147 148 return threads; 147 149 } 148 150 } -
code/branches/console/src/core/ArgumentCompletionFunctions.h
r1436 r1441 30 30 #define _ArgumentCompletionFunctions_H__ 31 31 32 #include <list> 33 #include <string> 34 32 #include "CorePrereqs.h" 35 33 #include "ArgumentCompleter.h" 36 #include "CorePrereqs.h"37 34 38 35 39 36 #define ARGUMENT_COMPLETION_FUNCTION_DECLARATION(functionname) \ 40 37 ArgumentCompleter* functionname(); \ 41 _CoreExport std::list<std::pair<std::string, std::string> >acf_##functionname38 _CoreExport ArgumentCompletionList acf_##functionname 42 39 43 40 #define ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(functionname) \ … … 48 45 } \ 49 46 \ 50 std::list<std::pair<std::string, std::string> >acf_##functionname47 ArgumentCompletionList acf_##functionname 51 48 52 49 -
code/branches/console/src/core/CommandEvaluation.cc
r1435 r1441 271 271 } 272 272 273 std::string CommandEvaluation::dump(const std::list<std::pair<std::string, std::string> >& list)273 std::string CommandEvaluation::dump(const ArgumentCompletionList& list) 274 274 { 275 275 std::string output = ""; 276 for ( std::list<std::pair<std::string, std::string> >::const_iterator it = list.begin(); it != list.end(); ++it)276 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 277 277 { 278 278 if (it != list.begin()) 279 279 output += " "; 280 280 281 output += (*it). second;281 output += (*it).getDisplay(); 282 282 } 283 283 return output; -
code/branches/console/src/core/CommandEvaluation.h
r1434 r1441 35 35 #include <list> 36 36 37 #include "ArgumentCompletionListElement.h" 37 38 #include "util/SubString.h" 38 39 #include "util/MultiTypeMath.h" … … 82 83 unsigned int getStartindex() const; 83 84 static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list); 84 static std::string dump(const std::list<std::pair<std::string, std::string> >& list);85 static std::string dump(const ArgumentCompletionList& list); 85 86 static std::string dump(const ConsoleCommand* command); 86 87 … … 96 97 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_; 97 98 std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_; 98 std::list<std::pair<std::string, std::string> >listOfPossibleArguments_;99 ArgumentCompletionList listOfPossibleArguments_; 99 100 100 101 Identifier* functionclass_; -
code/branches/console/src/core/CommandExecutor.cc
r1437 r1441 371 371 { 372 372 // There is exactly one possible argument 373 CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()). second;374 CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()). second;373 CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString(); 374 CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString(); 375 375 CommandExecutor::getEvaluation().state_ = CS_ParamPreparation; 376 376 return; … … 457 457 if ((*it).first.find(lowercase) == 0 || fragment == "") 458 458 CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName())); 459 460 CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.sort(CommandExecutor::compareStringsInList);461 459 } 462 460 … … 477 475 CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName())); 478 476 } 479 480 CommandExecutor::getEvaluation().listOfPossibleFunctions_.sort(CommandExecutor::compareStringsInList);481 477 } 482 478 … … 487 483 CommandExecutor::getEvaluation().listOfPossibleArguments_.clear(); 488 484 std::string lowercase = getLowercase(fragment); 489 for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it) 490 if ((*it).first.find(lowercase) == 0 || fragment == "") 491 CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(std::pair<std::string, std::string>((*it).first, (*it).second)); 492 493 CommandExecutor::getEvaluation().listOfPossibleArguments_.sort(CommandExecutor::compareStringsInList2); 485 for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it) 486 { 487 if ((*it).lowercaseComparison()) 488 { 489 if ((*it).getComparable().find(lowercase) == 0 || fragment == "") 490 CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it); 491 } 492 else 493 { 494 if ((*it).getComparable().find(fragment) == 0 || fragment == "") 495 CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it); 496 } 497 } 494 498 } 495 499 … … 527 531 528 532 std::string lowercase = getLowercase(name); 529 for (std::list<std::pair<std::string, std::string> >::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it) 530 { 531 if ((*it).first == lowercase) 532 return (*it).second; 533 for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it) 534 { 535 if ((*it).lowercaseComparison()) 536 { 537 if ((*it).getComparable() == lowercase) 538 return (*it).getString(); 539 } 540 else 541 { 542 if ((*it).getComparable() == name) 543 return (*it).getString(); 544 } 533 545 } 534 546 … … 595 607 } 596 608 597 std::string CommandExecutor::getCommonBegin(const std::list<std::pair<std::string, std::string> >& list)609 std::string CommandExecutor::getCommonBegin(const ArgumentCompletionList& list) 598 610 { 599 611 if (list.size() == 0) … … 603 615 else if (list.size() == 1) 604 616 { 605 return ((*list.begin()). first+ " ");617 return ((*list.begin()).getComparable() + " "); 606 618 } 607 619 else … … 611 623 { 612 624 char temp = 0; 613 for (std::list<std::pair<std::string, std::string> >::const_iterator it = list.begin(); it != list.end(); ++it) 614 { 615 if ((*it).first.size() > i) 625 for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it) 626 { 627 std::string argument = (*it).getComparable(); 628 if (argument.size() > i) 616 629 { 617 630 if (it == list.begin()) 618 631 { 619 temp = (*it).first[i];632 temp = argument[i]; 620 633 } 621 634 else 622 635 { 623 if (temp != (*it).first[i])636 if (temp != argument[i]) 624 637 return output; 625 638 } … … 635 648 } 636 649 } 637 638 bool CommandExecutor::compareStringsInList(const std::pair<const std::string*, const std::string*>& first, const std::pair<const std::string*, const std::string*>& second)639 {640 return ((*first.first) < (*second.first));641 }642 643 bool CommandExecutor::compareStringsInList2(const std::pair<std::string, std::string>& first, const std::pair<std::string, std::string>& second)644 {645 return (first.first < second.first);646 }647 650 } -
code/branches/console/src/core/CommandExecutor.h
r1434 r1441 35 35 36 36 #include "CommandEvaluation.h" 37 38 #define COMMAND_EXECUTOR_CURSOR "$"39 37 40 38 namespace orxonox … … 95 93 static void createArgumentCompletionList(ConsoleCommand* command, unsigned int param); 96 94 static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list); 97 static std::string getCommonBegin(const std::list<std::pair<std::string, std::string> >& list); 98 static bool compareStringsInList(const std::pair<const std::string*, const std::string*>& first, const std::pair<const std::string*, const std::string*>& second); 99 static bool compareStringsInList2(const std::pair<std::string, std::string>& first, const std::pair<std::string, std::string>& second); 100 95 static std::string getCommonBegin(const ArgumentCompletionList& list); 101 96 102 97 CommandEvaluation evaluation_; -
code/branches/console/src/core/ConsoleCommand.h
r1434 r1441 34 34 #include "Executor.h" 35 35 #include "ClassManager.h" 36 #include "Identifier.h"37 36 #include "CommandExecutor.h" 38 37 #include "ArgumentCompletionFunctions.h" … … 104 103 105 104 void createArgumentCompletionList(unsigned int param, const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = ""); 106 const std::list<std::pair<std::string, std::string> >& getArgumentCompletionList() const105 const ArgumentCompletionList& getArgumentCompletionList() const 107 106 { return this->argumentList_; } 108 std::list<std::pair<std::string, std::string> >::const_iterator getArgumentCompletionListBegin() const107 ArgumentCompletionList::const_iterator getArgumentCompletionListBegin() const 109 108 { return this->argumentList_.begin(); } 110 std::list<std::pair<std::string, std::string> >::const_iterator getArgumentCompletionListEnd() const109 ArgumentCompletionList::const_iterator getArgumentCompletionListEnd() const 111 110 { return this->argumentList_.end(); } 112 111 … … 114 113 AccessLevel::Level accessLevel_; 115 114 ArgumentCompleter* argumentCompleter_[5]; 116 std::list<std::pair<std::string, std::string> >argumentList_;115 ArgumentCompletionList argumentList_; 117 116 }; 118 117 -
code/branches/console/src/core/CorePrereqs.h
r1430 r1441 78 78 79 79 class ArgumentCompleter; 80 class ArgumentCompletionListElement; 80 81 class BaseFactory; 81 82 class BaseMetaObjectListElement; -
code/branches/console/src/core/TclThreadManager.cc
r1434 r1441 632 632 } 633 633 634 std::list< std::pair<std::string, std::string>> TclThreadManager::getThreadList() const634 std::list<unsigned int> TclThreadManager::getThreadList() const 635 635 { 636 636 boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_); 637 std::list< std::pair<std::string, std::string>> threads;637 std::list<unsigned int> threads; 638 638 for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it) 639 { 640 std::string number = getConvertedValue<unsigned int, std::string>((*it).first); 641 threads.push_back(std::pair<std::string, std::string>(number, number)); 642 } 639 threads.push_back((*it).first); 643 640 return threads; 644 641 } -
code/branches/console/src/core/TclThreadManager.h
r1434 r1441 109 109 virtual void tick(float dt); 110 110 111 std::list< std::pair<std::string, std::string>> getThreadList() const;111 std::list<unsigned int> getThreadList() const; 112 112 113 113 private:
Note: See TracChangeset
for help on using the changeset viewer.