Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7371 in orxonox.OLD for trunk/src/lib/util/helper_functions.cc


Ignore:
Timestamp:
Apr 26, 2006, 2:12:45 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: better completion-algos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/helper_functions.cc

    r7221 r7371  
    115115 * @param s2 second string
    116116 */
    117 int nocase_cmp(const std::string& s1, const std::string& s2)
     117int nocaseCmp(const std::string& s1, const std::string& s2)
    118118{
    119119  std::string::const_iterator it1=s1.begin();
     
    137137}
    138138
     139
     140/**
     141 * @brief compares two strings without ignoring the case
     142 * @param s1 first string
     143 * @param s2 second string
     144 * @param len how far from the beginning to start.
     145 */
     146int nocaseCmp(const std::string& s1, const std::string& s2, unsigned int len)
     147{
     148  std::string::const_iterator it1=s1.begin();
     149  std::string::const_iterator it2=s2.begin();
     150
     151  //stop when either string's end has been reached
     152  while ( (it1!=s1.end()) && (it2!=s2.end()) && len-- > 0)
     153  {
     154    if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
     155     // return -1 to indicate smaller than, 1 otherwise
     156      return (::toupper(*it1)  < ::toupper(*it2)) ? -1 : 1;
     157    //proceed to the next character in each string
     158    ++it1;
     159    ++it2;
     160  }
     161  return 0;
     162}
     163
Note: See TracChangeset for help on using the changeset viewer.