MCPcopy Create free account
hub / github.com/Persper/code-analytics / Equal

Function Equal

test/cpp_test_repo/D/Utility.cpp:9–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#define _DECLARE_ENUM_DEFAULT(TYPE) default : return string(#TYPE) + "::" + to_string((long)v);
8
9bool Equal(const string& lhs, const string& rhs, StringComparison comparision)
10{
11 if (&lhs == &rhs) return true;
12 size_t pos1 = 0, pos2 = 0;
13 size_t pos1r = lhs.size(), pos2r = rhs.size();
14 if ((comparision & StringComparison::IgnoreSurroudingWhiteSpaces)
15 == StringComparison::IgnoreSurroudingWhiteSpaces)
16 {
17 while (pos1 < lhs.size() && isspace(lhs[pos1])) pos1++;
18 while (pos2 < lhs.size() && isspace(lhs[pos2])) pos2++;
19 while (pos1 > 0 && isspace(lhs[pos1 - 1])) pos1--;
20 while (pos2 > 0 && isspace(lhs[pos2 - 1])) pos2--;
21 }
22 if (pos1r - pos1 != pos2r - pos2) return false;
23 auto ignoreCase = (comparision & StringComparison::IgnoureCase) == StringComparison::IgnoureCase;
24 while (pos1 < pos1r)
25 {
26 if (ignoreCase)
27 {
28 if (tolower(lhs[pos1]) != tolower(rhs[pos1])) return false;
29 } else
30 {
31 if (lhs[pos1] != rhs[pos1]) return false;
32 }
33 pos1++;
34 pos2++;
35 }
36 return true;
37}
38
39bool Confirm(const std::string& prompt)
40{

Callers 2

GetBoolMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected