#pragma once #include "reader.h" #include namespace NYsonPull { class TStreamEventsRange: public TInputRangeAdaptor { TReader Reader_; bool AtEnd; public: TStreamEventsRange(THolder stream, EStreamType mode) : Reader_{std::move(stream), mode} , AtEnd(false) { } const TEvent* Last() const noexcept { return &Reader_.LastEvent(); } const TEvent* Next() { if (Y_UNLIKELY(AtEnd)) { return nullptr; } auto* event = &Reader_.NextEvent(); if (event->Type() == EEventType::EndStream) { AtEnd = true; } return event; } }; }