Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 5, 2008, 1:33:08 AM (17 years ago)
Author:
landauf
Message:

and here comes the extended SubString class (added parenthesis support), I had problems with svn

Location:
code/branches/core/src/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core/src/util/SubString.cc

    r836 r849  
    4545/**
    4646 * @brief create a SubString from
    47  * @param string the String to Spilit
     47 * @param string the String to Split
    4848 * @param delimiter the Character at which to split string (delimiter)
    4949 */
     
    6666SubString::SubString(const std::string& string,
    6767                     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);
    7171}
    7272
     
    223223unsigned int SubString::split(const std::string& string,
    224224                              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)
    226226{
    227227  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);
    229229  return this->strings.size();
    230230}
     
    308308                     char escape_char,
    309309                     char safemode_char,
     310                     char openparenthesis_char,
     311                     char closeparenthesis_char,
    310312                     char comment_char,
    311313                     SPLIT_LINE_STATE start_state)
     
    335337        {
    336338          state = SL_SAFEMODE;
     339        }
     340        else if(line[i] == openparenthesis_char)
     341        {
     342          state = SL_PARENTHESES;
    337343        }
    338344        else if(line[i] == comment_char)
     
    419425        break;
    420426
     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
    421455      case SL_COMMENT:
    422456        if(line[i] == '\n')
  • code/branches/core/src/util/SubString.h

    r836 r849  
    2323 *   Co-authors:
    2424 *      Benjamin Grauer
     25 *      Fabian 'x3n' Landau
    2526 *
    26 //
     27
    2728//  splitLine
    2829//  STL string tokenizer
     
    3132//  Version 1.0
    3233//  Copyright (c) 2005 Clemens Wacha. All rights reserved.
    33 //
     34
     35 * Extended by Fabian 'x3n' Landau with the SL_PARENTHESES mode.
    3436 */
    3537
     
    7678    SL_SAFEESCAPE,        //!< In safe mode with the internal escape character, that escapes even the savemode character.
    7779    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.
    7882  } SPLIT_LINE_STATE;
    7983
     
    8488  SubString(const std::string& string,
    8589            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');
    8791  SubString(unsigned int argc, const char** argv);
    8892  /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */
     
    107111  unsigned int split(const std::string& string,
    108112                     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');
    110114  std::string join(const std::string& delimiter = " ") const;
    111115  ////////////////////////////////////////
     
    139143                                    char escape_char = '\\',
    140144                                    char safemode_char = '"',
     145                                    char openparenthesis_char = '(',
     146                                    char closeparenthesis_char = ')',
    141147                                    char comment_char = '\0',
    142148                                    SPLIT_LINE_STATE start_state = SL_NORMAL);
Note: See TracChangeset for help on using the changeset viewer.