| | 1 | = ArgumentCompletionList = |
| | 2 | [[TracNav(TracNav/TOC_Development)]] |
| | 3 | |
| | 4 | == Description == |
| | 5 | An !ArgumentCompletionList is used to display possible arguments when trying to complete a [wiki:ConsoleCommand] in the [wiki:CommandExecutor] by calling '''complete()'''. !ArgumentCompletionLists are returned by a [wiki:http://www.orxonox.net/wiki/ArgumentCompletionFunctions function] stored in a [wiki:ArgumentCompleter]. |
| | 6 | |
| | 7 | An !ArgumentCompletionList is in fact just a std::list with elements that return three strings: |
| | 8 | * '''getString()''': The string that will be used to complete the command |
| | 9 | * '''getComparable()''': A string in lowercase used to compare the possible arguments with the already typed argument fragment |
| | 10 | * '''getDisplay()''': The string that should be displayed in the list (but this is just fake - the other two strings do the real work) |
| | 11 | |
| | 12 | |
| | 13 | == Usage == |
| | 14 | {{{ |
| | 15 | ArgumentCompletionList myList = function(); |
| | 16 | std::string fragment = "a"; |
| | 17 | |
| | 18 | for (ArgumentCompletionList::iterator it = myList.begin(); |
| | 19 | it != myList.end(); ++it) |
| | 20 | { |
| | 21 | if ((*it).getComparable() starts_with fragment) |
| | 22 | { |
| | 23 | std::cout << "Argument: " << (*it).getDisplay() << std::endl; |
| | 24 | return (*it).getString(); |
| | 25 | } |
| | 26 | } |
| | 27 | }}} |