MCPcopy Create free account
hub / github.com/catboost/catboost / TYsonString

Class TYsonString

library/cpp/yt/yson_string/string.h:66–127  ·  view source on GitHub ↗

An owning version of TYsonStringBuf. ! * Internally captures the data either via TCowString or a polymorphic ref-counted holder. */

Source from the content-addressed store, hash-verified

64 * Internally captures the data either via TCowString or a polymorphic ref-counted holder.
65 */
66class TYsonString
67{
68public:
69 //! Constructs a null instance.
70 TYsonString();
71
72 //! Constructs an instance from TYsonStringBuf.
73 //! Copies the data into a ref-counted payload.
74 explicit TYsonString(const TYsonStringBuf& ysonStringBuf);
75
76 //! Constructs an instance from TStringBuf.
77 //! Copies the data into a ref-counted payload.
78 explicit TYsonString(
79 TStringBuf data,
80 EYsonType type = EYsonType::Node);
81
82 //! Constructs an instance from TString.
83 //! Zero-copy for CoW TString: retains the reference to TString in payload.
84 explicit TYsonString(
85 const TString& data,
86 EYsonType type = EYsonType::Node);
87
88 //! Constructs an instance from TSharedRef.
89 //! Zero-copy; retains the reference to TSharedRef holder in payload.
90 explicit TYsonString(
91 const TSharedRef& ref,
92 EYsonType type = EYsonType::Node);
93
94 //! Returns |true| if the instance is not null.
95 explicit operator bool() const;
96
97 //! Returns type of YSON contained here. The instance must be non-null.
98 EYsonType GetType() const;
99
100 //! Returns the non-owning data. The instance must be non-null.
101 TStringBuf AsStringBuf() const;
102
103 //! Returns the data represented by TString. The instance must be non-null.
104 //! Copies the data in case the payload is not TString.
105 TString ToString() const;
106
107 //! Returns the data represented by TSharedRef. The instance must be non-null.
108 //! The data is never copied.
109 TSharedRef ToSharedRef() const;
110
111 //! Computes the hash code.
112 size_t ComputeHash() const;
113
114 //! Allow to serialize/deserialize using the ::Save ::Load functions. See util/ysaveload.h.
115 void Save(IOutputStream* s) const;
116 void Load(IInputStream* s);
117
118private:
119 struct TNullPayload
120 { };
121
122 std::variant<TNullPayload, TSharedRangeHolderPtr, TCowString> Payload_;
123

Callers 7

ConvertToYsonString<i64>Function · 0.70
LoadMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected