Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7320 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Apr 17, 2006, 1:12:25 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: more cleanup stuff, subString slowly gets where i want it

Location:
trunk/src/lib
Files:
3 edited

Legend:

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

    r7319 r7320  
    184184            {
    185185
    186               (*alias)->getCommand()->executor->execute(objectList->front(), executionString.substr(inputSplits.getOffset(1))); /// TODO CHECK IF OK
     186              (*alias)->getCommand()->executor->execute(objectList->front(), inputSplits.getSubSet(1).join()); /// TODO CHECK IF OK
    187187            }
    188188            else
     
    241241              return false;
    242242            if (inputSplits.size() > fktPos+1)
    243               (*cmdIT)->executor->execute(objectPointer, executionString.substr(inputSplits.getOffset(fktPos +1))); /// TODO CHECK IF OK
     243              (*cmdIT)->executor->execute(objectPointer, inputSplits.getSubSet(2).join()); /// TODO CHECK IF OK
    244244            else
    245245              (*cmdIT)->executor->execute(objectPointer, "");
  • trunk/src/lib/util/substring.cc

    r7319 r7320  
    4141  split[0] = splitter;
    4242  split[1] = '\0';
    43   SubString::splitLine(this->strings, this->offsets,
    44                        string, split);
     43  SubString::splitLine(this->strings, string, split);
    4544}
    4645
     
    5251SubString::SubString(const std::string& string, bool whiteSpaces)
    5352{
    54   SubString::splitLine(this->strings, this->offsets,
    55                        string);
     53  SubString::splitLine(this->strings, string);
    5654}
    5755
     
    6664SubString::SubString(const std::string& string, const std::string& splitters, char escapeChar,char safemode_char, char comment_char)
    6765{
    68   SubString::splitLine(this->strings, this->offsets,
    69                        string, splitters, escapeChar, safemode_char, comment_char);
     66  SubString::splitLine(this->strings, string, splitters, escapeChar, safemode_char, comment_char);
    7067}
    7168
     
    113110SubString& SubString::operator=(const SubString& subString)
    114111{
    115   this->offsets = subString.offsets;
    116112  this->strings = subString.strings;
    117113  return *this;
     
    160156unsigned int SubString::split(const std::string& string, char splitter)
    161157{
    162   this->offsets.clear();
    163158  this->strings.clear();
    164159  char split[2];
    165160  split[0] = splitter;
    166161  split[1] = '\0';
    167   SubString::splitLine(this->strings, this->offsets, string, split);
     162  SubString::splitLine(this->strings, string, split);
    168163  return strings.size();
    169164}
     
    178173unsigned int SubString::split(const std::string& string, bool whiteSpaces)
    179174{
    180   this->offsets.clear();
    181175  this->strings.clear();
    182   SubString::splitLine(this->strings, this->offsets, string);
     176  SubString::splitLine(this->strings, string);
    183177  return strings.size();
    184178}
     
    195189unsigned int SubString::split(const std::string& string, const std::string& splitters, char escapeChar,char safemode_char, char comment_char)
    196190{
    197   this->offsets.clear();
    198191  this->strings.clear();
    199   SubString::splitLine(this->strings, this->offsets,
    200                        string, splitters, escapeChar, safemode_char);
     192  SubString::splitLine(this->strings, string, splitters, escapeChar, safemode_char);
    201193  return strings.size();
    202194}
     
    248240{
    249241  return SubString(*this, subSetBegin, subSetEnd);
    250 }
    251 
    252 
    253 /**
    254  * @brief get a particular substring's offset
    255  * @param i the ID of the substring to get the offset from
    256  * @returns the offset or NULL if an invalid ID was given
    257  */
    258 unsigned int SubString::getOffset(unsigned int i) const
    259 {
    260   if( i < this->offsets.size() && i >= 0)
    261     return this->offsets[i];
    262   else
    263     return 0;
    264242}
    265243
     
    283261 *
    284262 */
    285 SPLIT_LINE_STATE SubString::splitLine(std::vector<std::string>& ret, std::vector<unsigned int>& offsets,
    286                                       const std::string& line, const std::string& delimiters,
    287                                       char escape_char, char safemode_char, char comment_char,
     263SPLIT_LINE_STATE SubString::splitLine(std::vector<std::string>& ret,
     264                                      const std::string& line,
     265                                      const std::string& delimiters,
     266                                      char escape_char,
     267                                      char safemode_char,
     268                                      char comment_char,
    288269                                      SPLIT_LINE_STATE start_state)
    289270{
     
    317298          {
    318299            ret.push_back(token);
    319             offsets.push_back(i);
    320300            token.clear();
    321301          }
     
    330310          {
    331311            ret.push_back(token);
    332             offsets.push_back(i);
    333312            token.clear();
    334313          }
     
    384363          {
    385364            ret.push_back(token);
    386             offsets.push_back(i);
    387365            token.clear();
    388366          }
     
    405383  {
    406384    ret.push_back(token);
    407     offsets.push_back(i);
    408385    token.clear();
    409386  }
  • trunk/src/lib/util/substring.h

    r7319 r7320  
    4848  unsigned int split(const std::string& string, bool whiteSpaces);
    4949  unsigned int split(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0');
    50   std::string join(const std::string& delimiter) const;
     50  std::string join(const std::string& delimiter = " ") const;
    5151  ////////////////////////////////////////
    5252
     
    5757  // retrieve Information from within
    5858  inline unsigned int size() const { return this->strings.size(); };
    59 const std::string& getString(unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; }
    60   ; // safety-precaution
     59  const std::string& getString(unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; };
    6160  const std::string& operator[](unsigned int i) const { return this->getString(i); };
    62   unsigned int getOffset(unsigned int i) const;
    6361
    6462  // the almighty algorithm.
    65   static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,std::vector<unsigned int>& offsets,
    66                                     const std::string& line, const std::string& delimiters = " \t\r\n",
    67                                     char escape_char = '\\', char safemode_char = '"', char comment_char = '\0',
     63  static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,
     64                                    const std::string& line,
     65                                    const std::string& delimiters = " \t\r\n",
     66                                    char escape_char = '\\',
     67                                    char safemode_char = '"',
     68                                    char comment_char = '\0',
    6869                                    SPLIT_LINE_STATE start_state = SL_NORMAL);
    6970  // debugging.
     
    7273private:
    7374  std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
    74   std::vector<unsigned int> offsets;                      //!< offsets of the beginning of the input-string to the beginning of each substring.
    7575
    7676  static const std::string emptyString;
Note: See TracChangeset for help on using the changeset viewer.