reader.h 819 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include "event.h"
  3. #include "input.h"
  4. #include "stream_type.h"
  5. #include <util/system/yassert.h>
  6. #include <memory>
  7. namespace NYsonPull {
  8. namespace NDetail {
  9. class reader_impl;
  10. }
  11. //! \brief YSON reader facade class.
  12. //!
  13. //! Owns an input stream.
  14. class TReader {
  15. THolder<NInput::IStream> Stream_;
  16. THolder<NDetail::reader_impl> Impl_;
  17. public:
  18. TReader(THolder<NInput::IStream> stream, EStreamType mode);
  19. TReader(TReader&&) noexcept;
  20. ~TReader();
  21. //! \brief Advance stream to next event and return it.
  22. //!
  23. //! Any event data is invalidated by a call to NextEvent();
  24. const TEvent& NextEvent();
  25. //! \brief Get last returned event.
  26. const TEvent& LastEvent() const noexcept;
  27. };
  28. }