aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/yson_string/string.h
diff options
context:
space:
mode:
authorbabenko <babenko@yandex-team.ru>2022-02-10 16:49:19 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:19 +0300
commitf31097c96270919a1f49360bdaaa69ea4f3fefab (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/yt/yson_string/string.h
parentcec37806d8847aa3db53bafc9e251d4aaf325c12 (diff)
downloadydb-f31097c96270919a1f49360bdaaa69ea4f3fefab.tar.gz
Restoring authorship annotation for <babenko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yt/yson_string/string.h')
-rw-r--r--library/cpp/yt/yson_string/string.h210
1 files changed, 105 insertions, 105 deletions
diff --git a/library/cpp/yt/yson_string/string.h b/library/cpp/yt/yson_string/string.h
index cbe6810252..e13af37a6d 100644
--- a/library/cpp/yt/yson_string/string.h
+++ b/library/cpp/yt/yson_string/string.h
@@ -1,34 +1,34 @@
-#pragma once
-
-#include "public.h"
-
-#include <library/cpp/yt/memory/ref.h>
-
-#include <variant>
-
-namespace NYT::NYson {
-
-////////////////////////////////////////////////////////////////////////////////
-
-//! Contains a sequence of bytes in YSON encoding annotated with EYsonType describing
-//! the content. Could be null. Non-owning.
-class TYsonStringBuf
-{
-public:
- //! Constructs a null instance.
- TYsonStringBuf();
-
- //! Constructs an instance from TYsonString.
- TYsonStringBuf(const TYsonString& ysonString);
-
+#pragma once
+
+#include "public.h"
+
+#include <library/cpp/yt/memory/ref.h>
+
+#include <variant>
+
+namespace NYT::NYson {
+
+////////////////////////////////////////////////////////////////////////////////
+
+//! Contains a sequence of bytes in YSON encoding annotated with EYsonType describing
+//! the content. Could be null. Non-owning.
+class TYsonStringBuf
+{
+public:
+ //! Constructs a null instance.
+ TYsonStringBuf();
+
+ //! Constructs an instance from TYsonString.
+ TYsonStringBuf(const TYsonString& ysonString);
+
//! Constructs a non-null instance with given type and content.
- explicit TYsonStringBuf(
- const TString& data,
+ explicit TYsonStringBuf(
+ const TString& data,
EYsonType type = EYsonType::Node);
-
+
//! Constructs a non-null instance with given type and content.
- explicit TYsonStringBuf(
- TStringBuf data,
+ explicit TYsonStringBuf(
+ TStringBuf data,
EYsonType type = EYsonType::Node);
//! Constructs a non-null instance with given type and content
@@ -38,103 +38,103 @@ public:
const char* data,
EYsonType type = EYsonType::Node);
- //! Returns |true| if the instance is not null.
- explicit operator bool() const;
-
- //! Returns the underlying YSON bytes. The instance must be non-null.
- TStringBuf AsStringBuf() const;
-
- //! Returns type of YSON contained here. The instance must be non-null.
- EYsonType GetType() const;
-
+ //! Returns |true| if the instance is not null.
+ explicit operator bool() const;
+
+ //! Returns the underlying YSON bytes. The instance must be non-null.
+ TStringBuf AsStringBuf() const;
+
+ //! Returns type of YSON contained here. The instance must be non-null.
+ EYsonType GetType() const;
+
protected:
- TStringBuf Data_;
- EYsonType Type_;
+ TStringBuf Data_;
+ EYsonType Type_;
bool Null_;
};
-////////////////////////////////////////////////////////////////////////////////
-
-//! An owning version of TYsonStringBuf.
-/*!
- * Internally captures the data either via TString or a polymorphic ref-counted holder.
- */
+////////////////////////////////////////////////////////////////////////////////
+
+//! An owning version of TYsonStringBuf.
+/*!
+ * Internally captures the data either via TString or a polymorphic ref-counted holder.
+ */
class TYsonString
{
public:
- //! Constructs a null instance.
- TYsonString();
+ //! Constructs a null instance.
+ TYsonString();
- //! Constructs an instance from TYsonStringBuf.
- //! Copies the data into a ref-counted payload.
+ //! Constructs an instance from TYsonStringBuf.
+ //! Copies the data into a ref-counted payload.
explicit TYsonString(const TYsonStringBuf& ysonStringBuf);
- //! Constructs an instance from TStringBuf.
- //! Copies the data into a ref-counted payload.
- explicit TYsonString(
- TStringBuf data,
- EYsonType type = EYsonType::Node);
-
- //! Constructs an instance from TString.
+ //! Constructs an instance from TStringBuf.
+ //! Copies the data into a ref-counted payload.
+ explicit TYsonString(
+ TStringBuf data,
+ EYsonType type = EYsonType::Node);
+
+ //! Constructs an instance from TString.
//! Zero-copy for CoW TString: retains the reference to TString in payload.
- explicit TYsonString(
+ explicit TYsonString(
const TString& data,
- EYsonType type = EYsonType::Node);
-
- //! Constructs an instance from TSharedRef.
- //! Zero-copy; retains the reference to TSharedRef holder in payload.
- explicit TYsonString(
- const TSharedRef& ref,
- EYsonType type = EYsonType::Node);
-
- //! Returns |true| if the instance is not null.
- explicit operator bool() const;
-
- //! Returns type of YSON contained here. The instance must be non-null.
- EYsonType GetType() const;
-
- //! Returns the non-owning data. The instance must be non-null.
- TStringBuf AsStringBuf() const;
-
- //! Returns the data represented by TString. The instance must be non-null.
- //! Copies the data in case the payload is not TString.
- TString ToString() const;
-
- //! Computes the hash code.
- size_t ComputeHash() const;
-
-private:
- struct TNullPayload
- { };
-
+ EYsonType type = EYsonType::Node);
+
+ //! Constructs an instance from TSharedRef.
+ //! Zero-copy; retains the reference to TSharedRef holder in payload.
+ explicit TYsonString(
+ const TSharedRef& ref,
+ EYsonType type = EYsonType::Node);
+
+ //! Returns |true| if the instance is not null.
+ explicit operator bool() const;
+
+ //! Returns type of YSON contained here. The instance must be non-null.
+ EYsonType GetType() const;
+
+ //! Returns the non-owning data. The instance must be non-null.
+ TStringBuf AsStringBuf() const;
+
+ //! Returns the data represented by TString. The instance must be non-null.
+ //! Copies the data in case the payload is not TString.
+ TString ToString() const;
+
+ //! Computes the hash code.
+ size_t ComputeHash() const;
+
+private:
+ struct TNullPayload
+ { };
+
using THolder = TRefCountedPtr;
- std::variant<TNullPayload, THolder, TString> Payload_;
-
- const char* Begin_;
- ui64 Size_ : 56;
- EYsonType Type_ : 8;
-};
-
-////////////////////////////////////////////////////////////////////////////////
-
-bool operator == (const TYsonString& lhs, const TYsonString& rhs);
+ std::variant<TNullPayload, THolder, TString> Payload_;
+
+ const char* Begin_;
+ ui64 Size_ : 56;
+ EYsonType Type_ : 8;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+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 TYsonString& 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);
-
+
TString ToString(const TYsonString& yson);
TString ToString(const TYsonStringBuf& yson);
-
-////////////////////////////////////////////////////////////////////////////////
-
-} // namespace NYT::NYson
-
-#define STRING_INL_H_
-#include "string-inl.h"
-#undef STRING_INL_H_
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace NYT::NYson
+
+#define STRING_INL_H_
+#include "string-inl.h"
+#undef STRING_INL_H_