diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/yson_pull/read_ops.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/yson_pull/read_ops.h')
-rw-r--r-- | library/cpp/yson_pull/read_ops.h | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/library/cpp/yson_pull/read_ops.h b/library/cpp/yson_pull/read_ops.h index 5c084983ea..51e619c3c6 100644 --- a/library/cpp/yson_pull/read_ops.h +++ b/library/cpp/yson_pull/read_ops.h @@ -20,22 +20,22 @@ * */ -namespace NYsonPull { - namespace NReadOps { - class TExpectationFailure: public TWithBackTrace<yexception> { +namespace NYsonPull { + namespace NReadOps { + class TExpectationFailure: public TWithBackTrace<yexception> { }; - inline void Expect(const TEvent& got, EEventType expected) { + inline void Expect(const TEvent& got, EEventType expected) { Y_ENSURE_EX( got.Type() == expected, TExpectationFailure() << "expected " << expected << ", got " << got); - } + } - inline void Expect(const TScalar& got, EScalarType expected) { + inline void Expect(const TScalar& got, EScalarType expected) { Y_ENSURE_EX( got.Type() == expected, TExpectationFailure() << "expected scalar " << expected << ", got " << got); - } + } // ExpectBegin{X} functions verify that last event WAS X // SkipBegin{X} functions verify that next event WILL BE X and CONSUME it @@ -48,95 +48,95 @@ namespace NYsonPull { Expect(reader.NextEvent(), EEventType::BeginStream); } - inline void ExpectBeginMap(TReader& reader) { + inline void ExpectBeginMap(TReader& reader) { Expect(reader.LastEvent(), EEventType::BeginMap); - } + } - inline void SkipBeginMap(TReader& reader) { + inline void SkipBeginMap(TReader& reader) { Expect(reader.NextEvent(), EEventType::BeginMap); - } + } - inline void ExpectBeginList(TReader& reader) { + inline void ExpectBeginList(TReader& reader) { Expect(reader.LastEvent(), EEventType::BeginList); - } + } - inline void SkipBeginList(TReader& reader) { + inline void SkipBeginList(TReader& reader) { Expect(reader.NextEvent(), EEventType::BeginList); - } + } - inline bool ReadListItem(TReader& reader) { + inline bool ReadListItem(TReader& reader) { return reader.NextEvent().Type() != EEventType::EndList; - } + } - inline TMaybe<TStringBuf> ReadKey(TReader& reader) { + inline TMaybe<TStringBuf> ReadKey(TReader& reader) { const auto& event = reader.NextEvent(); switch (event.Type()) { case EEventType::Key: return event.AsString(); case EEventType::EndMap: - return Nothing(); - default: - ythrow yexception() << "Unexpected event: " << event; - } - } + return Nothing(); + default: + ythrow yexception() << "Unexpected event: " << event; + } + } - template <typename T = const TScalar&> - inline T ReadScalar(TReader& reader); + template <typename T = const TScalar&> + inline T ReadScalar(TReader& reader); - template <> - inline const TScalar& ReadScalar<const TScalar&>(TReader& reader) { + template <> + inline const TScalar& ReadScalar<const TScalar&>(TReader& reader) { const auto& event = reader.NextEvent(); Expect(event, EEventType::Scalar); return event.AsScalar(); - } + } - template <> - inline i64 ReadScalar<i64>(TReader& reader) { - const auto& scalar = ReadScalar(reader); + template <> + inline i64 ReadScalar<i64>(TReader& reader) { + const auto& scalar = ReadScalar(reader); Expect(scalar, EScalarType::Int64); return scalar.AsInt64(); - } + } - template <> - inline ui64 ReadScalar<ui64>(TReader& reader) { - const auto& scalar = ReadScalar(reader); + template <> + inline ui64 ReadScalar<ui64>(TReader& reader) { + const auto& scalar = ReadScalar(reader); Expect(scalar, EScalarType::UInt64); return scalar.AsUInt64(); - } + } - template <> - inline double ReadScalar<double>(TReader& reader) { - const auto& scalar = ReadScalar(reader); + template <> + inline double ReadScalar<double>(TReader& reader) { + const auto& scalar = ReadScalar(reader); Expect(scalar, EScalarType::Float64); return scalar.AsFloat64(); - } + } - template <> - inline TStringBuf ReadScalar<TStringBuf>(TReader& reader) { - const auto& scalar = ReadScalar(reader); + template <> + inline TStringBuf ReadScalar<TStringBuf>(TReader& reader) { + const auto& scalar = ReadScalar(reader); Expect(scalar, EScalarType::String); return scalar.AsString(); - } + } - template <> + template <> inline TString ReadScalar<TString>(TReader& reader) { return TString(ReadScalar<TStringBuf>(reader)); - } + } - template <> - inline bool ReadScalar<bool>(TReader& reader) { - const auto& scalar = ReadScalar(reader); + template <> + inline bool ReadScalar<bool>(TReader& reader) { + const auto& scalar = ReadScalar(reader); Expect(scalar, EScalarType::Boolean); return scalar.AsBoolean(); - } + } - // Skip value that was already started with `event` - void SkipCurrentValue(const TEvent& event, TReader& reader); + // Skip value that was already started with `event` + void SkipCurrentValue(const TEvent& event, TReader& reader); - // Skip value that starts at `reader.next_event()` - void SkipValue(TReader& reader); + // Skip value that starts at `reader.next_event()` + void SkipValue(TReader& reader); // Skip values with attributes, wait for map value void SkipControlRecords(TReader& reader); - } -} + } +} |