case_insensitive_string.cpp 645 B

12345678910111213141516171819202122
  1. #include "case_insensitive_string.h"
  2. #include <library/cpp/digest/murmur/murmur.h>
  3. size_t THash<TCaseInsensitiveStringBuf>::operator()(TCaseInsensitiveStringBuf str) const noexcept {
  4. TMurmurHash2A<size_t> hash;
  5. for (size_t i = 0; i < str.size(); ++i) {
  6. char lower = std::tolower(str[i]);
  7. hash.Update(&lower, 1);
  8. }
  9. return hash.Value();
  10. }
  11. template <>
  12. void Out<TCaseInsensitiveString>(IOutputStream& o, const TCaseInsensitiveString& p) {
  13. o.Write(p.data(), p.size());
  14. }
  15. template <>
  16. void Out<TCaseInsensitiveStringBuf>(IOutputStream& o, const TCaseInsensitiveStringBuf& p) {
  17. o.Write(p.data(), p.size());
  18. }