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