diff options
author | Vlad Yaroslavlev <vladon@vladon.com> | 2022-02-10 16:46:23 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:23 +0300 |
commit | 706b83ed7de5a473436620367af31fc0ceecde07 (patch) | |
tree | 103305d30dec77e8f6367753367f59b3cd68f9f1 /library/cpp/charset/ci_string.cpp | |
parent | 918e8a1574070d0ec733f0b76cfad8f8892ad2e5 (diff) | |
download | ydb-706b83ed7de5a473436620367af31fc0ceecde07.tar.gz |
Restoring authorship annotation for Vlad Yaroslavlev <vladon@vladon.com>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/charset/ci_string.cpp')
-rw-r--r-- | library/cpp/charset/ci_string.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/library/cpp/charset/ci_string.cpp b/library/cpp/charset/ci_string.cpp index 6097e40131..9efa3e21cd 100644 --- a/library/cpp/charset/ci_string.cpp +++ b/library/cpp/charset/ci_string.cpp @@ -1,41 +1,41 @@ -#include "ci_string.h" - -int TCiString::compare(const TCiString& s1, const TCiString& s2, const CodePage& cp) { +#include "ci_string.h" + +int TCiString::compare(const TCiString& s1, const TCiString& s2, const CodePage& cp) { return cp.stricmp(s1.data(), s2.data()); -} - -int TCiString::compare(const char* p, const TCiString& s2, const CodePage& cp) { +} + +int TCiString::compare(const char* p, const TCiString& s2, const CodePage& cp) { return cp.stricmp(p, s2.data()); -} - -int TCiString::compare(const TCiString& s1, const char* p, const CodePage& cp) { +} + +int TCiString::compare(const TCiString& s1, const char* p, const CodePage& cp) { return cp.stricmp(s1.data(), p); -} - +} + int TCiString::compare(const TStringBuf& p1, const TStringBuf& p2, const CodePage& cp) { int rv = cp.strnicmp(p1.data(), p2.data(), Min(p1.size(), p2.size())); return rv ? rv : p1.size() < p2.size() ? -1 : p1.size() == p2.size() ? 0 : 1; -} - +} + bool TCiString::is_prefix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp) { size_t len = what.size(); return len <= of.size() && cp.strnicmp(what.data(), of.data(), len) == 0; -} - +} + bool TCiString::is_suffix(const TStringBuf& what, const TStringBuf& of, const CodePage& cp) { size_t len = what.size(); size_t slen = of.size(); return (len <= slen) && (0 == cp.strnicmp(what.data(), of.data() + slen - len, len)); -} - -size_t TCiString::hashVal(const char* s, size_t len, const CodePage& cp) { - size_t h = len; - for (; /* (*s) && */ len--; ++s) - h = 5 * h + cp.ToLower(*s); - return h; -} - -template <> +} + +size_t TCiString::hashVal(const char* s, size_t len, const CodePage& cp) { + size_t h = len; + for (; /* (*s) && */ len--; ++s) + h = 5 * h + cp.ToLower(*s); + return h; +} + +template <> void Out<TCiString>(IOutputStream& o, const TCiString& p) { o.Write(p.data(), p.size()); -} +} |