Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/ArgumentCompletionList


Ignore:
Timestamp:
Oct 7, 2008, 2:10:15 PM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/ArgumentCompletionList

    v1 v1  
     1= ArgumentCompletionList =
     2[[TracNav(TracNav/TOC_Development)]]
     3
     4== Description ==
     5An !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
     7An !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{{{
     15ArgumentCompletionList myList = function();
     16std::string fragment = "a";
     17
     18for (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}}}