summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/yson_string/string.cpp
diff options
context:
space:
mode:
authoryurial <[email protected]>2023-11-16 13:59:02 +0300
committeryurial <[email protected]>2023-11-16 14:43:37 +0300
commita2fd00a24fcb20211418b797cb6191c4f1afa6ea (patch)
tree68e33195baef03090a66c0e3868c89bfd2268480 /library/cpp/yt/yson_string/string.cpp
parentcab414f768af417824e8def2b045b5f13c5e7931 (diff)
Support Save/Load TYsonString
Diffstat (limited to 'library/cpp/yt/yson_string/string.cpp')
-rw-r--r--library/cpp/yt/yson_string/string.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/library/cpp/yt/yson_string/string.cpp b/library/cpp/yt/yson_string/string.cpp
index dec428c31ef..164e450b72c 100644
--- a/library/cpp/yt/yson_string/string.cpp
+++ b/library/cpp/yt/yson_string/string.cpp
@@ -173,6 +173,28 @@ size_t TYsonString::ComputeHash() const
return THash<TStringBuf>()(TStringBuf(Begin_, Begin_ + Size_));
}
+void TYsonString::Save(IOutputStream* s) const
+{
+ EYsonType type = Type_;
+ if (*this) {
+ ::SaveMany(s, type, ToSharedRef());
+ } else {
+ ::SaveMany(s, type, TString());
+ }
+}
+
+void TYsonString::Load(IInputStream* s)
+{
+ EYsonType type;
+ TString data;
+ ::LoadMany(s, type, data);
+ if (data) {
+ *this = TYsonString(data, type);
+ } else {
+ *this = TYsonString();
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
TString ToString(const TYsonString& yson)