aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/event.h
diff options
context:
space:
mode:
authorMikhail Borisov <borisov.mikhail@gmail.com>2022-02-10 16:45:40 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:40 +0300
commit5d50718e66d9c037dc587a0211110b7d25a66185 (patch)
treee98df59de24d2ef7c77baed9f41e4875a2fef972 /library/cpp/yson_pull/event.h
parenta6a92afe03e02795227d2641b49819b687f088f8 (diff)
downloadydb-5d50718e66d9c037dc587a0211110b7d25a66185.tar.gz
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yson_pull/event.h')
-rw-r--r--library/cpp/yson_pull/event.h90
1 files changed, 45 insertions, 45 deletions
diff --git a/library/cpp/yson_pull/event.h b/library/cpp/yson_pull/event.h
index c8ecca7a45..b41d5ea3b5 100644
--- a/library/cpp/yson_pull/event.h
+++ b/library/cpp/yson_pull/event.h
@@ -1,13 +1,13 @@
-#pragma once
-
-#include "cyson_enums.h"
-#include "scalar.h"
-
-#include <util/generic/strbuf.h>
-#include <util/system/types.h>
-#include <util/system/yassert.h>
-
-namespace NYsonPull {
+#pragma once
+
+#include "cyson_enums.h"
+#include "scalar.h"
+
+#include <util/generic/strbuf.h>
+#include <util/system/types.h>
+#include <util/system/yassert.h>
+
+namespace NYsonPull {
//! A well-formed decoded YSON stream can be described by the following grammar:
//!
//! STREAM[node] ::= begin_stream VALUE end_stream
@@ -21,65 +21,65 @@ namespace NYsonPull {
//! VALUE_NOATTR ::= scalar(Scalar) | LIST | MAP
//! LIST ::= begin_list LIST_FRAGMENT end_list
//! MAP ::= begin_map MAP_FRAGMENT end_map
-
+
//! \brief YSON event type tag. Corresponds to YSON grammar.
enum class EEventType {
- BeginStream = YSON_EVENT_BEGIN_STREAM,
- EndStream = YSON_EVENT_END_STREAM,
- BeginList = YSON_EVENT_BEGIN_LIST,
- EndList = YSON_EVENT_END_LIST,
- BeginMap = YSON_EVENT_BEGIN_MAP,
- EndMap = YSON_EVENT_END_MAP,
- BeginAttributes = YSON_EVENT_BEGIN_ATTRIBUTES,
- EndAttributes = YSON_EVENT_END_ATTRIBUTES,
- Key = YSON_EVENT_KEY,
- Scalar = YSON_EVENT_SCALAR,
+ BeginStream = YSON_EVENT_BEGIN_STREAM,
+ EndStream = YSON_EVENT_END_STREAM,
+ BeginList = YSON_EVENT_BEGIN_LIST,
+ EndList = YSON_EVENT_END_LIST,
+ BeginMap = YSON_EVENT_BEGIN_MAP,
+ EndMap = YSON_EVENT_END_MAP,
+ BeginAttributes = YSON_EVENT_BEGIN_ATTRIBUTES,
+ EndAttributes = YSON_EVENT_END_ATTRIBUTES,
+ Key = YSON_EVENT_KEY,
+ Scalar = YSON_EVENT_SCALAR,
};
-
+
//! \brief YSON event variant type.
class TEvent {
- EEventType Type_;
- TScalar Value_;
-
+ EEventType Type_;
+ TScalar Value_;
+
public:
//! \brief Construct a tag-only event.
- explicit constexpr TEvent(EEventType type = EEventType::BeginStream)
- : Type_{type} {
+ explicit constexpr TEvent(EEventType type = EEventType::BeginStream)
+ : Type_{type} {
}
-
+
//! \brief Construct a tag+value event.
//!
//! Only \p EEventType::key is meaningful.
constexpr TEvent(EEventType type, const TScalar& value)
- : Type_{type}
- , Value_{value} {
+ : Type_{type}
+ , Value_{value} {
}
-
+
//! \brief Construct a \p EEventType::scalar event.
explicit constexpr TEvent(const TScalar& value)
- : Type_{EEventType::Scalar}
- , Value_{value} {
+ : Type_{EEventType::Scalar}
+ , Value_{value} {
}
-
- EEventType Type() const {
- return Type_;
+
+ EEventType Type() const {
+ return Type_;
}
-
+
//! \brief Get TScalar value.
//!
//! Undefined behaviour when event type is not \p EEventType::scalar.
- const TScalar& AsScalar() const {
- Y_ASSERT(Type_ == EEventType::Scalar || Type_ == EEventType::Key);
- return Value_;
+ const TScalar& AsScalar() const {
+ Y_ASSERT(Type_ == EEventType::Scalar || Type_ == EEventType::Key);
+ return Value_;
}
-
+
//! \brief Get string value.
//!
//! Undefined behaviour when event type is not \p EEventType::key.
- TStringBuf AsString() const {
- Y_ASSERT(Type_ == EEventType::Key || (Type_ == EEventType::Scalar && Value_.Type() == EScalarType::String));
- return Value_.AsString();
+ TStringBuf AsString() const {
+ Y_ASSERT(Type_ == EEventType::Key || (Type_ == EEventType::Scalar && Value_.Type() == EScalarType::String));
+ return Value_.AsString();
}
};
-
+
}