Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5103 in orxonox.OLD for trunk/src/util/shell.cc


Ignore:
Timestamp:
Aug 22, 2005, 6:08:15 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: better algorithm to find the ClassName.
Now this is done via the ClassList

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/shell.cc

    r5102 r5103  
    2424
    2525#include "load_param.h"
     26#include "class_list.h"
    2627#include "debug.h"
    2728#include <stdarg.h>
     
    5960  this->inputLineText->setParent2D(this);
    6061
     62  this->completionList = NULL;
    6163
    6264  EventHandler* evh = EventHandler::getInstance();
     
    9193  }
    9294  delete charIterator;
     95
     96//  if (this->completionList != NULL)
     97    //delete this->completionList;
    9398
    9499  Shell::singletonRef = NULL;
     
    465470  this->classComplete(commandBegin);
    466471
    467    delete[] completionLine;
     472  delete[] completionLine;
    468473}
    469474
     
    477482  if (unlikely(classBegin == NULL))
    478483    return false;
    479   tList<const char>* classList = LoadClassDescription::searchClassWithShort(classBegin);
     484  const tList<const char>* classList = this->searchClassWithShort(classBegin);
    480485  if (classList->getSize() == 0)
    481486  {
    482     delete classList;
    483487     //PRINTF(0)("no completion found for %s\n", commandBegin);
    484488    return false;
     
    519523    delete[] adder;
    520524  }
    521   delete classList;
    522525}
    523526
     
    529532bool Shell::functionComplete(const char* functionBegin)
    530533{
     534}
     535
     536
     537/**
     538 * searches for classes, which beginn with classNameBegin
     539 * @param classNameBegin the beginning string of a Class
     540 * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards,
     541 * !! The strings MUST NOT be deleted !!
     542 */
     543const tList<const char>* Shell::searchClassWithShort(const char* classNameBegin)
     544{
     545  unsigned int searchLength = strlen(classNameBegin);
     546  if (this->completionList != NULL)
     547    delete this->completionList;
     548  this->completionList = new tList<const char>;
     549
     550//  tList<const char>* classList = ClassList::getClassList();
     551
     552  tIterator<const char>* iterator = ClassList::getClassList()->getIterator();
     553  const char* enumString = iterator->nextElement();
     554  while (enumString != NULL)
     555  {
     556    if (strlen(enumString)>searchLength+1 &&
     557        !strncasecmp(enumString, classNameBegin, searchLength))
     558    {
     559      this->completionList->add(enumString);
     560    }
     561    enumString = iterator->nextElement();
     562  }
     563  delete iterator;
     564
     565  return this->completionList;
    531566}
    532567
     
    540575  if (this->pressedKey != SDLK_FIRST)
    541576    printf("%s::%f %f\n", SDLKToKeyname(this->pressedKey), this->delayed, this->repeatDelay);
    542 
    543 }
     577}
Note: See TracChangeset for help on using the changeset viewer.