Planet
navi homeaboutscreenshotsdownloaddevelopmentforum

ArgumentCompletionList

TracNav(TracNav/TOC_Development)?

Description

An ArgumentCompletionList is used to display possible arguments when trying to complete a ConsoleCommand in the CommandExecutor by calling complete(). ArgumentCompletionLists are returned by a function stored in a ArgumentCompleter.

An ArgumentCompletionList is in fact just a std::list with elements that return three strings:

  • getString(): The string that will be used to complete the command
  • getComparable(): A string in lowercase used to compare the possible arguments with the already typed argument fragment
  • getDisplay(): The string that should be displayed in the list (but this is just fake - the other two strings do the real work)

Usage

ArgumentCompletionList myList = function();
std::string fragment = "a";

for (ArgumentCompletionList::iterator it = myList.begin();
                                      it != myList.end(); ++it)
{
    if ((*it).getComparable() starts_with fragment)
    {
        std::cout << "Argument: " << (*it).getDisplay() << std::endl;
        return (*it).getString();
    }
}
Last modified 8 years ago Last modified on Oct 7, 2008, 2:51:06 PM