diff options
author | nadya73 <nadya73@yandex-team.ru> | 2022-02-10 16:49:18 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:18 +0300 |
commit | b6e35c760e81fe851ac4da1abc08e6ec8e779c10 (patch) | |
tree | bffcb657a262b70deabd6a12cf65b823c9332150 /library/cpp/yson/string-inl.h | |
parent | cb691264f012c552bac85a9fe352baa062cd81dd (diff) | |
download | ydb-b6e35c760e81fe851ac4da1abc08e6ec8e779c10.tar.gz |
Restoring authorship annotation for <nadya73@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yson/string-inl.h')
-rw-r--r-- | library/cpp/yson/string-inl.h | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/library/cpp/yson/string-inl.h b/library/cpp/yson/string-inl.h index 92e9ab4531..a730079387 100644 --- a/library/cpp/yson/string-inl.h +++ b/library/cpp/yson/string-inl.h @@ -1,57 +1,57 @@ -#pragma once - -#ifndef STRING_INL_H_ -#error "Direct inclusion of this file is not allowed, include string.h" -// For the sake of sane code completion. -#include "string.h" -#endif - -#include <util/str_stl.h> - -namespace NYson { - -//////////////////////////////////////////////////////////////////////////////// - -namespace NDetail { - -template <typename TLeft, typename TRight> -bool Equals(const TLeft& lhs, const TRight& rhs) -{ - auto lhsNull = !lhs.operator bool(); - auto rhsNull = !rhs.operator bool(); - if (lhsNull != rhsNull) { - return false; - } - if (lhsNull && rhsNull) { - return true; - } - return - lhs.AsStringBuf() == rhs.AsStringBuf() && - lhs.GetType() == rhs.GetType(); -} - -} // namespace NDetail - -inline bool operator == (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs) -{ - return NDetail::Equals(lhs, rhs); -} - -inline bool operator != (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs) -{ - return !(lhs == rhs); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYson - -//! A hasher for TYsonStringBuf -template <> -struct THash<NYson::TYsonStringBuf> -{ - size_t operator () (const NYson::TYsonStringBuf& str) const - { - return THash<TStringBuf>()(str.AsStringBuf()); - } -}; +#pragma once + +#ifndef STRING_INL_H_ +#error "Direct inclusion of this file is not allowed, include string.h" +// For the sake of sane code completion. +#include "string.h" +#endif + +#include <util/str_stl.h> + +namespace NYson { + +//////////////////////////////////////////////////////////////////////////////// + +namespace NDetail { + +template <typename TLeft, typename TRight> +bool Equals(const TLeft& lhs, const TRight& rhs) +{ + auto lhsNull = !lhs.operator bool(); + auto rhsNull = !rhs.operator bool(); + if (lhsNull != rhsNull) { + return false; + } + if (lhsNull && rhsNull) { + return true; + } + return + lhs.AsStringBuf() == rhs.AsStringBuf() && + lhs.GetType() == rhs.GetType(); +} + +} // namespace NDetail + +inline bool operator == (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs) +{ + return NDetail::Equals(lhs, rhs); +} + +inline bool operator != (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs) +{ + return !(lhs == rhs); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYson + +//! A hasher for TYsonStringBuf +template <> +struct THash<NYson::TYsonStringBuf> +{ + size_t operator () (const NYson::TYsonStringBuf& str) const + { + return THash<TStringBuf>()(str.AsStringBuf()); + } +}; |