summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-11-03 10:18:25 -0700
committerJared Adams <jaxad0127@gmail.com>2009-11-03 10:18:25 -0700
commitacd557f9472c711fe92b9c158ec336abf688bf7b (patch)
tree2295d13589411ee88afe16f4997bea65b4ebba94 /src/utils
parentc60d3a98dbbb20621742bfd82bbaaa6b7085a8ae (diff)
downloadmana-client-acd557f9472c711fe92b9c158ec336abf688bf7b.tar.gz
mana-client-acd557f9472c711fe92b9c158ec336abf688bf7b.tar.bz2
mana-client-acd557f9472c711fe92b9c158ec336abf688bf7b.tar.xz
mana-client-acd557f9472c711fe92b9c158ec336abf688bf7b.zip
Remove more _SUPPORT ifdefs and do some cleanup
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/stringutils.cpp17
-rw-r--r--src/utils/stringutils.h10
2 files changed, 27 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 64d928d6..adcedaa1 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -117,3 +117,20 @@ std::string removeColors(std::string msg)
}
return msg;
}
+
+int compareStrI(const std::string &a, const std::string &b)
+{
+ std::string::const_iterator itA = a.begin();
+ std::string::const_iterator endA = a.end();
+ std::string::const_iterator itB = b.begin();
+ std::string::const_iterator endB = b.end();
+
+ for (; itA < endA, itB < endB; ++itA, ++itB)
+ {
+ int comp = tolower(*itA) - tolower(*itB);
+ if (comp)
+ return comp;
+ }
+
+ return 0;
+}
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index ae105c6c..a0e766fb 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -100,4 +100,14 @@ std::string &removeBadChars(std::string &str);
*/
std::string removeColors(std::string msg);
+/**
+ * Compares the two strings case-insensitively.
+ *
+ * @param a the first string in the comparison
+ * @param b the second string in the comparison
+ * @return 0 if the strings are equal, positive if the first is greater,
+ * negative if the second is greater
+ */
+int compareStrI(const std::string &a, const std::string &b);
+
#endif // UTILS_STRINGUTILS_H