blob: 14e6d1d51f8c2657707c10ae8e3cc05987798116 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "case_insensitive_char_traits.h"
#include "case_insensitive_string.h"
#include <util/string/escape.h>
int TCaseInsensitiveCharTraits::compare(const char* s1, const char* s2, std::size_t n) {
while (n-- != 0) {
if (to_upper(*s1) < to_upper(*s2)) {
return -1;
}
if (to_upper(*s1) > to_upper(*s2)) {
return 1;
}
++s1;
++s2;
}
return 0;
}
const char* TCaseInsensitiveCharTraits::find(const char* s, std::size_t n, char a) {
auto const ua(to_upper(a));
while (n-- != 0) {
if (to_upper(*s) == ua)
return s;
s++;
}
return nullptr;
}
TCaseInsensitiveString EscapeC(const TCaseInsensitiveString& str) {
const auto result = EscapeC(str.data(), str.size());
return {result.data(), result.size()};
}
|