Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 12, 2013, 11:13:03 PM (11 years ago)
Author:
landauf
Message:

merged testing branch back to trunk. unbelievable it took me 13 months to finish this chore…

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/util/SubString.cc

    r8858 r9550  
    8787        @param other The other SubString
    8888        @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));
     89        @param length The length of the subset
     90
     91        The subset ranges from the token with index @a begin and contains @a length elements.
     92    */
     93    SubString::SubString(const SubString& other, size_t begin, size_t length)
     94    {
     95        for (size_t i = 0; i < length; ++i)
     96        {
     97            if (begin + i >= other.size())
     98                break;
     99
     100            this->tokens_.push_back(other[begin + i]);
     101            this->bTokenInSafemode_.push_back(other.isInSafemode(begin + i));
    117102        }
    118103    }
     
    123108        @param argv An array of pointers to the arguments
    124109    */
    125     SubString::SubString(unsigned int argc, const char** argv)
    126     {
    127         for(unsigned int i = 0; i < argc; ++i)
     110    SubString::SubString(size_t argc, const char** argv)
     111    {
     112        for (size_t i = 0; i < argc; ++i)
    128113        {
    129114            this->tokens_.push_back(std::string(argv[i]));
     
    158143
    159144    /**
    160         @copydoc operator==
    161     */
    162     bool SubString::compare(const SubString& other) const
    163     {
    164         return (*this == other);
    165     }
    166 
    167     /**
    168145        @brief Compares this SubString to another SubString and returns true if the first @a length values match.
    169146        @param other The other SubString
    170147        @param length How many tokens to compare
    171148    */
    172     bool SubString::compare(const SubString& other, unsigned int length) const
    173     {
    174         if (length > this->size() || length > other.size())
     149    bool SubString::compare(const SubString& other, size_t length) const
     150    {
     151        if (std::min(length, this->size()) != std::min(length, other.size()))
    175152            return false;
    176153
    177         for (unsigned int i = 0; i < length; ++i)
     154        for (size_t i = 0; i < std::min(length, this->size()); ++i)
    178155            if ((this->tokens_[i] != other.tokens_[i]) || (this->bTokenInSafemode_[i] != other.bTokenInSafemode_[i]))
    179156                return false;
     157
    180158        return true;
    181159    }
     
    196174    SubString& SubString::operator+=(const SubString& other)
    197175    {
    198         for (unsigned int i = 0; i < other.size(); ++i)
     176        for (size_t i = 0; i < other.size(); ++i)
    199177        {
    200178            this->tokens_.push_back(other[i]);
     
    207185        @copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char)
    208186    */
    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)
     187    size_t SubString::split(const std::string& line,
     188                            const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries,
     189                            char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar,
     190                            char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar)
    213191    {
    214192        this->tokens_.clear();
     
    228206        {
    229207            std::string retVal = this->tokens_[0];
    230             for (unsigned int i = 1; i < this->tokens_.size(); ++i)
     208            for (size_t i = 1; i < this->tokens_.size(); ++i)
    231209                retVal += delimiter + this->tokens_[i];
    232210            return retVal;
     
    239217        @brief Creates a subset of this SubString.
    240218        @param begin The beginning of the subset
     219        @param length The length of the subset
    241220        @return A new SubString containing the defined subset.
    242221
    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.
     222        The subset ranges from the token with index @a begin and contains @a length elements.
    245223
    246224        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);
     225        SubString::SubString(const SubString& other, size_t begin, size_t length)
     226    */
     227    SubString SubString::subSet(size_t begin, size_t length) const
     228    {
     229        return SubString(*this, begin, length);
    269230    }
    270231
     
    298259    {
    299260        SPLIT_LINE_STATE state = start_state;
    300         unsigned int i = 0;
    301         unsigned int fallBackNeighbours = 0;
     261        size_t i = 0;
     262        size_t fallBackNeighbours = 0;
    302263
    303264        std::string token;
     
    514475    {
    515476        orxout(debug_output) << "Substring-information::count=" << this->tokens_.size() << " ::";
    516         for (unsigned int i = 0; i < this->tokens_.size(); ++i)
     477        for (size_t i = 0; i < this->tokens_.size(); ++i)
    517478            orxout(debug_output) << "s" << i << "='" << this->tokens_[i].c_str() << "'::";
    518479        orxout(debug_output) << endl;
Note: See TracChangeset for help on using the changeset viewer.