Changeset 7325 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Apr 17, 2006, 2:17:21 PM (19 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/substring.cc
r7323 r7325 53 53 } 54 54 55 /**56 * @brief Splits a String into a SubString removing all whiteSpaces57 * @param string the String to Split58 * @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 }64 55 65 56 /** … … 107 98 { } 108 99 109 /** 110 * @brief An empty String 111 */ 100 /** @brief An empty String */ 112 101 const std::string SubString::emptyString = ""; 102 /** @brief Helper that gets you a String consisting of all White Spaces */ 103 const std::string SubString::WhiteSpaces = " \n\t"; 104 /** @brief Helper that gets you a String consisting of all WhiteSpaces and the Comma */ 105 const std::string SubString::WhiteSpacesWithComma = " \n\t,"; 113 106 114 107 /** … … 171 164 split[1] = '\0'; 172 165 SubString::splitLine(this->strings, string, split); 173 return strings.size();174 }175 176 177 /**178 * @brief Splits a String into a Substring removing all whiteSpaces179 * @param string the String to Split180 * @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);187 166 return strings.size(); 188 167 } -
trunk/src/lib/util/substring.h
r7323 r7325 1 1 /*! 2 \file substring.h3 \brief a small class to get the parts of a string separated by commas4 */2 * @file substring.h 3 * @brief a small class to get the parts of a string separated by commas 4 */ 5 5 6 6 #ifndef _SUBSTRING_H … … 28 28 SubString(); 29 29 SubString(const std::string& string, char splitter = ','); 30 SubString(const std::string& string, bool whiteSpaces);31 30 SubString(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0'); 32 31 /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */ … … 47 46 // Split and Join the any String. /////// 48 47 unsigned int split(const std::string& string = "", char splitter = ','); 49 unsigned int split(const std::string& string, bool whiteSpaces);50 48 unsigned int split(const std::string& string, const std::string& splitters, char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0'); 51 49 std::string join(const std::string& delimiter = " ") const; … … 58 56 // retrieve Information from within 59 57 inline unsigned int size() const { return this->strings.size(); }; 60 58 const std::string& getString(unsigned int i) const { return (i < this->strings.size()) ? this->strings[i] : emptyString; }; 61 59 const std::string& operator[](unsigned int i) const { return this->getString(i); }; 62 60 … … 64 62 static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret, 65 63 const std::string& line, 66 const std::string& delimiters = " \t\r\n",64 const std::string& delimiters = SubString::WhiteSpaces, 67 65 char escape_char = '\\', 68 66 char safemode_char = '"', … … 71 69 // debugging. 72 70 void debug() const; 71 72 public: 73 static const std::string WhiteSpaces; 74 static const std::string WhiteSpacesWithComma; 73 75 74 76 private:
Note: See TracChangeset
for help on using the changeset viewer.