diff options
author | levysotsky <levysotsky@yandex-team.ru> | 2022-02-10 16:47:29 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:29 +0300 |
commit | 57f874ffc2a75047c1c4fea7a9fc86cb0f56ed50 (patch) | |
tree | ba6454f353979bb4bafaf230cafdf3e02ea120b2 /library/cpp/yt/yson_string | |
parent | 23d4769f0fea97cfb1028710e50f2b5ecd0ac2c0 (diff) | |
download | ydb-57f874ffc2a75047c1c4fea7a9fc86cb0f56ed50.tar.gz |
Restoring authorship annotation for <levysotsky@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yt/yson_string')
-rw-r--r-- | library/cpp/yt/yson_string/string.cpp | 38 | ||||
-rw-r--r-- | library/cpp/yt/yson_string/string.h | 38 |
2 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/yt/yson_string/string.cpp b/library/cpp/yt/yson_string/string.cpp index 99d45e8616..c00aa98a50 100644 --- a/library/cpp/yt/yson_string/string.cpp +++ b/library/cpp/yt/yson_string/string.cpp @@ -99,8 +99,8 @@ TYsonString::TYsonString( TStringBuf data, EYsonType type) : TYsonString(TYsonStringBuf(data, type)) -{ } - +{ } + #ifdef TSTRING_IS_STD_STRING TYsonString::TYsonString( const TString& data, @@ -120,7 +120,7 @@ TYsonString::TYsonString( Type_ = type; } #endif - + TYsonString::TYsonString( const TSharedRef& data, EYsonType type) @@ -134,22 +134,22 @@ TYsonString::TYsonString( TYsonString::operator bool() const { return !std::holds_alternative<TNullPayload>(Payload_); -} - +} + EYsonType TYsonString::GetType() const -{ +{ YT_VERIFY(*this); return Type_; } TStringBuf TYsonString::AsStringBuf() const -{ +{ YT_VERIFY(*this); return TStringBuf(Begin_, Begin_ + Size_); -} - +} + TString TYsonString::ToString() const -{ +{ return Visit( Payload_, [] (const TNullPayload&) -> TString { @@ -161,13 +161,13 @@ TString TYsonString::ToString() const [] (const TString& payload) { return payload; }); -} - +} + size_t TYsonString::ComputeHash() const -{ +{ return THash<TStringBuf>()(TStringBuf(Begin_, Begin_ + Size_)); -} - +} + //////////////////////////////////////////////////////////////////////////////// TString ToString(const TYsonString& yson) @@ -175,11 +175,11 @@ TString ToString(const TYsonString& yson) return yson.ToString(); } -TString ToString(const TYsonStringBuf& yson) -{ +TString ToString(const TYsonStringBuf& yson) +{ return TString(yson.AsStringBuf()); -} - +} + //////////////////////////////////////////////////////////////////////////////// } // namespace NYT::NYson diff --git a/library/cpp/yt/yson_string/string.h b/library/cpp/yt/yson_string/string.h index e13af37a6d..b25223aa6c 100644 --- a/library/cpp/yt/yson_string/string.h +++ b/library/cpp/yt/yson_string/string.h @@ -47,28 +47,28 @@ public: //! Returns type of YSON contained here. The instance must be non-null. EYsonType GetType() const; -protected: +protected: TStringBuf Data_; EYsonType Type_; - bool Null_; -}; - + bool Null_; +}; + //////////////////////////////////////////////////////////////////////////////// //! An owning version of TYsonStringBuf. /*! * Internally captures the data either via TString or a polymorphic ref-counted holder. */ -class TYsonString -{ -public: +class TYsonString +{ +public: //! Constructs a null instance. TYsonString(); - + //! Constructs an instance from TYsonStringBuf. //! Copies the data into a ref-counted payload. - explicit TYsonString(const TYsonStringBuf& ysonStringBuf); - + explicit TYsonString(const TYsonStringBuf& ysonStringBuf); + //! Constructs an instance from TStringBuf. //! Copies the data into a ref-counted payload. explicit TYsonString( @@ -108,7 +108,7 @@ private: { }; using THolder = TRefCountedPtr; - + std::variant<TNullPayload, THolder, TString> Payload_; const char* Begin_; @@ -119,17 +119,17 @@ private: //////////////////////////////////////////////////////////////////////////////// bool operator == (const TYsonString& lhs, const TYsonString& rhs); -bool operator == (const TYsonString& lhs, const TYsonStringBuf& rhs); -bool operator == (const TYsonStringBuf& lhs, const TYsonString& rhs); -bool operator == (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs); - +bool operator == (const TYsonString& lhs, const TYsonStringBuf& rhs); +bool operator == (const TYsonStringBuf& lhs, const TYsonString& rhs); +bool operator == (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs); + bool operator != (const TYsonString& lhs, const TYsonString& rhs); -bool operator != (const TYsonString& lhs, const TYsonStringBuf& rhs); -bool operator != (const TYsonStringBuf& lhs, const TYsonString& rhs); -bool operator != (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs); +bool operator != (const TYsonString& lhs, const TYsonStringBuf& rhs); +bool operator != (const TYsonStringBuf& lhs, const TYsonString& rhs); +bool operator != (const TYsonStringBuf& lhs, const TYsonStringBuf& rhs); TString ToString(const TYsonString& yson); -TString ToString(const TYsonStringBuf& yson); +TString ToString(const TYsonStringBuf& yson); //////////////////////////////////////////////////////////////////////////////// |