Compare a TextView to a nul-termimated string, converting the TextView to lower case and ignoring whitespace in it.
| 96 | // Compare a TextView to a nul-termimated string, converting the TextView to lower case and ignoring whitespace in it. |
| 97 | // |
| 98 | bool |
| 99 | eqIgnoreCaseWs(swoc::TextView sv, const char *target) |
| 100 | { |
| 101 | const char *s = sv.data(); |
| 102 | |
| 103 | std::size_t skip = 0; |
| 104 | std::size_t i = 0; |
| 105 | |
| 106 | while ((i + skip) < sv.size()) { |
| 107 | if (std::isspace(s[i + skip])) { |
| 108 | ++skip; |
| 109 | } else if (std::tolower(s[i + skip]) != target[i]) { |
| 110 | return false; |
| 111 | } else { |
| 112 | ++i; |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | return target[i] == '\0'; |
| 117 | } |
| 118 | |
| 119 | } // end anonymous namespace |
| 120 |
no test coverage detected