Changeset 849
- Timestamp:
- Mar 5, 2008, 1:33:08 AM (17 years ago)
- Location:
- code/branches/core/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core/src/util/SubString.cc
r836 r849 45 45 /** 46 46 * @brief create a SubString from 47 * @param string the String to Sp ilit47 * @param string the String to Split 48 48 * @param delimiter the Character at which to split string (delimiter) 49 49 */ … … 66 66 SubString::SubString(const std::string& string, 67 67 const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries, 68 char escapeChar, char safemode_char, char comment_char)69 { 70 SubString::splitLine(this->strings, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, safemode_char, comment_char);68 char escapeChar, char safemode_char, char openparenthesis_char, char closeparenthesis_char, char comment_char) 69 { 70 SubString::splitLine(this->strings, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, safemode_char, openparenthesis_char, closeparenthesis_char, comment_char); 71 71 } 72 72 … … 223 223 unsigned int SubString::split(const std::string& string, 224 224 const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries, 225 char escapeChar, char safemode_char, char comment_char)225 char escapeChar, char safemode_char, char openparenthesis_char, char closeparenthesis_char, char comment_char) 226 226 { 227 227 this->strings.clear(); 228 SubString::splitLine(this->strings, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, safemode_char, comment_char);228 SubString::splitLine(this->strings, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, safemode_char, openparenthesis_char, closeparenthesis_char, comment_char); 229 229 return this->strings.size(); 230 230 } … … 308 308 char escape_char, 309 309 char safemode_char, 310 char openparenthesis_char, 311 char closeparenthesis_char, 310 312 char comment_char, 311 313 SPLIT_LINE_STATE start_state) … … 335 337 { 336 338 state = SL_SAFEMODE; 339 } 340 else if(line[i] == openparenthesis_char) 341 { 342 state = SL_PARENTHESES; 337 343 } 338 344 else if(line[i] == comment_char) … … 419 425 break; 420 426 427 case SL_PARENTHESES: 428 if(line[i] == closeparenthesis_char) 429 { 430 state = SL_NORMAL; 431 } 432 else if(line[i] == escape_char) 433 { 434 state = SL_PARENTHESESESCAPE; 435 } 436 else 437 { 438 token += line[i]; // EAT 439 } 440 break; 441 442 case SL_PARENTHESESESCAPE: 443 if(line[i] == 'n') token += '\n'; 444 else if(line[i] == 't') token += '\t'; 445 else if(line[i] == 'v') token += '\v'; 446 else if(line[i] == 'b') token += '\b'; 447 else if(line[i] == 'r') token += '\r'; 448 else if(line[i] == 'f') token += '\f'; 449 else if(line[i] == 'a') token += '\a'; 450 else if(line[i] == '?') token += '\?'; 451 else token += line[i]; // EAT 452 state = SL_PARENTHESES; 453 break; 454 421 455 case SL_COMMENT: 422 456 if(line[i] == '\n') -
code/branches/core/src/util/SubString.h
r836 r849 23 23 * Co-authors: 24 24 * Benjamin Grauer 25 * Fabian 'x3n' Landau 25 26 * 26 // 27 27 28 // splitLine 28 29 // STL string tokenizer … … 31 32 // Version 1.0 32 33 // Copyright (c) 2005 Clemens Wacha. All rights reserved. 33 // 34 35 * Extended by Fabian 'x3n' Landau with the SL_PARENTHESES mode. 34 36 */ 35 37 … … 76 78 SL_SAFEESCAPE, //!< In safe mode with the internal escape character, that escapes even the savemode character. 77 79 SL_COMMENT, //!< In Comment mode. 80 SL_PARENTHESES, //!< Between parentheses (usually '(' and ')') 81 SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character. 78 82 } SPLIT_LINE_STATE; 79 83 … … 84 88 SubString(const std::string& string, 85 89 const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries=false, 86 char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0');90 char escapeChar ='\\', char safemode_char = '"', char openparenthesis_char = '(', char closeparenthesis_char = ')', char comment_char = '\0'); 87 91 SubString(unsigned int argc, const char** argv); 88 92 /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */ … … 107 111 unsigned int split(const std::string& string, 108 112 const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries = false, 109 char escapeChar ='\\', char safemode_char = '"', char comment_char = '\0');113 char escapeChar ='\\', char safemode_char = '"', char openparenthesis_char = '(', char closeparenthesis_char = ')', char comment_char = '\0'); 110 114 std::string join(const std::string& delimiter = " ") const; 111 115 //////////////////////////////////////// … … 139 143 char escape_char = '\\', 140 144 char safemode_char = '"', 145 char openparenthesis_char = '(', 146 char closeparenthesis_char = ')', 141 147 char comment_char = '\0', 142 148 SPLIT_LINE_STATE start_state = SL_NORMAL);
Note: See TracChangeset
for help on using the changeset viewer.