aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/event.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /library/cpp/yson_pull/event.h
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yson_pull/event.h')
-rw-r--r--library/cpp/yson_pull/event.h80
1 files changed, 40 insertions, 40 deletions
diff --git a/library/cpp/yson_pull/event.h b/library/cpp/yson_pull/event.h
index c141b06889..b41d5ea3b5 100644
--- a/library/cpp/yson_pull/event.h
+++ b/library/cpp/yson_pull/event.h
@@ -8,22 +8,22 @@
#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
- //! STREAM[list_fragment] ::= begin_stream LIST_FRAGMENT end_stream
- //! STREAM[map_fragment] ::= begin_stream MAP_FRAGMENT end_stream
- //! LIST_FRAGMENT ::= { VALUE; }
- //! MAP_FRAGMENT ::= { KEY VALUE; }
- //! KEY ::= key(String)
- //! VALUE ::= VALUE_NOATTR | ATTRIBUTES VALUE_NOATTR
- //! ATTRIBUTES ::= begin_attributes MAP_FRAGMENT end_attributes
- //! VALUE_NOATTR ::= scalar(Scalar) | LIST | MAP
- //! LIST ::= begin_list LIST_FRAGMENT end_list
- //! MAP ::= begin_map MAP_FRAGMENT end_map
+ //! A well-formed decoded YSON stream can be described by the following grammar:
+ //!
+ //! STREAM[node] ::= begin_stream VALUE end_stream
+ //! STREAM[list_fragment] ::= begin_stream LIST_FRAGMENT end_stream
+ //! STREAM[map_fragment] ::= begin_stream MAP_FRAGMENT end_stream
+ //! LIST_FRAGMENT ::= { VALUE; }
+ //! MAP_FRAGMENT ::= { KEY VALUE; }
+ //! KEY ::= key(String)
+ //! VALUE ::= VALUE_NOATTR | ATTRIBUTES VALUE_NOATTR
+ //! ATTRIBUTES ::= begin_attributes MAP_FRAGMENT end_attributes
+ //! 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 {
+ //! \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,
@@ -34,52 +34,52 @@ namespace NYsonPull {
EndAttributes = YSON_EVENT_END_ATTRIBUTES,
Key = YSON_EVENT_KEY,
Scalar = YSON_EVENT_SCALAR,
- };
+ };
- //! \brief YSON event variant type.
- class TEvent {
+ //! \brief YSON event variant type.
+ class TEvent {
EEventType Type_;
TScalar Value_;
- public:
- //! \brief Construct a tag-only event.
+ public:
+ //! \brief Construct a tag-only event.
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)
+ //! \brief Construct a tag+value event.
+ //!
+ //! Only \p EEventType::key is meaningful.
+ constexpr TEvent(EEventType type, const TScalar& value)
: Type_{type}
, Value_{value} {
- }
+ }
- //! \brief Construct a \p EEventType::scalar event.
- explicit constexpr TEvent(const TScalar& value)
+ //! \brief Construct a \p EEventType::scalar event.
+ explicit constexpr TEvent(const TScalar& value)
: Type_{EEventType::Scalar}
, Value_{value} {
- }
+ }
EEventType Type() const {
return Type_;
- }
+ }
- //! \brief Get TScalar value.
- //!
- //! Undefined behaviour when event type is not \p EEventType::scalar.
+ //! \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_;
- }
+ }
- //! \brief Get string value.
- //!
- //! Undefined behaviour when event type is not \p EEventType::key.
+ //! \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();
- }
- };
+ }
+ };
-}
+}