Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 18, 2012, 6:43:24 PM (12 years ago)
Author:
landauf
Message:

made SubString more standard compliant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/testing/src/libraries/util/SubString.h

    r8858 r9047  
    5858    SubString tokens(text, SubString::WhiteSpaces, "", false, '\\', true, '"', true, '{', '}', true, '\0');
    5959
    60     for (unsigned int i = 0; i < tokens.size(); ++i)
     60    for (size_t i = 0; i < tokens.size(); ++i)
    6161        orxout() << i << ": " << tokens[i] << endl;
    6262    @endcode
     
    127127                  bool bRemoveParenthesisChars = true,
    128128                  char commentChar = '\0');
    129         SubString(unsigned int argc, const char** argv);
    130         SubString(const SubString& other, unsigned int begin);
    131         SubString(const SubString& other, unsigned int begin, unsigned int end);
     129        SubString(size_t argc, const char** argv);
     130        SubString(const SubString& other, size_t begin, size_t length = std::string::npos);
    132131        ~SubString();
    133132
     
    135134        SubString& operator=(const SubString& other);
    136135        bool operator==(const SubString& other) const;
    137         bool compare(const SubString& other) const;
    138         bool compare(const SubString& other, unsigned int length) const;
     136        bool compare(const SubString& other, size_t length = std::string::npos) const;
    139137        SubString operator+(const SubString& other) const;
    140138        SubString& operator+=(const SubString& other);
     
    144142        /////////////////////////////////////////
    145143        // Split and Join the any String. ///////
    146         unsigned int split(const std::string& line,
    147                            const std::string& delimiters = SubString::WhiteSpaces,
    148                            const std::string& delimiterNeighbours = "",
    149                            bool bAllowEmptyEntries = false,
    150                            char escapeChar ='\\',
    151                            bool bRemoveEscapeChar = true,
    152                            char safemodeChar = '"',
    153                            bool bRemoveSafemodeChar = true,
    154                            char openparenthesisChar = '{',
    155                            char closeparenthesisChar = '}',
    156                            bool bRemoveParenthesisChars = true,
    157                            char commentChar = '\0');
     144        size_t split(const std::string& line,
     145                     const std::string& delimiters = SubString::WhiteSpaces,
     146                     const std::string& delimiterNeighbours = "",
     147                     bool bAllowEmptyEntries = false,
     148                     char escapeChar ='\\',
     149                     bool bRemoveEscapeChar = true,
     150                     char safemodeChar = '"',
     151                     bool bRemoveSafemodeChar = true,
     152                     char openparenthesisChar = '{',
     153                     char closeparenthesisChar = '}',
     154                     bool bRemoveParenthesisChars = true,
     155                     char commentChar = '\0');
    158156
    159157        std::string join(const std::string& delimiter = " ") const;
     
    161159
    162160        // retrieve a SubSet from the String
    163         SubString subSet(unsigned int begin) const;
    164         SubString subSet(unsigned int begin, unsigned int end) const;
     161        SubString subSet(size_t begin, size_t length = std::string::npos) const;
    165162
    166163        // retrieve Information from within
     
    168165        inline bool empty() const { return this->tokens_.empty(); }
    169166        /// Returns the number of tokens stored in this SubString
    170         inline unsigned int size() const { return this->tokens_.size(); }
     167        inline size_t size() const { return this->tokens_.size(); }
    171168        /// Returns the i'th token from the subset of strings @param index The index of the requested token
    172         inline const std::string& operator[](unsigned int index) const { return this->tokens_[index]; }
     169        inline const std::string& operator[](size_t index) const { return this->tokens_[index]; }
    173170        /// Returns the i'th token from the subset of strings @param index The index of the requested token
    174         inline const std::string& getString(unsigned int index) const { return (*this)[index]; }
     171        inline const std::string& getString(size_t index) const { return (*this)[index]; }
    175172        /// Returns all tokens as std::vector
    176173        inline const std::vector<std::string>& getAllStrings() const { return this->tokens_; }
    177174        /// Returns true if the token is in safemode. @param index The index of the token
    178         inline bool isInSafemode(unsigned int index) const { return this->bTokenInSafemode_[index]; }
     175        inline bool isInSafemode(size_t index) const { return this->bTokenInSafemode_[index]; }
    179176        /// Returns the front of the list of tokens.
    180177        inline const std::string& front() const { return this->tokens_.front(); }
Note: See TracChangeset for help on using the changeset viewer.