Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7325 in orxonox.OLD for trunk/src/lib/util


Ignore:
Timestamp:
Apr 17, 2006, 2:17:21 PM (19 years ago)
Author:
bensch
Message:

helpers

Location:
trunk/src/lib/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/substring.cc

    r7323 r7325  
    5353}
    5454
    55 /**
    56  * @brief Splits a String into a SubString removing all whiteSpaces
    57  * @param string the String to Split
    58  * @param whiteSpaces MUST BE __TRUE__ or __FALSE__ (will be ignored)
    59  */
    60 SubString::SubString(const std::string& string, bool whiteSpaces)
    61 {
    62   SubString::splitLine(this->strings, string);
    63 }
    6455
    6556/**
     
    10798{ }
    10899
    109 /**
    110  * @brief An empty String
    111  */
     100/** @brief An empty String */
    112101const std::string SubString::emptyString = "";
     102/** @brief Helper that gets you a String consisting of all White Spaces */
     103const std::string SubString::WhiteSpaces = " \n\t";
     104/** @brief Helper that gets you a String consisting of all WhiteSpaces and the Comma */
     105const std::string SubString::WhiteSpacesWithComma = " \n\t,";
    113106
    114107/**
     
    171164  split[1] = '\0';
    172165  SubString::splitLine(this->strings, string, split);
    173   return strings.size();
    174 }
    175 
    176 
    177 /**
    178  * @brief Splits a String into a Substring removing all whiteSpaces
    179  * @param string the String to Split
    180  * @param whiteSpaces MUST BE __TRUE__
    181  *
    182  */
    183 unsigned int SubString::split(const std::string& string, bool whiteSpaces)
    184 {
    185   this->strings.clear();
    186   SubString::splitLine(this->strings, string);
    187166  return strings.size();
    188167}
  • trunk/src/lib/util/substring.h

    r7323 r7325  
    11/*!
    2   \file substring.h
    3   \brief a small class to get the parts of a string separated by commas
    4 */
     2 * @file substring.h
     3 * @brief a small class to get the parts of a string separated by commas
     4 */
    55
    66#ifndef _SUBSTRING_H
     
    2828  SubString();
    2929  SubString(const std::string& string, char splitter = ',');
    30   SubString(const std::string& string, bool whiteSpaces);
    3130  SubString(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0');
    3231  /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */
     
    4746  // Split and Join the any String. ///////
    4847  unsigned int split(const std::string& string = "", char splitter = ',');
    49   unsigned int split(const std::string& string, bool whiteSpaces);
    5048  unsigned int split(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0');
    5149  std::string join(const std::string& delimiter = " ") const;
     
    5856  // retrieve Information from within
    5957  inline unsigned int size() const { return this->strings.size(); };
    60   const std::string& getString(unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; };
     58const std::string& getString(unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; };
    6159  const std::string& operator[](unsigned int i) const { return this->getString(i); };
    6260
     
    6462  static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,
    6563                                    const std::string& line,
    66                                     const std::string& delimiters = " \t\r\n",
     64                                    const std::string& delimiters = SubString::WhiteSpaces,
    6765                                    char escape_char = '\\',
    6866                                    char safemode_char = '"',
     
    7169  // debugging.
    7270  void debug() const;
     71
     72public:
     73  static const std::string WhiteSpaces;
     74  static const std::string WhiteSpacesWithComma;
    7375
    7476private:
Note: See TracChangeset for help on using the changeset viewer.