Merge pull request #172 from shenweip/patch-3

Add strcmpIgnore func.
This commit is contained in:
Henrik Rydgård 2013-11-18 10:36:53 -08:00
commit 74e412ffd7
2 changed files with 9 additions and 0 deletions

View File

@ -233,4 +233,10 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
pos += dest.size();
}
return result;
}
int strcmpIgnore(std::string str1, std::string str2, std::string ignorestr1, std::string ignorestr2) {
str1 = ReplaceAll(str1, ignorestr1, ignorestr2);
str2 = ReplaceAll(str2, ignorestr1, ignorestr2);
return strcmp(str1.c_str(),str2.c_str());
}

View File

@ -133,6 +133,9 @@ void SplitString(const std::string& str, const char delim, std::vector<std::stri
std::string ReplaceAll(std::string input, const std::string& src, const std::string& dest);
// Compare two strings, ignore the difference between the ignorestr1 and the ignorestr2 in str1 and str2.
int strcmpIgnore(std::string str1, std::string str2, std::string ignorestr1, std::string ignorestr2);
template <typename N>
static std::string ValueToString(const N value)
{