Changeset 7371 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Apr 26, 2006, 2:12:45 AM (19 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/helper_functions.cc
r7221 r7371 115 115 * @param s2 second string 116 116 */ 117 int nocase _cmp(const std::string& s1, const std::string& s2)117 int nocaseCmp(const std::string& s1, const std::string& s2) 118 118 { 119 119 std::string::const_iterator it1=s1.begin(); … … 137 137 } 138 138 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 */ 146 int 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 -
trunk/src/lib/util/helper_functions.h
r7221 r7371 21 21 22 22 23 int nocase_cmp(const std::string& s1, const std::string& s2); 23 int nocaseCmp(const std::string& s1, const std::string& s2); 24 int nocaseCmp(const std::string& s1, const std::string& s2, unsigned int len); 24 25 25 26
Note: See TracChangeset
for help on using the changeset viewer.