Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7315 in orxonox.OLD


Ignore:
Timestamp:
Apr 17, 2006, 1:32:25 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: more std::string style in the Shell

Location:
trunk/src/lib/shell
Files:
4 edited

Legend:

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

    r7221 r7315  
    7474  this->bufferDisplaySize = 10;
    7575  this->bufferOffset = 0;
    76   this->bufferIterator = ShellBuffer::getInstance()->getBuffer()->begin();
     76  this->bufferIterator = ShellBuffer::getInstance()->getBuffer().begin();
    7777
    7878  // INPUT LINE
     
    130130  this->setRelCoorSoft2D(0, 0, 1, 5);
    131131
    132   list<char*>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer()->end();
     132  list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end();
    133133  bool top = false;
    134134  for (int i = 0; i < this->bufferDisplaySize; i++)
     
    138138    {
    139139      this->bufferText[i]->setText((*textLine));
    140     if (textLine != ShellBuffer::getInstance()->getBuffer()->begin())
     140    if (textLine != ShellBuffer::getInstance()->getBuffer().begin())
    141141      top = true;
    142142      textLine--;
     
    159159  this->setRelCoorSoft2D(0, -(int)this->shellHeight, 1, 5);
    160160
    161   list<char*>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer()->end();
     161  list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end();
    162162  for (int i = 0; i < this->bufferDisplaySize; i++)
    163163  {
    164164    this->bufferText[i]->setVisibility(false);
    165     if (textLine != ShellBuffer::getInstance()->getBuffer()->begin())
     165    if (textLine != ShellBuffer::getInstance()->getBuffer().begin())
    166166    {
    167167      this->bufferText[i]->setText((*textLine));
     
    306306  }
    307307
    308   list<char*>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer()->end();
     308  list<std::string>::const_iterator textLine = --ShellBuffer::getInstance()->getBuffer().end();
    309309  bufferText = new Text*[bufferDisplaySize];
    310310  for (unsigned int i = 0; i < bufferDisplaySize; i++)
     
    313313    bufferText[i]->setAlignment(TEXT_ALIGN_LEFT);
    314314    bufferText[i]->setParent2D(this);
    315     if(textLine != ShellBuffer::getInstance()->getBuffer()->begin())
     315    if(textLine != ShellBuffer::getInstance()->getBuffer().begin())
    316316    {
    317317      bufferText[i]->setText(*textLine);
     
    390390  if (this->bufferOffset == 0)
    391391   {
    392      this->bufferIterator = ShellBuffer::getInstance()->getBuffer()->end();
     392     this->bufferIterator = ShellBuffer::getInstance()->getBuffer().end();
    393393//     for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
    394394//       this->bufferIterator->prevStep();
     
    396396
    397397  // boundraries
    398   if (this->bufferOffset + lineCount > (int)ShellBuffer::getInstance()->getBuffer()->size())
    399     lineCount = (int)ShellBuffer::getInstance()->getBuffer()->size()- this->bufferOffset;
     398  if (this->bufferOffset + lineCount > (int)ShellBuffer::getInstance()->getBuffer().size())
     399    lineCount = (int)ShellBuffer::getInstance()->getBuffer().size()- this->bufferOffset;
    400400  else if (this->bufferOffset + lineCount < 0)
    401401    lineCount = -bufferOffset;
     
    418418  }
    419419  // redisplay the buffers
    420   list<char*>::const_iterator it = this->bufferIterator;
     420  list<std::string>::const_iterator it = this->bufferIterator;
    421421  for (unsigned int i = 0; i < this->bufferDisplaySize; i++)
    422422  {
  • trunk/src/lib/shell/shell.h

    r7221 r7315  
    104104    Text**                      bufferText;             //!< A list of stored bufferTexts for the display of the buffer.
    105105    int                         bufferOffset;           //!< how many lines from the bottom up we display the Buffer.
    106     std::list<char*>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
     106    std::list<std::string>::const_iterator  bufferIterator;         //!< used to move through and print the Buffer
    107107};
    108108
  • trunk/src/lib/shell/shell_buffer.cc

    r7314 r7315  
    9090void ShellBuffer::flush()
    9191{
    92   // delete all the Chars in the Buffers
    93   list<char*>::iterator bufferLine;
    94   for (bufferLine = this->buffer.begin(); bufferLine != this->buffer.end(); bufferLine++)
    95   {
    96     delete[] (*bufferLine);
    97   }
    9892  this->buffer.clear();
    9993}
     
    176170    }
    177171
    178     char* addLine = new char[strlen(newLineBegin)+1];
    179     strcpy(addLine, newLineBegin);
    180 
    181172    this->lineCount++;
    182     this->buffer.push_back(addLine);
     173    this->buffer.push_back(newLineBegin);
    183174    if (likely (this->shell != NULL) && unlikely (this->shell->isActive()))
    184       this->shell->printToDisplayBuffer(addLine);
     175      this->shell->printToDisplayBuffer(newLineBegin);
    185176
    186177    if (this->buffer.size() > this->bufferSize)
    187     {
    188       delete[] this->buffer.front();
    189178      this->buffer.pop_front();
    190     }
    191179
    192180    newLineBegin = newLineEnd+1;
     
    201189  PRINT(3)("Debugging output to console (not this shell)\n");
    202190
    203   list<char*>::const_iterator bufferLine;
     191  list<std::string>::const_iterator bufferLine;
    204192  for (bufferLine = this->buffer.begin(); bufferLine != this->buffer.end(); bufferLine++)
    205     printf(*bufferLine);
     193    printf((*bufferLine).c_str());
    206194}
  • trunk/src/lib/shell/shell_buffer.h

    r7314 r7315  
    4141  void addBufferLine(const char* line, va_list arg);
    4242  /** @returns the List of stings from the Buffer */
    43   const std::list<char*>* getBuffer() const { return &this->buffer; };
     43  const std::list<std::string>& getBuffer() const { return this->buffer; };
    4444 /** @returns the Count of lines processed by the Shell. */
    4545  inline long getLineCount() const { return this->lineCount; };
     
    5353    static ShellBuffer*      singletonRef;                       //!< The singleton-reference to the only memeber of this class.
    5454    unsigned int             bufferSize;                         //!< The Size of the buffer
    55     std::list<char*>         buffer;                             //!< A list of stored char-arrays(strings) to store the history
     55    std::list<std::string>   buffer;                             //!< A list of stored char-arrays(strings) to store the history
    5656
    5757    Shell*                   shell;                              //!< the Registered Shell.
Note: See TracChangeset for help on using the changeset viewer.