diff options
author | babenko <babenko@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:19 +0300 |
commit | f31097c96270919a1f49360bdaaa69ea4f3fefab (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/yt/yson_string/string-inl.h | |
parent | cec37806d8847aa3db53bafc9e251d4aaf325c12 (diff) | |
download | ydb-f31097c96270919a1f49360bdaaa69ea4f3fefab.tar.gz |
Restoring authorship annotation for <babenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yt/yson_string/string-inl.h')
-rw-r--r-- | library/cpp/yt/yson_string/string-inl.h | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/library/cpp/yt/yson_string/string-inl.h b/library/cpp/yt/yson_string/string-inl.h index 11e8af65a2..5c41629cc0 100644 --- a/library/cpp/yt/yson_string/string-inl.h +++ b/library/cpp/yt/yson_string/string-inl.h @@ -1,93 +1,93 @@ -#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 - -namespace NYT::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 TYsonString& lhs, const TYsonString& rhs) -{ - return NDetail::Equals(lhs, rhs); -} - -inline bool operator == (const TYsonString& lhs, const TYsonStringBuf& rhs) -{ - return NDetail::Equals(lhs, rhs); -} - -inline bool operator == (const TYsonStringBuf& lhs, const TYsonString& rhs) -{ - return NDetail::Equals(lhs, rhs); -} - -inline bool operator == (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs) -{ - return NDetail::Equals(lhs, rhs); -} - -inline bool operator != (const TYsonString& lhs, const TYsonString& rhs) -{ - return !(lhs == rhs); -} - -inline bool operator != (const TYsonString& lhs, const TYsonStringBuf& rhs) -{ - return !(lhs == rhs); -} - -inline bool operator != (const TYsonStringBuf& lhs, const TYsonString& rhs) -{ - return !(lhs == rhs); -} - -inline bool operator != (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs) -{ - return !(lhs == rhs); -} - -//////////////////////////////////////////////////////////////////////////////// - -} // namespace NYT::NYson - -//! A hasher for TYsonString -template <> -struct THash<NYT::NYson::TYsonString> -{ - size_t operator () (const NYT::NYson::TYsonString& str) const - { - return str.ComputeHash(); - } -}; - -//! A hasher for TYsonStringBuf -template <> -struct THash<NYT::NYson::TYsonStringBuf> -{ - size_t operator () (const NYT::NYson::TYsonStringBuf& str) const - { - return THash<TStringBuf>()(str.AsStringBuf()); - } -}; +#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 + +namespace NYT::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 TYsonString& lhs, const TYsonString& rhs) +{ + return NDetail::Equals(lhs, rhs); +} + +inline bool operator == (const TYsonString& lhs, const TYsonStringBuf& rhs) +{ + return NDetail::Equals(lhs, rhs); +} + +inline bool operator == (const TYsonStringBuf& lhs, const TYsonString& rhs) +{ + return NDetail::Equals(lhs, rhs); +} + +inline bool operator == (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs) +{ + return NDetail::Equals(lhs, rhs); +} + +inline bool operator != (const TYsonString& lhs, const TYsonString& rhs) +{ + return !(lhs == rhs); +} + +inline bool operator != (const TYsonString& lhs, const TYsonStringBuf& rhs) +{ + return !(lhs == rhs); +} + +inline bool operator != (const TYsonStringBuf& lhs, const TYsonString& rhs) +{ + return !(lhs == rhs); +} + +inline bool operator != (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs) +{ + return !(lhs == rhs); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT::NYson + +//! A hasher for TYsonString +template <> +struct THash<NYT::NYson::TYsonString> +{ + size_t operator () (const NYT::NYson::TYsonString& str) const + { + return str.ComputeHash(); + } +}; + +//! A hasher for TYsonStringBuf +template <> +struct THash<NYT::NYson::TYsonStringBuf> +{ + size_t operator () (const NYT::NYson::TYsonStringBuf& str) const + { + return THash<TStringBuf>()(str.AsStringBuf()); + } +}; |