| 164 | } |
| 165 | |
| 166 | bool hasPrefix(const std::string_view& str, size_t index, const char* term) { |
| 167 | if (index >= str.size()) { |
| 168 | return false; |
| 169 | } |
| 170 | |
| 171 | const auto* cStr = str.data() + index; |
| 172 | const auto* current = term; |
| 173 | while (*current != '\0') { |
| 174 | if (*cStr != *current) { |
| 175 | return false; |
| 176 | } |
| 177 | |
| 178 | cStr++; |
| 179 | current++; |
| 180 | } |
| 181 | |
| 182 | return true; |
| 183 | } |
| 184 | |
| 185 | bool hasSuffix(const std::string_view& str, const char* term) { |
| 186 | auto termLength = strlen(term); |