Might be an idea to add a new style of iterator selection, in which we actually store the completed words in the line and compare against them. This would permit something like
completer::addIteratorSelector(0,"view",&fileIterator);
to make the word "view" in position 0 (first word) select a file iterator. Who would ever use anything other than 0 there? Another approach might be to specify a selector callback which receives an array of words completed so far and returns an iterator pointer or null:
completer::Iterator *mySelector(int argc,char *argv[]){
if(!strcmp(argv[0],"view") ||
!strcmp(argv[0],"delete"))
return &fileIterator;
else
return NULL; // default
}
...
completer::setIteratorSelector(mySelector);