Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7398 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Apr 27, 2006, 4:23:55 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: SubString more functionality

Location:
trunk/src/lib
Files:
4 edited

Legend:

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

    r7397 r7398  
    4141    PRINTF(5)("create shellcommand %s %s\n", commandName, className);
    4242    this->setName(commandName);
     43
     44    // copy the executor:
    4345    this->executor = executor.clone();
    4446    this->executor->setName(commandName);
     47
    4548    this->alias = NULL;
    4649
    4750    //  this->classID = classID;
    4851    this->shellClass = ShellCommandClass::getCommandClass(className);
    49     if (this->shellClass != NULL)
    50       this->shellClass->commandList.push_back(this);
     52    assert (this->shellClass != NULL);
     53    this->shellClass->commandList.push_back(this);
    5154  }
    5255
     
    6265
    6366  /**
    64    * registers a new ShellCommand
     67   * @brief registers a new ShellCommand
    6568   */
    6669  ShellCommand* ShellCommand::registerCommand(const std::string& commandName, const std::string& className, const Executor& executor)
     
    7477
    7578  /**
    76    * unregister an existing commandName
     79   * @brief unregister an existing commandName
    7780   * @param className the name of the Class the command belongs to.
    7881   * @param commandName the name of the command itself
  • trunk/src/lib/shell/shell_command.h

    r7397 r7398  
    2323
    2424  /**
    25    * an easy to use Macro to create a Command
     25   * @brief an easy to use Macro to create a Command
    2626   * @param command the name of the command (without "" around the string)
    2727   * @param class the name of the class to apply this command to (without the "" around the string)
     
    4141
    4242  /**
    43    * an easy to use Macro to create a Command
     43   * @brief an easy to use Macro to create a Command
    4444   * @param command the name of the command (without "" around the string)
    4545   * @param class the name of the class to apply this command to (without the "" around the string)
  • trunk/src/lib/util/substring.cc

    r7325 r7398  
    3636 */
    3737SubString::SubString()
    38 {
    39 }
     38{}
    4039
    4140
     
    122121 * @returns true if the Stored Strings match
    123122 */
    124 bool SubString::operator==(const SubString& subString)
     123bool SubString::operator==(const SubString& subString) const
    125124{
    126125  return (this->strings == subString.strings);
     126}
     127
     128/**
     129 * @brief comparator.
     130 * @param subString the SubString to compare against this one.
     131 * @returns true if the Stored Strings match
     132 */
     133bool SubString::compare(const SubString& subString) const
     134{
     135  return (*this == subString);
     136}
     137
     138/**
     139 * @brief comparator.
     140 * @param subString the SubString to compare against this one.
     141 * @returns true if the Stored Strings match
     142 */
     143bool SubString::compare(const SubString& subString, unsigned int length) const
     144{
     145  if (length > this->size() || length > subString.size())
     146    return false;
     147
     148  for (unsigned int i = 0; i < length; i++)
     149    if (this->strings[i] != subString.strings[i])
     150      return false;
     151  return true;
    127152}
    128153
     
    272297    switch(state)
    273298    {
    274       case SL_NORMAL:
     299        case SL_NORMAL:
    275300        if(line[i] == escape_char)
    276301        {
     
    307332        }
    308333        break;
    309       case SL_ESCAPE:
     334        case SL_ESCAPE:
    310335        if(line[i] == 'n') token += '\n';
    311336        else if(line[i] == 't') token += '\t';
     
    319344        state = SL_NORMAL;
    320345        break;
    321       case SL_SAFEMODE:
     346        case SL_SAFEMODE:
    322347        if(line[i] == safemode_char)
    323348        {
     
    333358        }
    334359        break;
    335       case SL_SAFEESCAPE:
     360        case SL_SAFEESCAPE:
    336361        if(line[i] == 'n') token += '\n';
    337362        else if(line[i] == 't') token += '\t';
     
    345370        state = SL_SAFEMODE;
    346371        break;
    347       case SL_COMMENT:
     372        case SL_COMMENT:
    348373        if(line[i] == '\n')
    349374        {
     
    361386        }
    362387        break;
    363       default:
     388        default:
    364389        // nothing
    365390        break;
  • trunk/src/lib/util/substring.h

    r7340 r7398  
    3737  // operate on the SubString
    3838  SubString& operator=(const SubString& subString);
    39   bool operator==(const SubString& subString);
     39  bool operator==(const SubString& subString) const;
     40  bool compare(const SubString& subString) const;
     41  bool compare(const SubString& subString, unsigned int length) const;
    4042  SubString operator+(const SubString& subString) const;
    4143  SubString& operator+=(const SubString& subString);
Note: See TracChangeset for help on using the changeset viewer.