Changeset 7401 for code/trunk/src/libraries/util/SubString.cc
- Timestamp:
- Sep 11, 2010, 12:34:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/doc (added) merged: 7290-7292,7296-7300,7302-7304,7306-7312,7315-7318,7323,7325,7327,7331-7332,7334-7335,7345-7347,7352-7353,7356-7357,7361,7363-7367,7371-7375,7388
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/util/SubString.cc
r7284 r7401 38 38 */ 39 39 40 /** 41 @file 42 @brief Implementation of the SubString class. 43 */ 44 40 45 #include "SubString.h" 41 46 #include <cstdio> 47 #include "Debug.h" 42 48 43 49 namespace orxonox 44 50 { 45 /** 46 * @brief default constructor 47 */ 51 const std::string SubString::WhiteSpaces = " \n\t"; 52 const std::string SubString::WhiteSpacesWithComma = " \n\t,"; 53 const SubString SubString::NullSubString = SubString(); 54 55 /** 56 @brief Default constructor. 57 */ 48 58 SubString::SubString() 49 {} 50 51 52 /** 53 * @brief create a SubString from 54 * @param string the String to Split 55 * @param delimiter the Character at which to split string (delimiter) 56 */ 57 SubString::SubString(const std::string& string, char delimiter) 58 { 59 this->split(string, delimiter); 60 } 61 62 63 /** 64 * @brief Splits a String into multiple splitters. 65 * @param string the String to split 66 * @param delimiters multiple set of characters at what to split. (delimiters) 67 * @param delimiterNeighbours neighbours of the delimiters, that will be erased only when near a delimiter. 68 * @param emptyEntries If empty entries should be allewed or removed. 69 * @param escapeChar The Escape Character that overrides splitters commends and so on... 70 * @param safemode_char within these characters splitting won't happen 71 * @param comment_char the Comment character. 72 */ 73 SubString::SubString(const std::string& string, 74 const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries, 75 char escapeChar, bool removeEscapeChar, char safemode_char, bool removeSafemodeChar, 76 char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char) 77 { 78 SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeEscapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char); 79 } 80 81 /** 82 * @brief creates a SubSet of a SubString. 83 * @param subString the SubString to take a set from. 84 * @param subSetBegin the beginning to the end 85 */ 86 SubString::SubString(const SubString& subString, unsigned int subSetBegin) 87 { 88 for (unsigned int i = subSetBegin; i < subString.size(); i++) 89 { 90 this->strings.push_back(subString[i]); 91 this->bInSafemode.push_back(subString.isInSafemode(i)); 92 } 93 } 94 95 96 /** 97 * @brief creates a SubSet of a SubString. 98 * @param subString the SubString to take a Set from 99 * @param subSetBegin the beginning to the end 100 * @param subSetEnd the end of the SubSet (max subString.size() will be checked internaly) 101 */ 102 SubString::SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd) 103 { 104 for (unsigned int i = subSetBegin; i < subString.size() && i < subSetEnd; i++) 105 { 106 this->strings.push_back(subString[i]); 107 this->bInSafemode.push_back(subString.isInSafemode(i)); 108 } 109 } 110 111 /** 112 * @brief creates a Substring from a count and values set. 113 * @param argc: the Arguments Count. 114 * @param argv: Argument Values. 115 */ 59 { 60 } 61 62 /** 63 @brief Splits a string into multiple tokens. 64 @param line The line to split 65 @param delimiters Multiple characters at which to split the line 66 @param delimiterNeighbours Neighbours of the delimiters that will be erased as well (for example white-spaces) 67 @param bAllowEmptyEntries If true, empty tokens are also added to the SubString (if there are two delimiters without a char in between) 68 @param escapeChar The escape character that is used to escape safemode chars (for example if you want to use a quotation mark between two other quotation marks). 69 @param bRemoveEscapeChar If true, the escape char is removed from the tokens 70 @param safemodeChar Within these characters splitting won't happen (usually the quotation marks) 71 @param bRemoveSafemodeChar Removes the safemodeChar from the beginning and the ending of a token 72 @param openparenthesisChar The beginning of a safemode is marked with this (usually an opening brace) 73 @param closeparenthesisChar The ending of a safemode is marked with this (usually a closing brace) 74 @param bRemoveParenthesisChars Removes the parenthesis chars from the beginning and the ending of a token 75 @param commentChar The comment character (used to ignore the part of the line after the comment char). 76 */ 77 SubString::SubString(const std::string& line, 78 const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries, 79 char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar, 80 char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar) 81 { 82 SubString::splitLine(this->tokens_, this->bTokenInSafemode_, line, delimiters, delimiterNeighbours, bAllowEmptyEntries, escapeChar, bRemoveEscapeChar, safemodeChar, bRemoveSafemodeChar, openparenthesisChar, closeparenthesisChar, bRemoveParenthesisChars, commentChar); 83 } 84 85 /** 86 @brief creates a new SubString based on a subset of an other SubString. 87 @param other The other SubString 88 @param begin The beginning of the subset 89 90 The subset ranges from the token with index @a begin to the end of the tokens. 91 If @a begin is greater than the greatest index, the new SubString will be empty. 92 */ 93 SubString::SubString(const SubString& other, unsigned int begin) 94 { 95 for (unsigned int i = begin; i < other.size(); ++i) 96 { 97 this->tokens_.push_back(other[i]); 98 this->bTokenInSafemode_.push_back(other.isInSafemode(i)); 99 } 100 } 101 102 /** 103 @brief creates a new SubString based on a subset of an other SubString. 104 @param other The other SubString 105 @param begin The beginning of the subset 106 @param end The end of the subset 107 108 The subset ranges from the token with index @a begin until (but not including) the token with index @a end. 109 If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty. 110 */ 111 SubString::SubString(const SubString& other, unsigned int begin, unsigned int end) 112 { 113 for (unsigned int i = begin; i < std::min(other.size(), end); ++i) 114 { 115 this->tokens_.push_back(other[i]); 116 this->bTokenInSafemode_.push_back(other.isInSafemode(i)); 117 } 118 } 119 120 /** 121 @brief Creates a SubString from a count and values set. 122 @param argc The number of arguments 123 @param argv An array of pointers to the arguments 124 */ 116 125 SubString::SubString(unsigned int argc, const char** argv) 117 126 { 118 127 for(unsigned int i = 0; i < argc; ++i) 119 128 { 120 this-> strings.push_back(std::string(argv[i]));121 this->b InSafemode.push_back(false);122 } 123 } 124 125 /** 126 * @brief removes the object from memory127 129 this->tokens_.push_back(std::string(argv[i])); 130 this->bTokenInSafemode_.push_back(false); 131 } 132 } 133 134 /** 135 @brief Destructor 136 */ 128 137 SubString::~SubString() 129 138 { } 130 139 131 /** @brief An empty String */ 132 // const std::string SubString::emptyString = ""; 133 /** @brief Helper that gets you a String consisting of all White Spaces */ 134 const std::string SubString::WhiteSpaces = " \n\t"; 135 /** @brief Helper that gets you a String consisting of all WhiteSpaces and the Comma */ 136 const std::string SubString::WhiteSpacesWithComma = " \n\t,"; 137 /** An Empty SubString */ 138 const SubString SubString::NullSubString = SubString(); 139 140 /** 141 * @brief stores the Value of subString in this SubString 142 * @param subString will be copied into this String. 143 * @returns this SubString. 144 */ 145 SubString& SubString::operator=(const SubString& subString) 146 { 147 this->strings = subString.strings; 148 this->bInSafemode = subString.bInSafemode; 140 /** 141 @brief Stores the tokens of @a other in this SubString 142 @return This SubString. 143 */ 144 SubString& SubString::operator=(const SubString& other) 145 { 146 this->tokens_ = other.tokens_; 147 this->bTokenInSafemode_ = other.bTokenInSafemode_; 149 148 return *this; 150 149 } 151 150 152 153 /** 154 * @brief comparator. 155 * @param subString the SubString to compare against this one. 156 * @returns true if the Stored Strings match 157 */ 158 bool SubString::operator==(const SubString& subString) const 159 { 160 return ((this->strings == subString.strings) && (this->bInSafemode == subString.bInSafemode)); 161 } 162 163 /** 164 * @brief comparator. 165 * @param subString the SubString to compare against this one. 166 * @returns true if the Stored Strings match 167 */ 168 bool SubString::compare(const SubString& subString) const 169 { 170 return (*this == subString); 171 } 172 173 /** 174 * @brief comparator. 175 * @param subString the SubString to compare against this one. 176 * @param length how many entries to compare. (from 0 to length) 177 * @returns true if the Stored Strings match 178 */ 179 bool SubString::compare(const SubString& subString, unsigned int length) const 180 { 181 if (length > this->size() || length > subString.size()) 151 /** 152 @brief Compares this SubString to another SubString and returns true if they contain the same values. 153 */ 154 bool SubString::operator==(const SubString& other) const 155 { 156 return ((this->tokens_ == other.tokens_) && (this->bTokenInSafemode_ == other.bTokenInSafemode_)); 157 } 158 159 /** 160 @copydoc operator== 161 */ 162 bool SubString::compare(const SubString& other) const 163 { 164 return (*this == other); 165 } 166 167 /** 168 @brief Compares this SubString to another SubString and returns true if the first @a length values match. 169 @param other The other SubString 170 @param length How many tokens to compare 171 */ 172 bool SubString::compare(const SubString& other, unsigned int length) const 173 { 174 if (length > this->size() || length > other.size()) 182 175 return false; 183 176 184 for (unsigned int i = 0; i < length; i++)185 if ((this-> strings[i] != subString.strings[i]) || (this->bInSafemode[i] != subString.bInSafemode[i]))177 for (unsigned int i = 0; i < length; ++i) 178 if ((this->tokens_[i] != other.tokens_[i]) || (this->bTokenInSafemode_[i] != other.bTokenInSafemode_[i])) 186 179 return false; 187 180 return true; 188 181 } 189 182 190 191 /** 192 * @brief append operator 193 * @param subString the String to append. 194 * @returns a SubString where this and subString are appended. 195 */ 196 SubString SubString::operator+(const SubString& subString) const 197 { 198 return SubString(*this) += subString; 199 } 200 201 202 /** 203 * @brief append operator. 204 * @param subString append subString to this SubString. 205 * @returns this substring appended with subString 206 */ 207 SubString& SubString::operator+=(const SubString& subString) 208 { 209 for (unsigned int i = 0; i < subString.size(); i++) 210 { 211 this->strings.push_back(subString[i]); 212 this->bInSafemode.push_back(subString.isInSafemode(i)); 183 /** 184 @brief Concatenates the tokens of two SubStrings and returns the resulting new SubString 185 @return A new SubString that contains the tokens of this and the other SubString 186 */ 187 SubString SubString::operator+(const SubString& other) const 188 { 189 return SubString(*this) += other; 190 } 191 192 /** 193 @brief Appends the tokens of @a other to this SubString 194 @return This SubString 195 */ 196 SubString& SubString::operator+=(const SubString& other) 197 { 198 for (unsigned int i = 0; i < other.size(); ++i) 199 { 200 this->tokens_.push_back(other[i]); 201 this->bTokenInSafemode_.push_back(other.isInSafemode(i)); 213 202 } 214 203 return *this; 215 204 } 216 205 217 218 /** 219 * @brief Split the String at 220 * @param string where to split 221 * @param splitter delimiter. 222 */ 223 unsigned int SubString::split(const std::string& string, char splitter) 224 { 225 this->strings.clear(); 226 this->bInSafemode.clear(); 227 char split[2]; 228 split[0] = splitter; 229 split[1] = '\0'; 230 SubString::splitLine(this->strings, this->bInSafemode, string, split); 231 return strings.size(); 232 } 233 234 235 /** 236 * @brief Splits a String into multiple splitters. 237 * @param string the String to split 238 * @param delimiters multiple set of characters at what to split. (delimiters) 239 * @param delimiterNeighbours: Neighbours to the Delimiters that will be erased too. 240 * @param emptyEntries: If empty entries are added to the List of SubStrings 241 * @param escapeChar The Escape Character that overrides splitters commends and so on... 242 * @param safemode_char within these characters splitting won't happen 243 * @param comment_char the Comment character. 244 */ 245 unsigned int SubString::split(const std::string& string, 246 const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries, 247 char escapeChar, bool removeExcapeChar, char safemode_char, bool removeSafemodeChar, 248 char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char) 249 { 250 this->strings.clear(); 251 this->bInSafemode.clear(); 252 SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeExcapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char); 253 return this->strings.size(); 254 } 255 256 257 /** 258 * @brief joins together all Strings of this Substring. 259 * @param delimiter the String between the subStrings. 260 * @returns the joined String. 261 */ 206 /** 207 @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char) 208 */ 209 unsigned int SubString::split(const std::string& line, 210 const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries, 211 char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar, 212 char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar) 213 { 214 this->tokens_.clear(); 215 this->bTokenInSafemode_.clear(); 216 SubString::splitLine(this->tokens_, this->bTokenInSafemode_, line, delimiters, delimiterNeighbours, bAllowEmptyEntries, escapeChar, bRemoveEscapeChar, safemodeChar, bRemoveSafemodeChar, openparenthesisChar, closeparenthesisChar, bRemoveParenthesisChars, commentChar); 217 return this->tokens_.size(); 218 } 219 220 /** 221 @brief Joins the tokens of this SubString using the given delimiter and returns a string. 222 @param delimiter This delimiter will be placed between each two tokens 223 @return The joined string. 224 */ 262 225 std::string SubString::join(const std::string& delimiter) const 263 226 { 264 if (!this-> strings.empty())265 { 266 std::string retVal = this-> strings[0];267 for (unsigned int i = 1; i < this-> strings.size(); i++)268 retVal += delimiter + this-> strings[i];227 if (!this->tokens_.empty()) 228 { 229 std::string retVal = this->tokens_[0]; 230 for (unsigned int i = 1; i < this->tokens_.size(); ++i) 231 retVal += delimiter + this->tokens_[i]; 269 232 return retVal; 270 233 } … … 273 236 } 274 237 275 276 /** 277 * @brief creates a SubSet of a SubString. 278 * @param subSetBegin the beginning to the end 279 * @returns the SubSet 280 * 281 * This function is added for your convenience, and does the same as 282 * SubString::SubString(const SubString& subString, unsigned int subSetBegin) 283 */ 284 SubString SubString::subSet(unsigned int subSetBegin) const 285 { 286 return SubString(*this, subSetBegin); 287 } 288 289 290 /** 291 * @brief creates a SubSet of a SubString. 292 * @param subSetBegin the beginning to 293 * @param subSetEnd the end of the SubSet to select (if bigger than subString.size() it will be downset.) 294 * @returns the SubSet 295 * 296 * This function is added for your convenience, and does the same as 297 * SubString::SubString(const SubString& subString, unsigned int subSetBegin) 298 */ 299 SubString SubString::subSet(unsigned int subSetBegin, unsigned int subSetEnd) const 300 { 301 return SubString(*this, subSetBegin, subSetEnd); 302 } 303 304 305 /** 306 * @brief splits line into tokens and stores them in ret. 307 * @param ret the Array, where the Splitted strings will be stored in 308 * to the beginning of the current token is stored 309 * @param line the inputLine to split 310 * @param delimiters a String of Delimiters (here the input will be splitted) 311 * @param delimiterNeighbours Neighbours to the Delimiter, that will be removed if they are to the left or the right of a Delimiter. 312 * @param emptyEntries: if empty Strings are added to the List of Strings. 313 * @param escape_char: Escape carater (escapes splitters) 314 * @param safemode_char: the beginning of the safemode is marked with this 315 * @param removeSafemodeChar removes the safemode_char from the beginning and the ending of a token 316 * @param openparenthesis_char the beginning of a safemode is marked with this 317 * @param closeparenthesis_char the ending of a safemode is marked with this 318 * @param removeParenthesisChars removes the parenthesis from the beginning and the ending of a token 319 * @param comment_char: the beginning of a comment is marked with this: (until the end of a Line) 320 * @param start_state: the Initial state on how to parse the String. 321 * @return SPLIT_LINE_STATE the parser was in when returning 322 * 323 * This is the Actual Splitting Algorithm from Clemens Wacha 324 * Supports delimiters, escape characters, 325 * ignores special characters between safemode_char and between comment_char and linend '\n'. 326 */ 238 /** 239 @brief Creates a subset of this SubString. 240 @param begin The beginning of the subset 241 @return A new SubString containing the defined subset. 242 243 The subset ranges from the token with index @a begin to the end of the tokens. 244 If @a begin is greater than the greatest index, the new SubString will be empty. 245 246 This function is added for your convenience, and does the same as 247 SubString::SubString(const SubString& other, unsigned int begin) 248 */ 249 SubString SubString::subSet(unsigned int begin) const 250 { 251 return SubString(*this, begin); 252 } 253 254 /** 255 @brief Creates a subset of this SubString. 256 @param begin The beginning of the subset 257 @param end The ending of the subset 258 @return A new SubString containing the defined subset. 259 260 The subset ranges from the token with index @a begin until (but not including) the token with index @a end. 261 If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty. 262 263 This function is added for your convenience, and does the same as 264 SubString::SubString(const SubString& other, unsigned int begin, unsigned int end) 265 */ 266 SubString SubString::subSet(unsigned int begin, unsigned int end) const 267 { 268 return SubString(*this, begin, end); 269 } 270 271 /** 272 @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char) 273 @param tokens The array, where the splitted strings will be stored in 274 @param bTokenInSafemode A vector wich stores for each character of the string if it is in safemode or not 275 @param start_state The internal state of the parser 276 277 This is the actual splitting algorithm from Clemens Wacha. 278 Supports delimiters, escape characters, ignores special characters between safemodeChar and between commentChar and line end "\n". 279 280 Extended by Orxonox to support parenthesis as additional safe-mode. 281 */ 327 282 SubString::SPLIT_LINE_STATE 328 SubString::splitLine(std::vector<std::string>& ret,329 std::vector<bool>& b InSafemode,283 SubString::splitLine(std::vector<std::string>& tokens, 284 std::vector<bool>& bTokenInSafemode, 330 285 const std::string& line, 331 286 const std::string& delimiters, 332 287 const std::string& delimiterNeighbours, 333 bool emptyEntries,334 char escape _char,335 bool removeExcapeChar,336 char safemode _char,337 bool removeSafemodeChar,338 char openparenthesis _char,339 char closeparenthesis _char,340 bool removeParenthesisChars,341 char comment _char,288 bool bAllowEmptyEntries, 289 char escapeChar, 290 bool bRemoveEscapeChar, 291 char safemodeChar, 292 bool bRemoveSafemodeChar, 293 char openparenthesisChar, 294 char closeparenthesisChar, 295 bool bRemoveParenthesisChars, 296 char commentChar, 342 297 SPLIT_LINE_STATE start_state) 343 298 { … … 349 304 bool inSafemode = false; 350 305 351 if(start_state != SL_NORMAL && ret.size() > 0)352 { 353 token = ret[ret.size()-1];354 ret.pop_back();355 } 356 if(start_state != SL_NORMAL && b InSafemode.size() > 0)357 { 358 inSafemode = b InSafemode[bInSafemode.size()-1];359 b InSafemode.pop_back();306 if(start_state != SL_NORMAL && tokens.size() > 0) 307 { 308 token = tokens[tokens.size()-1]; 309 tokens.pop_back(); 310 } 311 if(start_state != SL_NORMAL && bTokenInSafemode.size() > 0) 312 { 313 inSafemode = bTokenInSafemode[bTokenInSafemode.size()-1]; 314 bTokenInSafemode.pop_back(); 360 315 } 361 316 … … 365 320 { 366 321 case SL_NORMAL: 367 if(line[i] == escape _char)322 if(line[i] == escapeChar) 368 323 { 369 324 state = SL_ESCAPE; 370 if (! removeExcapeChar)325 if (!bRemoveEscapeChar) 371 326 token += line[i]; 372 } 373 else if(line[i] == safemode_char) 327 fallBackNeighbours = 0; 328 } 329 else if(line[i] == safemodeChar) 374 330 { 375 331 state = SL_SAFEMODE; 376 332 inSafemode = true; 377 if (! removeSafemodeChar)333 if (!bRemoveSafemodeChar) 378 334 token += line[i]; 379 } 380 else if(line[i] == openparenthesis_char) 335 fallBackNeighbours = 0; 336 } 337 else if(line[i] == openparenthesisChar) 381 338 { 382 339 state = SL_PARENTHESES; 383 340 inSafemode = true; 384 if (! removeParenthesisChars)341 if (!bRemoveParenthesisChars) 385 342 token += line[i]; 386 } 387 else if(line[i] == comment_char) 343 fallBackNeighbours = 0; 344 } 345 else if(line[i] == commentChar) 388 346 { 389 347 if (fallBackNeighbours > 0) 390 348 token = token.substr(0, token.size() - fallBackNeighbours); 391 /// FINISH 392 if(emptyEntries || token.size() > 0) 349 fallBackNeighbours = 0; 350 // FINISH 351 if(bAllowEmptyEntries || token.size() > 0) 393 352 { 394 ret.push_back(token);353 tokens.push_back(token); 395 354 token.clear(); 396 b InSafemode.push_back(inSafemode);355 bTokenInSafemode.push_back(inSafemode); 397 356 inSafemode = false; 398 357 } … … 405 364 if (fallBackNeighbours > 0) 406 365 token = token.substr(0, token.size() - fallBackNeighbours); 407 /// FINISH 408 if(emptyEntries || token.size() > 0) 366 fallBackNeighbours = 0; 367 // FINISH 368 if(bAllowEmptyEntries || token.size() > 0) 409 369 { 410 ret.push_back(token);370 tokens.push_back(token); 411 371 token.clear(); 412 b InSafemode.push_back(inSafemode);372 bTokenInSafemode.push_back(inSafemode); 413 373 inSafemode = false; 414 374 } … … 423 383 else 424 384 { 425 i++;385 ++i; 426 386 continue; 427 387 } … … 433 393 break; 434 394 case SL_ESCAPE: 435 if (! removeSafemodeChar)395 if (!bRemoveSafemodeChar) 436 396 token += line[i]; 437 397 else … … 450 410 break; 451 411 case SL_SAFEMODE: 452 if(line[i] == safemode _char)412 if(line[i] == safemodeChar) 453 413 { 454 414 state = SL_NORMAL; 455 if (! removeSafemodeChar)415 if (!bRemoveSafemodeChar) 456 416 token += line[i]; 457 417 } 458 else if(line[i] == escape _char)418 else if(line[i] == escapeChar) 459 419 { 460 420 state = SL_SAFEESCAPE; … … 480 440 481 441 case SL_PARENTHESES: 482 if(line[i] == closeparenthesis _char)442 if(line[i] == closeparenthesisChar) 483 443 { 484 444 state = SL_NORMAL; 485 if (! removeParenthesisChars)445 if (!bRemoveParenthesisChars) 486 446 token += line[i]; 487 447 } 488 else if(line[i] == escape _char)448 else if(line[i] == escapeChar) 489 449 { 490 450 state = SL_PARENTHESESESCAPE; … … 512 472 if(line[i] == '\n') 513 473 { 514 // /FINISH474 // FINISH 515 475 if(token.size() > 0) 516 476 { 517 ret.push_back(token);477 tokens.push_back(token); 518 478 token.clear(); 519 b InSafemode.push_back(inSafemode);479 bTokenInSafemode.push_back(inSafemode); 520 480 inSafemode = false; 521 481 } … … 532 492 break; 533 493 } 534 i++;535 } 536 537 // /FINISH494 ++i; 495 } 496 497 // FINISH 538 498 if (fallBackNeighbours > 0) 539 499 token = token.substr(0, token.size() - fallBackNeighbours); 540 if( emptyEntries || token.size() > 0)541 { 542 ret.push_back(token);500 if(bAllowEmptyEntries || token.size() > 0) 501 { 502 tokens.push_back(token); 543 503 token.clear(); 544 b InSafemode.push_back(inSafemode);504 bTokenInSafemode.push_back(inSafemode); 545 505 inSafemode = false; 546 506 } … … 548 508 } 549 509 550 551 /** 552 * @brief Some nice debug information about this SubString 553 */ 510 /** 511 @brief Some nice debug information about this SubString. 512 */ 554 513 void SubString::debug() const 555 514 { 556 printf("Substring-information::count=%d ::", this->strings.size());557 for (unsigned int i = 0; i < this-> strings.size(); i++)558 printf("s%d='%s'::", i, this->strings[i].c_str());559 printf("\n");515 COUT(0) << "Substring-information::count=" << this->tokens_.size() << " ::"; 516 for (unsigned int i = 0; i < this->tokens_.size(); ++i) 517 COUT(0) << "s" << i << "='" << this->tokens_[i].c_str() << "'::"; 518 COUT(0) << std::endl; 560 519 } 561 520 }
Note: See TracChangeset
for help on using the changeset viewer.